Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lint #1095

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 43 additions & 44 deletions packages/eslint-config-w3up/index.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,60 @@
'use strict'

module.exports = {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jsdoc/recommended",
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jsdoc/recommended',
],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-ts-comment': 'off',

/**
* many of these rules are inherited from hd-scripts.
* It may be useful over time to remove these rules
* and juse use plugin:jsdoc/recommended defaults.
* But that might require updating src.
*/
"jsdoc/check-values": "off",
"jsdoc/check-tag-names": "off",
"jsdoc/require-jsdoc": [
"warn",
'jsdoc/check-values': 'off',
'jsdoc/check-tag-names': 'off',
'jsdoc/require-jsdoc': [
'warn',
{
"publicOnly": true
}
publicOnly: true,
},
],
"jsdoc/require-returns": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/require-throws": "off",
"jsdoc/require-yields": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/valid-types": "off",
"jsdoc/tag-lines": [
"error",
"any",
'jsdoc/require-returns': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-throws': 'off',
'jsdoc/require-yields': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/valid-types': 'off',
'jsdoc/tag-lines': [
'error',
'any',
{
"startLines": 1
}
startLines: 1,
},
],
"jsdoc/no-undefined-types": [
"error",
'jsdoc/no-undefined-types': [
'error',
{
"definedTypes": [
"ArrayLike",
"AsyncIterable",
"AsyncIterableIterator",
"Iterable",
"IterableIterator",
"Generator",
"CryptoKeyPair",
"NodeJS",
"ErrorOptions",
"IDBTransactionMode"
]
}
]

}
definedTypes: [
'ArrayLike',
'AsyncIterable',
'AsyncIterableIterator',
'Iterable',
'IterableIterator',
'Generator',
'CryptoKeyPair',
'NodeJS',
'ErrorOptions',
'IDBTransactionMode',
],
},
],
},
}
6 changes: 5 additions & 1 deletion packages/filecoin-api/src/aggregator/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export type BufferQueue = Queue<BufferMessage>
export type BufferStore = Store<Link, BufferRecord>
export type AggregateStore = Store<AggregateRecordKey, AggregateRecord>
export type PieceAcceptQueue = Queue<PieceAcceptMessage>
export type InclusionStore = QueryableStore<InclusionRecordKey, InclusionRecord, InclusionRecordQueryByGroup>
export type InclusionStore = QueryableStore<
InclusionRecordKey,
InclusionRecord,
InclusionRecordQueryByGroup
>
export type AggregateOfferQueue = Queue<AggregateOfferMessage>

