|
1 | | -module.exports = { |
2 | | - parser: '@typescript-eslint/parser', |
3 | | - env: { |
4 | | - browser: true, |
5 | | - node: true, |
6 | | - commonjs: true, |
7 | | - es6: true, |
| 1 | +// Importing necessary ESLint plugins |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests'; |
| 4 | +import headerPlugin from 'eslint-plugin-header'; |
| 5 | +import jsdocPlugin from 'eslint-plugin-jsdoc'; |
| 6 | +import preferArrowPlugin from 'eslint-plugin-prefer-arrow'; |
| 7 | +import importPlugin from 'eslint-plugin-import'; |
| 8 | +import noNullPlugin from 'eslint-plugin-no-null'; |
| 9 | +import localRulesPlugin from 'eslint-plugin-local-rules'; |
| 10 | +import eslintConfigPrettier from 'eslint-config-prettier'; |
| 11 | +import pluginJs from '@eslint/js'; |
| 12 | + |
| 13 | +const commonConfig = { |
| 14 | + plugins: { |
| 15 | + '@typescript-eslint': tseslint.plugin, |
| 16 | + 'no-only-tests': noOnlyTestsPlugin, |
| 17 | + header: headerPlugin, |
| 18 | + jsdoc: jsdocPlugin, |
| 19 | + 'prefer-arrow': preferArrowPlugin, |
| 20 | + import: importPlugin, |
| 21 | + 'no-null': noNullPlugin, |
| 22 | + 'local-rules': localRulesPlugin, |
8 | 23 | }, |
9 | | - globals: { |
10 | | - $: false, |
11 | | - chrome: false, |
12 | | - OpenPGP: false, |
13 | | - }, |
14 | | - extends: ['eslint:recommended', 'plugin:@typescript-eslint/strict', 'plugin:@typescript-eslint/stylistic', 'prettier'], |
15 | | - ignorePatterns: ['.eslintrc.js'], |
16 | | - parserOptions: { |
17 | | - project: 'tsconfig.json', |
18 | | - sourceType: 'module', |
| 24 | + languageOptions: { |
| 25 | + parser: tseslint.parser, |
| 26 | + parserOptions: { |
| 27 | + project: true, |
| 28 | + }, |
19 | 29 | }, |
20 | | - plugins: [ |
21 | | - 'no-only-tests', |
22 | | - 'header', |
23 | | - 'eslint-plugin-jsdoc', |
24 | | - 'eslint-plugin-prefer-arrow', |
25 | | - 'eslint-plugin-import', |
26 | | - 'eslint-plugin-no-null', |
27 | | - 'eslint-plugin-local-rules', |
28 | | - '@typescript-eslint', |
29 | | - ], |
30 | | - root: true, |
31 | 30 | rules: { |
32 | 31 | '@typescript-eslint/consistent-indexed-object-style': 'off', |
33 | 32 | '@typescript-eslint/consistent-type-assertions': 'error', |
@@ -84,6 +83,14 @@ module.exports = { |
84 | 83 | '@typescript-eslint/no-parameter-properties': 'off', |
85 | 84 | '@typescript-eslint/no-shadow': 'off', |
86 | 85 | '@typescript-eslint/no-unsafe-return': 'error', |
| 86 | + '@typescript-eslint/prefer-nullish-coalescing': 'off', |
| 87 | + '@typescript-eslint/no-unnecessary-condition': 'off', |
| 88 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 89 | + '@typescript-eslint/restrict-plus-operands': 'off', |
| 90 | + '@typescript-eslint/require-await': 'off', |
| 91 | + '@typescript-eslint/no-confusing-void-expression': 'off', |
| 92 | + '@typescript-eslint/no-misused-promises': 'off', |
| 93 | + '@typescript-eslint/no-redundant-type-constituents': 'off', |
87 | 94 | '@typescript-eslint/no-unused-vars': ['error'], |
88 | 95 | '@typescript-eslint/no-unused-expressions': 'error', |
89 | 96 | '@typescript-eslint/no-use-before-define': 'off', |
@@ -156,13 +163,60 @@ module.exports = { |
156 | 163 | ], |
157 | 164 | 'local-rules/standard-loops': 'error', |
158 | 165 | }, |
159 | | - overrides: [ |
160 | | - { |
161 | | - files: './test/**/*.ts', |
162 | | - rules: { |
163 | | - '@typescript-eslint/no-unused-expressions': 'off', |
164 | | - '@typescript-eslint/no-non-null-assertion': 'off', |
| 166 | +}; |
| 167 | + |
| 168 | +export default [ |
| 169 | + { |
| 170 | + ignores: ['extension/types/**', 'extension/js/common/core/types/**', 'test/source/core/types/**', 'build/**', 'extension/lib/**', 'eslint.config.js'], |
| 171 | + }, |
| 172 | + pluginJs.configs.recommended, |
| 173 | + ...tseslint.configs.strictTypeChecked, |
| 174 | + ...tseslint.configs.stylisticTypeChecked, |
| 175 | + eslintConfigPrettier, |
| 176 | + { |
| 177 | + ...commonConfig, |
| 178 | + files: ['extension/**/*.ts'], |
| 179 | + languageOptions: { |
| 180 | + ...commonConfig.languageOptions, |
| 181 | + parserOptions: { |
| 182 | + project: './tsconfig.json', |
165 | 183 | }, |
166 | 184 | }, |
167 | | - ], |
168 | | -}; |
| 185 | + }, |
| 186 | + { |
| 187 | + ...commonConfig, |
| 188 | + files: ['tooling/**/*.ts'], |
| 189 | + languageOptions: { |
| 190 | + ...commonConfig.languageOptions, |
| 191 | + parserOptions: { |
| 192 | + project: './conf/tsconfig.tooling.json', |
| 193 | + }, |
| 194 | + }, |
| 195 | + }, |
| 196 | + { |
| 197 | + ...commonConfig, |
| 198 | + files: ['test/**/*.ts'], |
| 199 | + languageOptions: { |
| 200 | + ...commonConfig.languageOptions, |
| 201 | + parserOptions: { |
| 202 | + project: './conf/tsconfig.test.eslint.json', |
| 203 | + }, |
| 204 | + }, |
| 205 | + rules: { |
| 206 | + ...commonConfig.rules, |
| 207 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 208 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 209 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 210 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 211 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 212 | + }, |
| 213 | + }, |
| 214 | + ...tseslint.config({ |
| 215 | + files: ['extension/js/content_scripts/webmail/**/*.ts'], |
| 216 | + languageOptions: { |
| 217 | + parserOptions: { |
| 218 | + project: './conf/tsconfig.content_scripts.json', |
| 219 | + }, |
| 220 | + }, |
| 221 | + }), |
| 222 | +]; |
0 commit comments