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

[DNM] preview/eslint9 #4727

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
128 changes: 0 additions & 128 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable
- run: yarn lint
- run: yarn eslint
- name: Require clean working directory
shell: bash
run: |
Expand Down
168 changes: 168 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import base from '@metamask/eslint-config';

Check failure on line 1 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 1 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 1 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 1 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)
import nodejs from '@metamask/eslint-config-nodejs';

Check failure on line 2 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config-nodejs': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 2 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config-nodejs': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 2 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config-nodejs': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)

Check failure on line 2 in eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Parse errors in imported module '@metamask/eslint-config-nodejs': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)
import jest from '@metamask/eslint-config-jest';
import typescript from '@metamask/eslint-config-typescript';
import tseslint from 'typescript-eslint';

const config = tseslint.config({
ignores: [
'!.eslint.config.mjs',
'!jest.config.js',
'yarn.lock',
'**/**.map',
'**/**.tsbuildinfo',
'**/*.json',
'**/*.md',
'**/LICENSE',
'**/*.sh',
'**/.DS_Store',
'**/dist/**',
'**/docs/**',
'**/coverage/**',
'merged-packages/**',
'.yarn/**',
'scripts/create-package/package-template/**',
],
},
{
extends: [...base, ...nodejs],
rules: {
// Left disabled because various properties throughough this repo are snake_case because the
// names come from external sources or must comply with standards
// e.g. `txreceipt_status`, `signTypedData_v4`, `token_id`
camelcase: 'off',
'id-length': 'off',

// TODO: re-enble most of these rules
'@typescript-eslint/naming-convention': 'off',
'function-paren-newline': 'off',
'id-denylist': 'off',
'implicit-arrow-linebreak': 'off',
'import/no-anonymous-default-export': 'off',
'import/no-unassigned-import': 'off',
'lines-around-comment': 'off',
'n/no-sync': 'off',
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-invalid-this': 'off',
'no-negated-condition': 'off',
'no-new': 'off',
'no-param-reassign': 'off',
'no-restricted-syntax': 'off',
radix: 'off',
'require-atomic-updates': 'off',
'jsdoc/match-description': [
'off',
{ matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' },
],
},
settings: {
'import/resolver': {
typescript: {},
},
jsdoc: {
mode: 'typescript',
},
},
},
{
files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'],
extends: [...jest, ...typescript],
languageOptions: {
sourceType: 'module',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/naming-convention': 'warn',
'import/unambiguous': 'off',
},
},
{
files: ['scripts/*.ts'],
extends: nodejs,
languageOptions: {
sourceType: 'module',
parserOptions: {
project: ['./scripts/*/tsconfig.json'],
},
},
rules: {
// All scripts will have shebangs.
'n/shebang': 'off',
},
},
{
// These files are test helpers, not tests. We still use the Jest ESLint
// config here to ensure that ESLint expects a test-like environment, but
// various rules meant just to apply to tests have been disabled.
files: ['**/tests/**/*.{ts,js}', '!*.test.{ts,js}'],
languageOptions: {
sourceType: 'module',
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: ['./packages/*/tsconfig.json'],
},
},
rules: {
'jest/no-export': 'off',
'jest/require-top-level-describe': 'off',
'jest/no-if': 'off',
},
},
{
files: ['*.js', '*.cjs'],
languageOptions: {
parserOptions: {
sourceType: 'script',
ecmaVersion: 2020,
},
},
},
{
files: ['*.ts'],
extends: typescript,
languageOptions: {
sourceType: 'module',
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: ['./packages/*/tsconfig.json'],
},
},
rules: {
// Enable rules that are disabled in `@metamask/eslint-config-typescript`
'@typescript-eslint/no-explicit-any': 'error',

// TODO: auto-fix breaks stuff
'@typescript-eslint/promise-function-async': 'off',

// TODO: re-enable most of these rules
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'no-restricted-syntax': 'off',
'no-restricted-globals': 'off',
},
},
{
files: ['tests/setupAfterEnv/matchers.ts'],
languageOptions: {
parserOptions: {
sourceType: 'module',
},
},
},
{
files: ['**/jest.environment.js'],
extends: nodejs,
rules: {
// These files run under Node, and thus `require(...)` is expected.
'n/global-require': 'off',
},
});

export default config;
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"@babel/preset-typescript": "^7.23.3",
"@lavamoat/allow-scripts": "^3.0.4",
"@metamask/create-release-branch": "^3.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/eslint-config": "github:MetaMask/eslint-config#head=mrtenz/eslint-9&workspace=@metamask/eslint-config",
"@metamask/eslint-config-jest": "github:MetaMask/eslint-config#head=mrtenz/eslint-9&workspace=@metamask/eslint-config-jest",
"@metamask/eslint-config-nodejs": "github:MetaMask/eslint-config#head=mrtenz/eslint-9&workspace=@metamask/eslint-config-nodejs",
"@metamask/eslint-config-typescript": "github:MetaMask/eslint-config#head=mrtenz/eslint-9&workspace=@metamask/eslint-config-typescript",
"@metamask/eth-block-tracker": "^10.0.0",
"@metamask/eth-json-rpc-provider": "^4.1.4",
"@metamask/json-rpc-engine": "^9.0.3",
Expand All @@ -64,34 +64,35 @@
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@yarnpkg/types": "^4.0.0",
"babel-jest": "^27.5.1",
"babel-jest": "^29.7.0",
"depcheck": "^1.4.7",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint": "^9.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-interactive": "^10.8.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-import-x": "^4.3.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.9.1",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-jsdoc": "^50.2.4",
"eslint-plugin-n": "^17.10.3",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"execa": "^5.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1",
"jest-silent-reporter": "^0.5.0",
"lodash": "^4.17.21",
"nock": "^13.3.1",
"prettier": "^2.7.1",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.4.5",
"rimraf": "^5.0.5",
"semver": "^7.6.3",
"simple-git-hooks": "^2.8.0",
"ts-node": "^10.9.1",
"typescript": "~5.2.2",
"typescript-eslint": "^8.7.0",
"yargs": "^17.7.2"
},
"packageManager": "[email protected]",
Expand Down
Loading
Loading