|
1 | 1 | import eslint from '@eslint/js' |
2 | | -import tseslint from '@typescript-eslint/eslint-plugin' |
3 | | -import tsparser from '@typescript-eslint/parser' |
| 2 | +import tseslint from 'typescript-eslint' |
4 | 3 | import jestPlugin from 'eslint-plugin-jest' |
5 | 4 | import githubPlugin from 'eslint-plugin-github' |
6 | 5 | import prettierPlugin from 'eslint-plugin-prettier' |
7 | 6 | import importPlugin from 'eslint-plugin-import' |
| 7 | +import globals from 'globals' |
8 | 8 |
|
9 | 9 | export default [ |
10 | 10 | // Global ignores |
11 | 11 | { |
12 | 12 | ignores: ['**/node_modules/**', '**/dist/**', '**/coverage/**', '**/*.json'] |
13 | 13 | }, |
14 | 14 |
|
15 | | - // Base configuration for all files |
| 15 | + // Base ESLint recommended config for all files |
16 | 16 | eslint.configs.recommended, |
17 | 17 |
|
18 | 18 | // TypeScript files configuration |
19 | 19 | { |
20 | 20 | files: ['**/*.ts'], |
21 | 21 | languageOptions: { |
22 | | - parser: tsparser, |
| 22 | + parser: tseslint.parser, |
23 | 23 | parserOptions: { |
24 | 24 | ecmaVersion: 2023, |
25 | 25 | sourceType: 'module', |
26 | | - project: ['./.github/linters/tsconfig.json', './tsconfig.json'] |
| 26 | + project: ['./.github/linters/tsconfig.json', './tsconfig.json'], |
| 27 | + tsconfigRootDir: import.meta.dirname |
27 | 28 | }, |
28 | 29 | globals: { |
29 | | - Atomics: 'readonly', |
30 | | - SharedArrayBuffer: 'readonly', |
31 | | - console: 'readonly', |
32 | | - process: 'readonly', |
33 | | - __dirname: 'readonly', |
34 | | - __filename: 'readonly', |
35 | | - module: 'readonly', |
36 | | - require: 'readonly', |
37 | | - exports: 'readonly', |
38 | | - Buffer: 'readonly', |
39 | | - global: 'readonly' |
| 30 | + ...globals.node, |
| 31 | + ...globals.es2021, |
| 32 | + ...globals.jest |
40 | 33 | } |
41 | 34 | }, |
42 | 35 | plugins: { |
43 | | - '@typescript-eslint': tseslint, |
| 36 | + '@typescript-eslint': tseslint.plugin, |
44 | 37 | jest: jestPlugin, |
45 | 38 | github: githubPlugin, |
46 | 39 | prettier: prettierPlugin |
47 | 40 | }, |
48 | 41 | rules: { |
49 | | - // Spread recommended rules from plugins |
50 | | - ...tseslint.configs['eslint-recommended'].overrides[0].rules, |
51 | | - ...tseslint.configs.recommended.rules, |
| 42 | + // TypeScript recommended rules |
| 43 | + ...tseslint.configs.recommended[0].rules, |
| 44 | + ...tseslint.configs.stylistic[0].rules, |
| 45 | + |
| 46 | + // Jest recommended rules |
52 | 47 | ...jestPlugin.configs.recommended.rules, |
53 | 48 |
|
54 | | - // Custom rules |
| 49 | + // Prettier integration |
| 50 | + 'prettier/prettier': 'error', |
| 51 | + |
| 52 | + // Custom overrides |
55 | 53 | camelcase: 'off', |
56 | 54 | 'no-console': 'off', |
57 | 55 | 'no-unused-vars': 'off', |
58 | | - 'prettier/prettier': 'error', |
59 | 56 | semi: ['error', 'never'], |
| 57 | + |
| 58 | + // TypeScript-specific custom rules |
60 | 59 | '@typescript-eslint/array-type': 'error', |
61 | 60 | '@typescript-eslint/await-thenable': 'error', |
62 | 61 | '@typescript-eslint/ban-ts-comment': 'error', |
@@ -99,22 +98,13 @@ export default [ |
99 | 98 |
|
100 | 99 | // JavaScript files configuration |
101 | 100 | { |
102 | | - files: ['**/*.js'], |
| 101 | + files: ['**/*.js', '**/*.mjs'], |
103 | 102 | languageOptions: { |
104 | 103 | ecmaVersion: 2023, |
105 | 104 | sourceType: 'module', |
106 | 105 | globals: { |
107 | | - Atomics: 'readonly', |
108 | | - SharedArrayBuffer: 'readonly', |
109 | | - console: 'readonly', |
110 | | - process: 'readonly', |
111 | | - __dirname: 'readonly', |
112 | | - __filename: 'readonly', |
113 | | - module: 'readonly', |
114 | | - require: 'readonly', |
115 | | - exports: 'readonly', |
116 | | - Buffer: 'readonly', |
117 | | - global: 'readonly' |
| 106 | + ...globals.node, |
| 107 | + ...globals.es2021 |
118 | 108 | } |
119 | 109 | }, |
120 | 110 | plugins: { |
|
0 commit comments