Skip to content

Commit

Permalink
Updated all packages to use ESLint v9 (#579)
Browse files Browse the repository at this point in the history
* Updated all packages to use ESLint v9
  • Loading branch information
thehenrytsai authored May 17, 2024
1 parent 59a7e60 commit b36e7b1
Show file tree
Hide file tree
Showing 30 changed files with 600 additions and 489 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-donkeys-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@web5/api": patch
---

Updated some dependencies of `api` package
13 changes: 13 additions & 0 deletions .changeset/tricky-rockets-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@web5/common": patch
"@web5/crypto": patch
"@web5/crypto-aws-kms": patch
"@web5/dids": patch
"@web5/credentials": patch
"@web5/agent": patch
"@web5/user-agent": patch
"@web5/proxy-agent": patch
"@web5/identity-agent": patch
---

Updated dependencies of all packages
56 changes: 0 additions & 56 deletions .eslintrc.cjs

This file was deleted.

92 changes: 92 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const eslint = require('@eslint/js');
const globals = require('globals');
const tsParser = require('@typescript-eslint/parser');
const tsPlugin = require('@typescript-eslint/eslint-plugin');
const mochaPlugin = require('eslint-plugin-mocha');

/** @type {import('eslint').ESLint.ConfigData} */
module.exports = [
eslint.configs.recommended,
mochaPlugin.configs.flat.recommended,
// tsPlugin.configs.flat.recommended, // @typescript-eslint v7.9.0 doesn't have a recommended config yet, v8 alpha build has it, so should be available soon.
{
// extends : ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: '2022',
project: [
'tests/tsconfig.json'// this is the config that includes both `src` and `tests` directories
]
},
globals: {
...globals.node,
...globals.es2021,
...globals.browser
}
},
plugins: {
'@typescript-eslint': tsPlugin,
'mocha': mochaPlugin
},
files: [
'**/*.ts'
],
// IMPORTANT and confusing: `ignores` only exclude files from the `files` setting.
// To exclude *.js files entirely, you need to have a separate config object altogether. (See another `ignores` below.)
ignores: [
'**/*.d.ts',
],
rules: {
'key-spacing': [
'error',
{
'align': {
'afterColon' : true,
'beforeColon' : true,
'on' : 'colon'
}
}
],
'quotes': [
'error',
'single',
{ 'allowTemplateLiterals': true }
],
'semi' : ['error', 'always'],
'indent' : ['error', 2, { 'SwitchCase': 1 }],
'no-unused-vars' : 'off',
'prefer-const' : 'off',
'@typescript-eslint/no-unused-vars' : [
'error',
{
'vars' : 'all',
'args' : 'after-used',
'ignoreRestSiblings' : true,
'argsIgnorePattern' : '^_',
'varsIgnorePattern' : '^_'
}
],
'no-dupe-class-members' : 'off',
'no-trailing-spaces' : ['error'],
'@typescript-eslint/no-explicit-any' : 'off',
'@typescript-eslint/no-non-null-assertion' : 'off',
'@typescript-eslint/ban-ts-comment' : 'off',
// TODO: Revisit new default mocha rules that were disabled in #579 - https://github.com/TBD54566975/web5-js/issues/580
'mocha/no-exclusive-tests' : 'warn',
'mocha/no-setup-in-describe' : 'off',
'mocha/no-mocha-arrows' : 'off',
'mocha/max-top-level-suites' : 'off',
'mocha/no-identical-title' : 'off',
'mocha/no-pending-tests' : 'off',
'mocha/no-skipped-tests' : 'off',
'mocha/no-sibling-hooks' : 'off',
}
}, {
ignores: [
'**/*.js',
'**/*.cjs',
'**/*.mjs',
],
}];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@npmcli/package-json": "5.0.0",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@web5/dwn-server": "0.2.2",
"eslint-plugin-mocha": "10.1.0",
"eslint-plugin-mocha": "10.4.3",
"npkill": "0.11.3"
},
"pnpm": {
Expand Down
12 changes: 6 additions & 6 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"build:tests:node": "rimraf tests/compiled && pnpm tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs && pnpm build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"test:node": "pnpm build:tests:node && pnpm c8 mocha",
"test:browser": "pnpm build:tests:browser && web-test-runner"
},
Expand Down Expand Up @@ -92,16 +92,16 @@
"@types/ms": "0.7.31",
"@types/node": "20.11.19",
"@types/sinon": "17.0.2",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"@web/test-runner": "0.18.0",
"@web/test-runner-playwright": "0.11.0",
"abstract-level": "1.0.4",
"c8": "9.1.0",
"chai": "4.3.10",
"esbuild": "0.19.8",
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"eslint": "9.2.0",
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/tests/dwn-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ describe('AgentDwnApi', () => {

describe('get agent', () => {
it(`returns the 'agent' instance property`, () => {
// @ts-expect-error because we are only mocking a single property.
const mockAgent: Web5PlatformAgent = {
// we are only mocking
const mockAgent: any = {
agentDid: 'did:method:abc123'
};
const mockDwn = ({} as unknown) as Dwn;
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/tests/identity-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('AgentIdentityApi', () => {

describe('get agent', () => {
it(`returns the 'agent' instance property`, async () => {
// @ts-expect-error because we are only mocking a single property.
const mockAgent: Web5PlatformAgent = {
// we are only mocking
const mockAgent: any = {
agentDid: 'did:method:abc123'
};
const identityApi = new AgentIdentityApi({ agent: mockAgent });
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/tests/store-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DwnTestStore extends DwnDataStore<PortableDid> implements AgentDataStore<P
}
}

export class InMemoryTestStore extends InMemoryDataStore<PortableDid> implements AgentDataStore<PortableDid> {
class InMemoryTestStore extends InMemoryDataStore<PortableDid> implements AgentDataStore<PortableDid> {
protected name = 'InMemoryTestStore';

public async delete(params: DataStoreDeleteParams): Promise<boolean> {
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/tests/sync-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe('AgentSyncApi', () => {

describe('get agent', () => {
it(`returns the 'agent' instance property`, async () => {
// @ts-expect-error because we are only mocking a single property.
const mockAgent: Web5PlatformAgent = {
// we are only mocking
const mockAgent: any = {
agentDid: 'did:method:abc123'
};
const mockSyncEngine: SyncEngine = {} as SyncEngine;
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/tests/sync-engine-level.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('SyncEngineLevel', () => {

describe('get agent', () => {
it(`returns the 'agent' instance property`, () => {
// @ts-expect-error because we are only mocking a single property.
const mockAgent: Web5PlatformAgent = {
// we are only mocking
const mockAgent: any = {
agentDid: 'did:method:abc123'
};
const syncEngine = new SyncEngineLevel({ agent: mockAgent, db: {} as any });
Expand Down
12 changes: 6 additions & 6 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build:tests:node": "rimraf tests/compiled && pnpm tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs && pnpm build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"test:node": "pnpm build:tests:node && pnpm c8 mocha",
"test:browser": "pnpm build:tests:browser && web-test-runner"
},
Expand Down Expand Up @@ -91,15 +91,15 @@
"@types/mocha": "10.0.1",
"@types/node": "20.11.19",
"@types/sinon": "17.0.2",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"@web/test-runner": "0.18.0",
"@web/test-runner-playwright": "0.11.0",
"c8": "9.1.0",
"chai": "4.3.10",
"esbuild": "0.19.8",
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"eslint": "9.2.0",
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ export class Record implements RecordModel {
* @beta
*/
get data() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this; // Capture the context of the `Record` instance.
const dataObj = {

Expand Down
4 changes: 2 additions & 2 deletions packages/api/tests/did-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('DidApi', () => {
await testHarness.closeStorage();
});

describe('create()', async () => {
describe('create()', () => {
it('creates a DID and returns a response', async () => {
const didCreateResponse = await did.create({ method: 'jwk' });

Expand Down Expand Up @@ -62,7 +62,7 @@ describe('DidApi', () => {
});
});

describe('resolve()', async () => {
describe('resolve()', () => {
it('resolves a DID and returns a resolution result', async () => {
// const testDid = 'did:jwk:eyJjcnYiOiJFZDI1NTE5Iiwia3R5IjoiT0tQIiwieCI6Im80MHNoWnJzY28tQ2ZFcWs2bUZzWGZjUDk0bHkzQXozZ204NFB6QVVzWG8iLCJraWQiOiJCRHAweGltODJHc3dseG5QVjhUUHRCZFV3ODB3a0dJRjhnakZidzF4NWlRIiwiYWxnIjoiRWREU0EifQ';
const testDid = 'did:dht:ugkhixpk56o9izfp4ucc543scj5ajcis3rkh43yueq98qiaj8tgy';
Expand Down
2 changes: 2 additions & 0 deletions packages/api/tests/utils/chai-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as Chai from 'chai';

/**
* Chai plugin for validating URLs.
*
Expand Down
10 changes: 5 additions & 5 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"build:tests:node": "rimraf tests/compiled && pnpm tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs && pnpm build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"test:node": "pnpm build:tests:node && pnpm c8 mocha",
"test:browser": "pnpm build:tests:browser && web-test-runner"
},
Expand Down Expand Up @@ -82,16 +82,16 @@
"@types/mocha": "10.0.6",
"@types/node": "20.11.19",
"@types/readable-stream": "4.0.9",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"@web/test-runner": "0.18.0",
"@web/test-runner-playwright": "0.11.0",
"abstract-level": "1.0.4",
"c8": "9.1.0",
"chai": "5.1.1",
"chai-as-promised": "7.1.2",
"esbuild": "0.19.8",
"eslint": "8.47.0",
"eslint": "9.2.0",
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.4.0",
"mocha-junit-reporter": "2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions packages/common/tests/stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ describe('Stream', () => {
let chunkCount = 0;
let firstChunkLength: number | undefined;

// eslint-disable-next-line no-constant-condition
while (true) {
const { done, value } = await reader.read();
if (done) break;
Expand Down Expand Up @@ -418,7 +417,6 @@ describe('Stream', () => {
const readableStream = Stream.generateByteStream({ streamLength, chunkLength, fillValue: fillValueRange });
const reader = readableStream.getReader();

// eslint-disable-next-line no-constant-condition
while (true) {
const { done, value } = await reader.read();
if (done) break;
Expand Down
Loading

0 comments on commit b36e7b1

Please sign in to comment.