export interface ServiceContext {
Expand Down
4 changes: 3 additions & 1 deletion packages/filecoin-api/src/aggregator/buffer-reducing.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export async function handleBufferReducingWithAggregate({
pieces: aggregateInfo.addedBufferedPieces,
group,
}
const piecesBlock = await CBOR.write(aggregateInfo.addedBufferedPieces.map(bf => bf.piece))
const piecesBlock = await CBOR.write(
aggregateInfo.addedBufferedPieces.map((bf) => bf.piece)
)
const aggregateBlock = await CBOR.write(aggregateReducedBuffer)

// Store buffered pieces for aggregate
Expand Down
2 changes: 1 addition & 1 deletion packages/filecoin-api/src/aggregator/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const pieceAccept = async ({ capability }, context) => {
}
}

// Get buffered pieces
// Get buffered pieces
const [{ aggregate, inclusion }] = getInclusionRes.ok
const getAggregateRes = await context.aggregateStore.get({ aggregate })
if (getAggregateRes.error) {
Expand Down
6 changes: 5 additions & 1 deletion packages/filecoin-api/src/deal-tracker/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { Signer } from '@ucanto/interface'
import { PieceLink } from '@web3-storage/data-segment'
import { QueryableStore } from '../types.js'

export type DealStore = QueryableStore<DealRecordKey, DealRecord, DealRecordQueryByPiece>
export type DealStore = QueryableStore<
DealRecordKey,
DealRecord,
DealRecordQueryByPiece
>

export interface ServiceContext {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/filecoin-api/src/dealer/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export interface AggregateUpdatedStatusEventContext {
dealerService: ServiceConfig<DealerService>
}

export interface CronContext extends Pick<ServiceContext, 'aggregateStore' | 'dealTrackerService'> {}
export interface CronContext
extends Pick<ServiceContext, 'aggregateStore' | 'dealTrackerService'> {}

export interface AggregateRecord {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/filecoin-api/src/dealer/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async function updateApprovedDeals({
{ aggregate: deal.aggregate },
{
status: 'accepted',
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
}
)

Expand Down
15 changes: 7 additions & 8 deletions packages/filecoin-api/src/dealer/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import * as DealerCaps from '@web3-storage/capabilities/filecoin/dealer'
import { DealTracker } from '@web3-storage/filecoin-client'
// eslint-disable-next-line no-unused-vars
import * as API from '../types.js'
import {
StoreOperationFailed,
DecodeBlockOperationFailed,
} from '../errors.js'
import { StoreOperationFailed, DecodeBlockOperationFailed } from '../errors.js'

/**
* @param {API.Input<DealerCaps.aggregateOffer>} input
Expand Down Expand Up @@ -112,17 +109,19 @@ export const aggregateAccept = async ({ capability }, context) => {
const deals = Object.keys(info.out.ok.deals || {})
if (!deals.length) {
return {
error: new Server.Failure('no deals were obtained for given aggregate CID')
error: new Server.Failure(
'no deals were obtained for given aggregate CID'
),
}
}

// For receipts, we only care about first deal
// TODO: We need to revisit this with renewals
const deal = {
dataType: 0n,
dataSource: {
dealID: BigInt(deals[0])
}
dealID: BigInt(deals[0]),
},
}

return {
Expand Down
6 changes: 5 additions & 1 deletion packages/filecoin-api/src/storefront/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
ServiceConfig,
} from '../types.js'

export type PieceStore = UpdatableAndQueryableStore<PieceRecordKey, PieceRecord, Pick<PieceRecord, 'status'>>
export type PieceStore = UpdatableAndQueryableStore<
PieceRecordKey,
PieceRecord,
Pick<PieceRecord, 'status'>
>
export type FilecoinSubmitQueue = Queue<FilecoinSubmitMessage>
export type PieceOfferQueue = Queue<PieceOfferMessage>
export type TaskStore = Store<UnknownLink, Invocation>
Expand Down
2 changes: 1 addition & 1 deletion packages/filecoin-api/src/storefront/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const handleFilecoinSubmitMessage = async (context, message) => {
}
if (hasRes.ok) {
return {
ok: {}
ok: {},
}
}

Expand Down
5 changes: 1 addition & 4 deletions packages/filecoin-api/src/storefront/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import * as StorefrontCaps from '@web3-storage/capabilities/filecoin/storefront'
import * as AggregatorCaps from '@web3-storage/capabilities/filecoin/aggregator'
// eslint-disable-next-line no-unused-vars
import * as API from '../types.js'
import {
QueueOperationFailed,
StoreOperationFailed,
} from '../errors.js'
import { QueueOperationFailed, StoreOperationFailed } from '../errors.js'

/**
* @param {API.Input<StorefrontCaps.filecoinOffer>} input
Expand Down
14 changes: 4 additions & 10 deletions packages/filecoin-api/test/aggregator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ describe('Aggregator', () => {
// resources
/** @type {Map<string, unknown[]>} */
const queuedMessages = new Map()
const { pieceQueue } = getQueues(queuedMessages)
const {
pieceQueue,
} = getQueues(queuedMessages)
const {
aggregator: {
pieceStore,
aggregateStore,
inclusionStore,
},
aggregator: { pieceStore, aggregateStore, inclusionStore },
} = getStoreImplementations()

await test(
Expand All @@ -55,7 +49,7 @@ describe('Aggregator', () => {
inclusionStore,
pieceQueue,
queuedMessages,
validateAuthorization
validateAuthorization,
}
)
})
Expand Down Expand Up @@ -138,7 +132,7 @@ describe('Aggregator', () => {
minAggregateSize: 2 ** 34,
minUtilizationFactor: 4,
},
validateAuthorization
validateAuthorization,
}
)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/filecoin-api/test/context/queue-implementations.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Queue } from './queue.js'

/**
* @param {Map<string, unknown[]>} queuedMessages
* @param {Map<string, unknown[]>} queuedMessages
*/
export const getQueueImplementations = (
queuedMessages,
Expand All @@ -26,7 +26,7 @@ export const getQueueImplementations = (
return {
storefront: {
filecoinSubmitQueue,
pieceOfferQueue
}
pieceOfferQueue,
},
}
}
2 changes: 1 addition & 1 deletion packages/filecoin-api/test/context/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function getConnection(id, service) {
id: id,
service,
codec: CAR.inbound,
validateAuthorization
validateAuthorization,
})
const connection = Client.connect({
id: id,
Expand Down
9 changes: 6 additions & 3 deletions packages/filecoin-api/test/context/store-implementations.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@ export const getStoreImplementations = (
/** @type {Set<DealerAggregateRecord>} */ items,
/** @type {Partial<DealerAggregateRecord>} */ search
) => {
return Array.from(items).filter((i) => i.status === search.status || i.aggregate.equals(search.aggregate))
return Array.from(items).filter(
(i) =>
i.status === search.status || i.aggregate.equals(search.aggregate)
)
},
updateFn: (
/** @type {Set<DealerAggregateRecord>} */ items,
/** @type {DealerAggregateRecordKey} */ key,
/** @type {Partial<DealerAggregateRecord>} */ item
) => {
const itemToUpdate = Array.from(items).find(
(i) => i.aggregate.equals(key.aggregate)
const itemToUpdate = Array.from(items).find((i) =>
i.aggregate.equals(key.aggregate)
)
if (!itemToUpdate) {
throw new Error('not found')
Expand Down
2 changes: 1 addition & 1 deletion packages/filecoin-api/test/deal-tracker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('deal-tracker', () => {
assert.fail(error)
},
},
validateAuthorization
validateAuthorization,
}
)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/filecoin-api/test/dealer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Dealer', () => {
audience: dealTrackerSigner,
},
},
validateAuthorization
validateAuthorization,
}
)
})
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('Dealer', () => {
},
},
service,
validateAuthorization
validateAuthorization,
}
)
})
Expand Down
Loading
Loading