|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'], |
| 4 | + ignorePatterns: [ |
| 5 | + '!.eslintrc.js', |
| 6 | + '!jest.config.js', |
| 7 | + 'node_modules', |
| 8 | + 'dist', |
| 9 | + 'docs', |
| 10 | + 'coverage', |
| 11 | + // 'merged-packages', |
| 12 | + ], |
| 13 | + overrides: [ |
| 14 | + { |
| 15 | + files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'], |
| 16 | + extends: ['@metamask/eslint-config-jest'], |
| 17 | + rules: { |
| 18 | + // TODO: Re-enable |
| 19 | + 'import/no-named-as-default-member': 'off', |
| 20 | + 'jest/no-conditional-expect': 'off', |
| 21 | + }, |
| 22 | + }, |
| 23 | + { |
| 24 | + // These files are test helpers, not tests. We still use the Jest ESLint |
| 25 | + // config here to ensure that ESLint expects a test-like environment, but |
| 26 | + // various rules meant just to apply to tests have been disabled. |
| 27 | + files: ['**/tests/**/*.{ts,js}', '!*.test.{ts,js}'], |
| 28 | + rules: { |
| 29 | + 'jest/no-export': 'off', |
| 30 | + 'jest/require-top-level-describe': 'off', |
| 31 | + 'jest/no-if': 'off', |
| 32 | + 'jest/no-test-return-statement': 'off', |
| 33 | + // TODO: Re-enable this rule; we can accomodate this even in our test helpers |
| 34 | + 'jest/expect-expect': 'off', |
| 35 | + }, |
| 36 | + }, |
| 37 | + { |
| 38 | + files: ['*.js'], |
| 39 | + parserOptions: { |
| 40 | + sourceType: 'script', |
| 41 | + ecmaVersion: '2018', |
| 42 | + }, |
| 43 | + }, |
| 44 | + { |
| 45 | + files: ['*.ts'], |
| 46 | + extends: ['@metamask/eslint-config-typescript'], |
| 47 | + parserOptions: { |
| 48 | + tsconfigRootDir: __dirname, |
| 49 | + project: ['./tsconfig.json'], |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + // disabled due to incompatibility with Record<string, unknown> |
| 53 | + // See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440 |
| 54 | + '@typescript-eslint/consistent-type-definitions': 'off', |
| 55 | + |
| 56 | + // TODO: auto-fix breaks stuff |
| 57 | + '@typescript-eslint/promise-function-async': 'off', |
| 58 | + |
| 59 | + // TODO: re-enble most of these rules |
| 60 | + '@typescript-eslint/await-thenable': 'warn', |
| 61 | + '@typescript-eslint/naming-convention': 'off', |
| 62 | + '@typescript-eslint/no-floating-promises': 'warn', |
| 63 | + '@typescript-eslint/no-for-in-array': 'warn', |
| 64 | + '@typescript-eslint/no-loss-of-precision': 'warn', |
| 65 | + '@typescript-eslint/no-misused-promises': 'warn', |
| 66 | + '@typescript-eslint/no-unnecessary-type-assertion': 'off', |
| 67 | + '@typescript-eslint/unbound-method': 'off', |
| 68 | + '@typescript-eslint/prefer-enum-initializers': 'off', |
| 69 | + '@typescript-eslint/prefer-nullish-coalescing': 'off', |
| 70 | + '@typescript-eslint/prefer-optional-chain': 'off', |
| 71 | + '@typescript-eslint/prefer-reduce-type-parameter': 'off', |
| 72 | + '@typescript-eslint/restrict-plus-operands': 'warn', |
| 73 | + '@typescript-eslint/restrict-template-expressions': 'warn', |
| 74 | + 'no-restricted-syntax': 'off', |
| 75 | + 'no-restricted-globals': 'off', |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + files: ['tests/setupAfterEnv/matchers.ts'], |
| 80 | + parserOptions: { |
| 81 | + sourceType: 'script', |
| 82 | + }, |
| 83 | + }, |
| 84 | + { |
| 85 | + files: ['*.d.ts'], |
| 86 | + rules: { |
| 87 | + '@typescript-eslint/naming-convention': 'warn', |
| 88 | + 'import/unambiguous': 'off', |
| 89 | + }, |
| 90 | + }, |
| 91 | + { |
| 92 | + files: ['scripts/*.ts'], |
| 93 | + rules: { |
| 94 | + // All scripts will have shebangs. |
| 95 | + 'n/shebang': 'off', |
| 96 | + }, |
| 97 | + }, |
| 98 | + ], |
| 99 | + rules: { |
| 100 | + // Left disabled because various properties throughough this repo are snake_case because the |
| 101 | + // names come from external sources or must comply with standards |
| 102 | + // e.g. `txreceipt_status`, `signTypedData_v4`, `token_id` |
| 103 | + camelcase: 'off', |
| 104 | + 'id-length': 'off', |
| 105 | + |
| 106 | + // TODO: re-enble most of these rules |
| 107 | + '@typescript-eslint/naming-convention': 'off', |
| 108 | + 'function-paren-newline': 'off', |
| 109 | + 'guard-for-in': 'off', |
| 110 | + 'id-denylist': 'off', |
| 111 | + 'implicit-arrow-linebreak': 'off', |
| 112 | + 'import/no-anonymous-default-export': 'off', |
| 113 | + 'import/no-unassigned-import': 'off', |
| 114 | + 'lines-around-comment': 'off', |
| 115 | + 'n/no-sync': 'off', |
| 116 | + 'no-async-promise-executor': 'off', |
| 117 | + 'no-case-declarations': 'off', |
| 118 | + 'no-invalid-this': 'off', |
| 119 | + 'no-negated-condition': 'off', |
| 120 | + 'no-new': 'off', |
| 121 | + 'no-param-reassign': 'off', |
| 122 | + 'no-restricted-syntax': 'off', |
| 123 | + radix: 'off', |
| 124 | + 'require-atomic-updates': 'off', |
| 125 | + 'jsdoc/match-description': [ |
| 126 | + 'off', |
| 127 | + { matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' }, |
| 128 | + ], |
| 129 | + }, |
| 130 | + settings: { |
| 131 | + 'import/resolver': { |
| 132 | + typescript: {}, |
| 133 | + }, |
| 134 | + }, |
| 135 | +}; |
0 commit comments