|
1 | 1 | // eslint.config.js
|
2 |
| -import eslint from "@eslint/js"; |
3 |
| -import tseslint from "typescript-eslint"; |
4 |
| -import eslintConfigPrettier from "eslint-config-prettier"; |
| 2 | +import js from "@eslint/js"; |
| 3 | +import ts from "typescript-eslint"; |
| 4 | +import prettierRecommended from "eslint-plugin-prettier/recommended"; |
5 | 5 | import importPlugin from "eslint-plugin-import";
|
6 | 6 | import unusedImports from "eslint-plugin-unused-imports";
|
| 7 | +import pluginPromise from "eslint-plugin-promise"; |
7 | 8 |
|
8 |
| -export default [ |
| 9 | +export default ts.config( |
| 10 | + js.configs.recommended, |
| 11 | + ts.configs.recommendedTypeChecked, |
| 12 | + prettierRecommended, |
| 13 | + importPlugin.flatConfigs.recommended, |
| 14 | + pluginPromise.configs["flat/recommended"], |
9 | 15 | {
|
10 |
| - ignores: ["**/dist/**", "**/node_modules/**", "**/coverage/**"], |
11 |
| - }, |
12 |
| - ...tseslint.config( |
13 |
| - eslint.configs.recommended, |
14 |
| - ...tseslint.configs.recommended, |
15 |
| - eslintConfigPrettier, |
16 |
| - { |
17 |
| - files: ["src/**/*.{js,ts}", "tests/**/*.{js,ts}", "bin/**/*.{js,ts}"], |
18 |
| - plugins: { |
19 |
| - import: importPlugin, |
20 |
| - "unused-imports": unusedImports, |
| 16 | + languageOptions: { |
| 17 | + ecmaVersion: 2022, |
| 18 | + sourceType: "module", |
| 19 | + parserOptions: { |
| 20 | + project: ["./tsconfig.eslint.json"], |
| 21 | + tsconfigRootDir: import.meta.dirname, |
21 | 22 | },
|
22 |
| - languageOptions: { |
23 |
| - ecmaVersion: 2022, |
24 |
| - sourceType: "module", |
25 |
| - parser: tseslint.parser, |
26 |
| - }, |
27 |
| - rules: { |
28 |
| - // Basic TypeScript rules |
29 |
| - "@typescript-eslint/no-unused-vars": [ |
30 |
| - "warn", |
31 |
| - { |
32 |
| - ignoreRestSiblings: true, |
33 |
| - argsIgnorePattern: "^_", |
34 |
| - varsIgnorePattern: "^_", |
35 |
| - caughtErrorsIgnorePattern: "^_", |
36 |
| - }, |
37 |
| - ], |
38 |
| - "unused-imports/no-unused-imports": "error", |
39 |
| - "@typescript-eslint/no-explicit-any": "off", |
40 |
| - "@typescript-eslint/explicit-function-return-type": "off", |
41 |
| - "@typescript-eslint/no-floating-promises": "off", |
42 |
| - |
43 |
| - // Basic code quality rules |
44 |
| - "no-console": "off", |
45 |
| - "prefer-const": "warn", |
46 |
| - "no-var": "warn", |
47 |
| - eqeqeq: ["warn", "always"], |
| 23 | + }, |
| 24 | + plugins: { |
| 25 | + "unused-imports": unusedImports, |
| 26 | + }, |
| 27 | + files: ["{src,test}/**/*.{js,ts}"], |
| 28 | + rules: { |
| 29 | + // Basic code quality rules |
| 30 | + "no-console": "off", |
| 31 | + "prefer-const": "warn", |
| 32 | + "no-var": "warn", |
| 33 | + eqeqeq: ["warn", "always"], |
48 | 34 |
|
49 |
| - // Light complexity rules |
50 |
| - complexity: ["warn", { max: 20 }], |
51 |
| - "max-depth": ["warn", { max: 4 }], |
52 |
| - "max-lines-per-function": ["warn", { max: 150 }], |
| 35 | + // Light complexity rules |
| 36 | + complexity: ["warn", { max: 20 }], |
| 37 | + "max-depth": ["warn", { max: 4 }], |
| 38 | + "max-lines-per-function": ["warn", { max: 150 }], |
53 | 39 |
|
54 |
| - // Error prevention |
55 |
| - "import/no-duplicates": "error", |
56 |
| - "no-template-curly-in-string": "warn", |
| 40 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 41 | + "@typescript-eslint/no-explicit-any": "off", |
| 42 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 43 | + "@typescript-eslint/no-unsafe-call": "off", |
| 44 | + "@typescript-eslint/no-unsafe-return": "off", |
| 45 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 46 | + "@typescript-eslint/no-explicit-any": "off", |
| 47 | + "@typescript-eslint/no-unused-vars": [ |
| 48 | + "error", |
| 49 | + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, |
| 50 | + ], |
57 | 51 |
|
58 |
| - // Format and whitespace |
59 |
| - "max-len": [ |
60 |
| - "warn", |
61 |
| - { |
62 |
| - code: 120, |
63 |
| - ignoreComments: true, |
64 |
| - ignoreStrings: true, |
65 |
| - ignoreTemplateLiterals: true, |
66 |
| - }, |
67 |
| - ], |
| 52 | + "import/no-unresolved": "off", |
| 53 | + "import/named": "off", |
| 54 | + "import/extensions": [ |
| 55 | + "error", |
| 56 | + "ignorePackages", |
| 57 | + { js: "always", ts: "never" }, |
| 58 | + ], |
68 | 59 |
|
69 |
| - // Import rules |
70 |
| - "import/extensions": ["off"], |
71 |
| - "import/no-unresolved": "off", |
| 60 | + "no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off", |
| 61 | + "unused-imports/no-unused-imports": "error", |
72 | 62 |
|
73 |
| - // Disable specific TypeScript rules that require type information |
74 |
| - "@typescript-eslint/no-unsafe-assignment": "off", |
75 |
| - "@typescript-eslint/no-unsafe-member-access": "off", |
76 |
| - "@typescript-eslint/no-unsafe-call": "off", |
77 |
| - "@typescript-eslint/no-unsafe-return": "off", |
78 |
| - }, |
79 |
| - } |
80 |
| - ), |
81 |
| -]; |
| 63 | + "promise/always-return": "error", |
| 64 | + "promise/no-return-wrap": "error", |
| 65 | + "promise/param-names": "error", |
| 66 | + "promise/catch-or-return": "error", |
| 67 | + "promise/no-native": "off", |
| 68 | + "promise/no-nesting": "warn", |
| 69 | + "promise/no-promise-in-callback": "warn", |
| 70 | + "promise/no-callback-in-promise": "warn", |
| 71 | + "promise/avoid-new": "off", |
| 72 | + "promise/no-new-statics": "error", |
| 73 | + "promise/no-return-in-finally": "warn", |
| 74 | + "promise/valid-params": "warn", |
| 75 | + "promise/no-multiple-resolved": "error", |
| 76 | + }, |
| 77 | + } |
| 78 | +); |
0 commit comments