1module.exports = { 2 root: true, 3 plugins: [ 4 'eslint-plugin', 5 '@typescript-eslint', 6 'jest', 7 'import', 8 'eslint-comments', 9 '@typescript-eslint/internal', 10 ], 11 env: { 12 es6: true, 13 node: true, 14 }, 15 extends: [ 16 'eslint:recommended', 17 'plugin:@typescript-eslint/recommended', 18 'plugin:@typescript-eslint/recommended-requiring-type-checking', 19 ], 20 parserOptions: { 21 sourceType: 'module', 22 project: [ 23 './tsconfig.eslint.json', 24 './tests/integration/utils/jsconfig.json', 25 './packages/*/tsconfig.json', 26 ], 27 tsconfigRootDir: __dirname, 28 warnOnUnsupportedTypeScriptVersion: false, 29 EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, 30 }, 31 rules: { 32 // 33 // our plugin :D 34 // 35 36 '@typescript-eslint/ban-ts-comment': [ 37 'error', 38 { 39 'ts-expect-error': 'allow-with-description', 40 'ts-ignore': true, 41 'ts-nocheck': true, 42 'ts-check': false, 43 minimumDescriptionLength: 5, 44 }, 45 ], 46 '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], 47 '@typescript-eslint/explicit-function-return-type': 'error', 48 '@typescript-eslint/explicit-module-boundary-types': 'off', 49 '@typescript-eslint/no-empty-function': [ 50 'error', 51 { allow: ['arrowFunctions'] }, 52 ], 53 '@typescript-eslint/no-explicit-any': 'error', 54 '@typescript-eslint/no-non-null-assertion': 'off', 55 '@typescript-eslint/no-var-requires': 'off', 56 '@typescript-eslint/prefer-nullish-coalescing': 'error', 57 '@typescript-eslint/prefer-optional-chain': 'error', 58 '@typescript-eslint/unbound-method': 'off', 59 '@typescript-eslint/prefer-as-const': 'error', 60 '@typescript-eslint/no-unused-vars': [ 61 'warn', 62 { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }, 63 ], 64 65 // TODO - enable these new recommended rules 66 '@typescript-eslint/no-floating-promises': 'off', 67 '@typescript-eslint/no-unsafe-assignment': 'off', 68 '@typescript-eslint/no-unsafe-call': 'off', 69 '@typescript-eslint/no-unsafe-member-access': 'off', 70 '@typescript-eslint/no-unsafe-return': 'off', 71 '@typescript-eslint/restrict-plus-operands': 'off', 72 '@typescript-eslint/restrict-template-expressions': 'off', 73 // TODO - enable this 74 '@typescript-eslint/naming-convention': 'off', 75 76 // 77 // Internal repo rules 78 // 79 80 '@typescript-eslint/internal/no-poorly-typed-ts-props': 'error', 81 '@typescript-eslint/internal/no-typescript-default-import': 'error', 82 '@typescript-eslint/internal/prefer-ast-types-enum': 'error', 83 84 // 85 // eslint base 86 // 87 88 curly: ['error', 'all'], 89 'no-mixed-operators': 'error', 90 'no-console': 'error', 91 'no-process-exit': 'error', 92 93 // 94 // eslint-plugin-eslint-comment 95 // 96 97 // require a eslint-enable comment for every eslint-disable comment 98 'eslint-comments/disable-enable-pair': [ 99 'error', 100 { 101 allowWholeFile: true, 102 }, 103 ], 104 // disallow a eslint-enable comment for multiple eslint-disable comments 105 'eslint-comments/no-aggregating-enable': 'error', 106 // disallow duplicate eslint-disable comments 107 'eslint-comments/no-duplicate-disable': 'error', 108 // disallow eslint-disable comments without rule names 109 'eslint-comments/no-unlimited-disable': 'error', 110 // disallow unused eslint-disable comments 111 'eslint-comments/no-unused-disable': 'error', 112 // disallow unused eslint-enable comments 113 'eslint-comments/no-unused-enable': 'error', 114 // disallow ESLint directive-comments 115 'eslint-comments/no-use': [ 116 'error', 117 { 118 allow: [ 119 'eslint-disable', 120 'eslint-disable-line', 121 'eslint-disable-next-line', 122 'eslint-enable', 123 ], 124 }, 125 ], 126 127 // 128 // eslint-plugin-import 129 // 130 131 // disallow non-import statements appearing before import statements 132 'import/first': 'error', 133 // Require a newline after the last import/require in a group 134 'import/newline-after-import': 'error', 135 // Forbid import of modules using absolute paths 136 'import/no-absolute-path': 'error', 137 // disallow AMD require/define 138 'import/no-amd': 'error', 139 // forbid default exports 140 'import/no-default-export': 'error', 141 // Forbid the use of extraneous packages 142 'import/no-extraneous-dependencies': [ 143 'error', 144 { 145 devDependencies: true, 146 peerDependencies: true, 147 optionalDependencies: false, 148 }, 149 ], 150 // Forbid mutable exports 151 'import/no-mutable-exports': 'error', 152 // Prevent importing the default as if it were named 153 'import/no-named-default': 'error', 154 // Prohibit named exports 155 'import/no-named-export': 'off', // we want everything to be a named export 156 // Forbid a module from importing itself 157 'import/no-self-import': 'error', 158 // Require modules with a single export to use a default export 159 'import/prefer-default-export': 'off', // we want everything to be named 160 }, 161 overrides: [ 162 // all test files 163 { 164 files: [ 165 'packages/*/tests/**/*.test.ts', 166 'packages/*/tests/**/*.spec.ts', 167 'packages/parser/tests/**/*.ts', 168 ], 169 env: { 170 'jest/globals': true, 171 }, 172 rules: { 173 'eslint-plugin/no-identical-tests': 'error', 174 'jest/no-disabled-tests': 'warn', 175 'jest/no-focused-tests': 'error', 176 'jest/no-alias-methods': 'error', 177 'jest/no-identical-title': 'error', 178 'jest/no-jasmine-globals': 'error', 179 'jest/no-jest-import': 'error', 180 'jest/no-test-prefixes': 'error', 181 'jest/no-test-callback': 'error', 182 'jest/no-test-return-statement': 'error', 183 'jest/prefer-to-have-length': 'warn', 184 'jest/prefer-spy-on': 'error', 185 'jest/valid-expect': 'error', 186 }, 187 }, 188 // plugin source files 189 { 190 files: [ 191 'packages/eslint-plugin-internal/**/*.ts', 192 'packages/eslint-plugin-tslint/**/*.ts', 193 'packages/eslint-plugin/**/*.ts', 194 ], 195 rules: { 196 '@typescript-eslint/internal/no-typescript-estree-import': 'error', 197 }, 198 }, 199 // plugin rule source files 200 { 201 files: [ 202 'packages/eslint-plugin-internal/src/rules/**/*.ts', 203 'packages/eslint-plugin-tslint/src/rules/**/*.ts', 204 'packages/eslint-plugin/src/configs/**/*.ts', 205 'packages/eslint-plugin/src/rules/**/*.ts', 206 ], 207 rules: { 208 // specifically for rules - default exports makes the tooling easier 209 'import/no-default-export': 'off', 210 }, 211 }, 212 // plugin rule tests 213 { 214 files: [ 215 'packages/eslint-plugin-internal/tests/rules/**/*.test.ts', 216 'packages/eslint-plugin-tslint/tests/rules/**/*.test.ts', 217 'packages/eslint-plugin/tests/rules/**/*.test.ts', 218 'packages/eslint-plugin/tests/eslint-rules/**/*.test.ts', 219 ], 220 rules: { 221 '@typescript-eslint/internal/plugin-test-formatting': 'error', 222 }, 223 }, 224 // files which list all the things 225 { 226 files: ['packages/eslint-plugin/src/rules/index.ts'], 227 rules: { 228 // enforce alphabetical ordering 229 'sort-keys': 'error', 230 'import/order': ['error', { alphabetize: { order: 'asc' } }], 231 }, 232 }, 233 // tools and tests 234 { 235 files: ['**/tools/**/*.ts', '**/tests/**/*.ts'], 236 rules: { 237 // allow console logs in tools and tests 238 'no-console': 'off', 239 }, 240 }, 241 // generated files 242 { 243 files: [ 244 'packages/scope-manager/src/lib/*.ts', 245 'packages/eslint-plugin/src/configs/*.ts', 246 ], 247 rules: { 248 // allow console logs in tools and tests 249 '@typescript-eslint/internal/no-poorly-typed-ts-props': 'off', 250 '@typescript-eslint/internal/no-typescript-default-import': 'off', 251 '@typescript-eslint/internal/prefer-ast-types-enum': 'off', 252 }, 253 }, 254 ], 255}; 256