diff --git a/.github/workflows/access-client.yml b/.github/workflows/access-client.yml index 549765e39..56285511a 100644 --- a/.github/workflows/access-client.yml +++ b/.github/workflows/access-client.yml @@ -8,11 +8,13 @@ on: - main paths: - 'packages/access-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/access-client.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/access-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/access-client.yml' - 'pnpm-lock.yaml' jobs: diff --git a/.github/workflows/capabilities.yml b/.github/workflows/capabilities.yml index a4620c1e5..d58b6278c 100644 --- a/.github/workflows/capabilities.yml +++ b/.github/workflows/capabilities.yml @@ -8,11 +8,13 @@ on: - main paths: - 'packages/capabilities/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/capabilities.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/capabilities/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/capabilities.yml' - 'pnpm-lock.yaml' jobs: diff --git a/.github/workflows/did-mailto.yml b/.github/workflows/did-mailto.yml index 6cd5acadb..a1afe766d 100644 --- a/.github/workflows/did-mailto.yml +++ b/.github/workflows/did-mailto.yml @@ -5,11 +5,13 @@ on: - main paths: - 'packages/did-mailto/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/did-mailto.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/did-mailto/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/did-mailto.yml' - 'pnpm-lock.yaml' jobs: diff --git a/.github/workflows/filecoin-api.yml b/.github/workflows/filecoin-api.yml index e80d6ba38..7f184c098 100644 --- a/.github/workflows/filecoin-api.yml +++ b/.github/workflows/filecoin-api.yml @@ -9,12 +9,14 @@ on: - main paths: - 'packages/filecoin-api/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/filecoin-api.yml' - 'pnpm-lock.yaml' - '.env.tpl' pull_request: paths: - 'packages/filecoin-api/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/filecoin-api.yml' - 'pnpm-lock.yaml' - '.env.tpl' diff --git a/.github/workflows/filecoin-client.yml b/.github/workflows/filecoin-client.yml index 95934c654..8780e961e 100644 --- a/.github/workflows/filecoin-client.yml +++ b/.github/workflows/filecoin-client.yml @@ -8,11 +8,13 @@ on: - main paths: - 'packages/filecoin-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/filecoin-client.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/filecoin-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/filecoin-client.yml' - 'pnpm-lock.yaml' jobs: diff --git a/.github/workflows/upload-api.yml b/.github/workflows/upload-api.yml index fc6537c30..a9e052763 100644 --- a/.github/workflows/upload-api.yml +++ b/.github/workflows/upload-api.yml @@ -9,12 +9,14 @@ on: - main paths: - 'packages/upload-api/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/upload-api.yml' - 'pnpm-lock.yaml' - '.env.tpl' pull_request: paths: - 'packages/upload-api/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/upload-api.yml' - 'pnpm-lock.yaml' - '.env.tpl' diff --git a/.github/workflows/upload-client.yml b/.github/workflows/upload-client.yml index 55553c57b..c8e49442e 100644 --- a/.github/workflows/upload-client.yml +++ b/.github/workflows/upload-client.yml @@ -8,11 +8,13 @@ on: - main paths: - 'packages/upload-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/client.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/upload-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/client.yml' - 'pnpm-lock.yaml' jobs: diff --git a/.github/workflows/w3up-client.yml b/.github/workflows/w3up-client.yml index 04c290dc5..cd2a01196 100644 --- a/.github/workflows/w3up-client.yml +++ b/.github/workflows/w3up-client.yml @@ -5,11 +5,13 @@ on: - main paths: - 'packages/w3up-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/w3up-client.yml' - 'pnpm-lock.yaml' pull_request: paths: - 'packages/w3up-client/**' + - 'packages/eslint-config-w3up/**' - '.github/workflows/w3up-client.yml' - 'pnpm-lock.yaml' jobs: diff --git a/packages/access-client/src/agent.js b/packages/access-client/src/agent.js index d4d2d7c6d..520b13e6f 100644 --- a/packages/access-client/src/agent.js +++ b/packages/access-client/src/agent.js @@ -632,7 +632,7 @@ export async function addSpacesFromDelegations(agent, delegations) { for (const [did, value] of Object.entries(allows)) { // If we discovered a delegation to any DID, we add it to the spaces list. if (did.startsWith('did:key') && Object.keys(value).length > 0) { - data.addSpace(/** @type {API.DID} */ (did), { + await data.addSpace(/** @type {API.DID} */ (did), { name: '', }) } diff --git a/packages/access-client/src/space.js b/packages/access-client/src/space.js index bc16dc733..12b4366fc 100644 --- a/packages/access-client/src/space.js +++ b/packages/access-client/src/space.js @@ -176,7 +176,7 @@ class OwnedSpace { const proof = await createAuthorization(this, { agent }) await agent.importSpaceFromDelegation(proof) - agent.setCurrentSpace(this.did()) + await agent.setCurrentSpace(this.did()) return { ok: {} } } diff --git a/packages/access-client/test/agent-data.test.js b/packages/access-client/test/agent-data.test.js index 5931451c7..fb8b4f276 100644 --- a/packages/access-client/test/agent-data.test.js +++ b/packages/access-client/test/agent-data.test.js @@ -51,7 +51,7 @@ describe('AgentData', () => { }, ], }) - agentData.addDelegation(delegation) + await agentData.addDelegation(delegation) const mapIssuerToSession = new Map() for (const service of services) { @@ -61,7 +61,7 @@ describe('AgentData', () => { with: service.did(), nb: { proof: delegation.cid }, }) - agentData.addDelegation(session) + await agentData.addDelegation(session) mapIssuerToSession.set(service.did(), session) } diff --git a/packages/access-client/test/agent.test.js b/packages/access-client/test/agent.test.js index df10989d3..2849ccb85 100644 --- a/packages/access-client/test/agent.test.js +++ b/packages/access-client/test/agent.test.js @@ -445,8 +445,8 @@ describe('Agent', function () { with: service.did(), nb: { proof: delegation.cid }, }) - agent.addProof(delegation) - agent.addProof(session) + await agent.addProof(delegation) + await agent.addProof(session) } const proofsForService = agent.proofs([ { can: 'provider/add', with: account }, @@ -500,8 +500,8 @@ describe('Agent', function () { with: service.did(), nb: { proof: delegation.cid }, }) - agent.addProof(delegation) - agent.addProof(session) + await agent.addProof(delegation) + await agent.addProof(session) } /** diff --git a/packages/access-client/test/stores/store-indexeddb.browser.test.js b/packages/access-client/test/stores/store-indexeddb.browser.test.js index 81495e132..cb58dacea 100644 --- a/packages/access-client/test/stores/store-indexeddb.browser.test.js +++ b/packages/access-client/test/stores/store-indexeddb.browser.test.js @@ -82,7 +82,9 @@ describe('IndexedDB store', () => { expiration: Infinity, }) - data0.addDelegation(del0, { audience: { name: 'test', type: 'device' } }) + await data0.addDelegation(del0, { + audience: { name: 'test', type: 'device' }, + }) await store.save(data0.export()) const exportData1 = await store.load() diff --git a/packages/did-mailto/test/did-mailto.spec.js b/packages/did-mailto/test/did-mailto.spec.js index a9d8290a5..20ebc6097 100644 --- a/packages/did-mailto/test/did-mailto.spec.js +++ b/packages/did-mailto/test/did-mailto.spec.js @@ -1,37 +1,37 @@ import * as assert from 'assert' import * as didMailto from '../src/index.js' -describe('did-mailto', () => { - testDidMailto(didMailto, async (name, test) => it(name, test)) +describe('did-mailto', async () => { + await testDidMailto(didMailto, async (name, test) => it(name, test)) }) /** * @param {typeof didMailto} didMailto - did-mailto module to test * @param {import("./test-types.js").TestAdder} test - function to call to add a named test */ -function testDidMailto(didMailto, test) { - test('module is an object', async () => { +async function testDidMailto(didMailto, test) { + await test('module is an object', async () => { assert.equal(typeof didMailto, 'object') }) for (const { email, did } of examples()) { - test(`fromEmail("${email}")`, async () => { + await test(`fromEmail("${email}")`, async () => { assert.deepStrictEqual(didMailto.fromEmail(email), did) }) - test(`toEmail("${did}")`, async () => { + await test(`toEmail("${did}")`, async () => { assert.deepStrictEqual(didMailto.toEmail(did), email) }) - test(`toEmail(fromEmail("${email}"))`, async () => { + await test(`toEmail(fromEmail("${email}"))`, async () => { assert.deepStrictEqual( didMailto.toEmail(didMailto.fromEmail(email)), email ) }) - test(`fromEmail(toEmail("${did}"))`, async () => { + await test(`fromEmail(toEmail("${did}"))`, async () => { assert.deepStrictEqual(didMailto.fromEmail(didMailto.toEmail(did)), did) }) } for (const email of validEmailAddresses()) { - test(`email("${email}")`, async () => { + await test(`email("${email}")`, async () => { assert.doesNotThrow(() => didMailto.email(email), 'can parse to email') }) } diff --git a/packages/eslint-config-w3up/index.js b/packages/eslint-config-w3up/index.js index c120a791a..f0cc00880 100644 --- a/packages/eslint-config-w3up/index.js +++ b/packages/eslint-config-w3up/index.js @@ -6,7 +6,11 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', ], + parserOptions: { + EXPERIMENTAL_useProjectService: true, + }, rules: { + "@typescript-eslint/no-floating-promises": "error", '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/ban-ts-comment': 'off', diff --git a/packages/eslint-config-w3up/tsconfig.json b/packages/eslint-config-w3up/tsconfig.json new file mode 100644 index 000000000..3c42f94d9 --- /dev/null +++ b/packages/eslint-config-w3up/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src", "test", "index.js"], + "exclude": ["**/node_modules/**", "dist"], + "references": [], + "typedocOptions": { + "entryPoints": ["."] + } +} diff --git a/packages/upload-api/test/access-client-agent.js b/packages/upload-api/test/access-client-agent.js index 3f805cca9..b55a791e8 100644 --- a/packages/upload-api/test/access-client-agent.js +++ b/packages/upload-api/test/access-client-agent.js @@ -273,7 +273,7 @@ export const test = { await deviceA.importSpaceFromDelegation(auth) // make space current - deviceA.setCurrentSpace(spaceCreation.did()) + await deviceA.setCurrentSpace(spaceCreation.did()) const recovery = await spaceCreation.createRecovery(account.did()) const delegateResult = await AgentAccess.delegate(deviceA, { @@ -395,7 +395,7 @@ export const test = { const { account, agent, mail } = await setup(context) // fire off request - requestAccess(agent, account, [{ can: '*' }]) + await requestAccess(agent, account, [{ can: '*' }]) const claimed = pollAccessClaimUntil( delegationsIncludeSessionProof, agent, diff --git a/packages/upload-api/test/handlers/plan.js b/packages/upload-api/test/handlers/plan.js index da55b1d8d..9c8e08855 100644 --- a/packages/upload-api/test/handlers/plan.js +++ b/packages/upload-api/test/handlers/plan.js @@ -12,7 +12,7 @@ export const test = { 'an account can get plan information': async (assert, context) => { const account = 'did:mailto:example.com:alice' const product = 'did:web:test.web3.storage' - context.plansStorage.set(account, product) + await context.plansStorage.set(account, product) const connection = connect({ id: context.id, channel: createServer(context), diff --git a/packages/upload-api/test/handlers/provider-add.spec.js b/packages/upload-api/test/handlers/provider-add.spec.js index 1ede178b6..b348c9d32 100644 --- a/packages/upload-api/test/handlers/provider-add.spec.js +++ b/packages/upload-api/test/handlers/provider-add.spec.js @@ -254,7 +254,7 @@ describe(`provider/add`, () => { assert.ok(addW3Storage.out.error, 'Provider already added to this space') } finally { - cleanupContext(context) + await cleanupContext(context) } }) @@ -289,7 +289,7 @@ describe(`provider/add`, () => { `Account identified by ${account.did()} has not selected a payment plan` ) } finally { - cleanupContext(context) + await cleanupContext(context) } }) }) diff --git a/packages/upload-client/test/store.test.js b/packages/upload-client/test/store.test.js index 082eae362..2f53d5f8c 100644 --- a/packages/upload-client/test/store.test.js +++ b/packages/upload-client/test/store.test.js @@ -123,7 +123,7 @@ describe('Store.add', () => { channel: server, }) - assert.rejects( + await assert.rejects( Store.add( { issuer: agent, with: space.did(), proofs, audience: serviceSigner }, car, @@ -176,7 +176,7 @@ describe('Store.add', () => { channel: server, }) - assert.rejects( + await assert.rejects( Store.add( { issuer: agent, with: space.did(), proofs, audience: serviceSigner }, car, diff --git a/packages/w3up-client/test/capability/filecoin.test.js b/packages/w3up-client/test/capability/filecoin.test.js index 8fe283aba..fa388c67a 100644 --- a/packages/w3up-client/test/capability/filecoin.test.js +++ b/packages/w3up-client/test/capability/filecoin.test.js @@ -70,7 +70,7 @@ describe('FilecoinClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const [cargo] = await randomCargo(1, 100) @@ -145,7 +145,7 @@ describe('FilecoinClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const res = await alice.capability.filecoin.info(cargo.link) diff --git a/packages/w3up-client/test/capability/space.test.js b/packages/w3up-client/test/capability/space.test.js index d6519de2c..179dc0e3a 100644 --- a/packages/w3up-client/test/capability/space.test.js +++ b/packages/w3up-client/test/capability/space.test.js @@ -46,7 +46,7 @@ describe('SpaceClient', () => { access: { 'space/info': {} }, expiration: Infinity, }) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const info = await alice.capability.space.info(space.did()) diff --git a/packages/w3up-client/test/capability/store.test.js b/packages/w3up-client/test/capability/store.test.js index 8a5c7cafd..9de3da339 100644 --- a/packages/w3up-client/test/capability/store.test.js +++ b/packages/w3up-client/test/capability/store.test.js @@ -47,7 +47,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const car = await randomCAR(128) @@ -102,7 +102,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const res = await alice.capability.store.list() @@ -147,7 +147,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) await alice.capability.store.remove((await randomCAR(128)).cid) @@ -193,7 +193,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const result = await alice.capability.store.get(car.cid) diff --git a/packages/w3up-client/test/capability/upload.test.js b/packages/w3up-client/test/capability/upload.test.js index 94c770fd5..393265cc7 100644 --- a/packages/w3up-client/test/capability/upload.test.js +++ b/packages/w3up-client/test/capability/upload.test.js @@ -49,7 +49,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) await alice.capability.upload.add(car.roots[0], [car.cid]) @@ -103,7 +103,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const res = await alice.capability.upload.list() @@ -148,7 +148,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) await alice.capability.upload.remove((await randomCAR(128)).roots[0]) @@ -195,7 +195,7 @@ describe('StoreClient', () => { const space = await alice.createSpace('test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const result = await alice.capability.upload.get(car.cid) diff --git a/packages/w3up-client/test/client.test.js b/packages/w3up-client/test/client.test.js index a7b645a3d..9316afcb4 100644 --- a/packages/w3up-client/test/client.test.js +++ b/packages/w3up-client/test/client.test.js @@ -83,7 +83,7 @@ describe('Client', () => { const space = await alice.createSpace('upload-test') const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) await alice.setCurrentSpace(space.did()) const dataCID = await alice.uploadFile(file, { @@ -293,7 +293,7 @@ describe('Client', () => { assert(current0 === undefined) const space = await alice.createSpace('new-space') - alice.addSpace(await space.createAuthorization(alice)) + await alice.addSpace(await space.createAuthorization(alice)) await alice.setCurrentSpace(space.did()) const current1 = alice.currentSpace() @@ -309,7 +309,7 @@ describe('Client', () => { const name = `space-${Date.now()}` const space = await alice.createSpace(name) const auth = await space.createAuthorization(alice) - alice.addSpace(auth) + await alice.addSpace(auth) const spaces = alice.spaces() assert.equal(spaces.length, 1) @@ -348,7 +348,7 @@ describe('Client', () => { const bob = new Client(await AgentData.create()) const space = await alice.createSpace('proof-space') - alice.addSpace(await space.createAuthorization(alice)) + await alice.addSpace(await space.createAuthorization(alice)) await alice.setCurrentSpace(space.did()) const delegation = await alice.createDelegation(bob.agent, ['store/*']) @@ -447,7 +447,7 @@ describe('Client', () => { const bob = new Client(await AgentData.create()) const space = await alice.createSpace('test') - alice.addSpace(await space.createAuthorization(alice)) + await alice.addSpace(await space.createAuthorization(alice)) await alice.setCurrentSpace(space.did()) const name = `delegation-${Date.now()}` const delegation = await alice.createDelegation(bob.agent, ['space/*'], {