|
| 1 | +import path from "node:path" |
| 2 | +import tseslint from "typescript-eslint" |
| 3 | +import url from "node:url" |
| 4 | +import unusedImports from "eslint-plugin-unused-imports" |
| 5 | +import unicornPlugin from "eslint-plugin-unicorn" |
| 6 | + |
| 7 | +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) |
| 8 | + |
| 9 | +export default tseslint.config( |
| 10 | + // register plugins |
| 11 | + { |
| 12 | + plugins: { |
| 13 | + ["@typescript-eslint"]: tseslint.plugin, |
| 14 | + ["@unused-imports"]: unusedImports, |
| 15 | + }, |
| 16 | + }, |
| 17 | + |
| 18 | + // add files and folders to be ignored |
| 19 | + { |
| 20 | + ignores: ["**/*.js", "eslint.config.mjs", ".github/*", ".yarn/*", "src/utils.ts", "dist/*"], |
| 21 | + }, |
| 22 | + |
| 23 | + tseslint.configs.all, |
| 24 | + unicornPlugin.configs["flat/all"], |
| 25 | + |
| 26 | + { |
| 27 | + languageOptions: { |
| 28 | + parserOptions: { |
| 29 | + projectService: true, |
| 30 | + tsconfigRootDir: __dirname, |
| 31 | + }, |
| 32 | + }, |
| 33 | + |
| 34 | + rules: { |
| 35 | + // override typescript-eslint |
| 36 | + "@typescript-eslint/no-empty-function": "off", |
| 37 | + "@typescript-eslint/no-inferrable-types": "off", |
| 38 | + "@typescript-eslint/typedef": [ |
| 39 | + "error", |
| 40 | + {parameter: true, memberVariableDeclaration: true}, |
| 41 | + ], |
| 42 | + "@typescript-eslint/consistent-generic-constructors": ["error", "type-annotation"], |
| 43 | + "@typescript-eslint/no-unused-vars": [ |
| 44 | + "error", |
| 45 | + { |
| 46 | + argsIgnorePattern: "^_", |
| 47 | + caughtErrorsIgnorePattern: "^_", |
| 48 | + varsIgnorePattern: "^_", |
| 49 | + }, |
| 50 | + ], |
| 51 | + "@typescript-eslint/prefer-optional-chain": "off", |
| 52 | + "@typescript-eslint/no-extraneous-class": "off", |
| 53 | + "@typescript-eslint/no-magic-numbers": "off", |
| 54 | + "@typescript-eslint/no-unsafe-type-assertion": "off", |
| 55 | + "@typescript-eslint/prefer-readonly-parameter-types": "off", |
| 56 | + "@typescript-eslint/member-ordering": "off", |
| 57 | + "@typescript-eslint/parameter-properties": "off", |
| 58 | + "@typescript-eslint/method-signature-style": "off", |
| 59 | + "@typescript-eslint/prefer-destructuring": "off", |
| 60 | + "@typescript-eslint/no-use-before-define": "off", |
| 61 | + "@typescript-eslint/class-methods-use-this": "off", |
| 62 | + "@typescript-eslint/no-shadow": "off", |
| 63 | + "@typescript-eslint/consistent-type-imports": "off", |
| 64 | + "@typescript-eslint/naming-convention": "off", |
| 65 | + "@typescript-eslint/max-params": "off", |
| 66 | + "@typescript-eslint/no-invalid-this": "off", |
| 67 | + "@typescript-eslint/init-declarations": "off", |
| 68 | + "@typescript-eslint/dot-notation": "off", |
| 69 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 70 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 71 | + |
| 72 | + "@unused-imports/no-unused-imports": "error", |
| 73 | + "no-duplicate-imports": "error", |
| 74 | + "@typescript-eslint/strict-boolean-expressions": "error", |
| 75 | + |
| 76 | + // override unicorn |
| 77 | + "unicorn/no-null": "off", |
| 78 | + "unicorn/prevent-abbreviations": "off", |
| 79 | + "unicorn/no-array-for-each": "off", |
| 80 | + "unicorn/import-style": "off", |
| 81 | + "unicorn/filename-case": "off", |
| 82 | + "unicorn/consistent-function-scoping": "off", |
| 83 | + "unicorn/no-nested-ternary": "off", |
| 84 | + "unicorn/prefer-module": "off", |
| 85 | + "unicorn/prefer-string-replace-all": "off", |
| 86 | + "unicorn/no-process-exit": "off", |
| 87 | + "unicorn/number-literal-case": "off", // prettier changes to lowercase |
| 88 | + "unicorn/no-lonely-if": "off", |
| 89 | + "unicorn/prefer-top-level-await": "off", |
| 90 | + "unicorn/no-static-only-class": "off", |
| 91 | + "unicorn/no-keyword-prefix": "off", |
| 92 | + "unicorn/prefer-json-parse-buffer": "off", |
| 93 | + "unicorn/no-array-reduce": "off", |
| 94 | + "unicorn/no-useless-undefined": "off", |
| 95 | + "unicorn/prefer-type-error": "off", |
| 96 | + |
| 97 | + "@/eqeqeq": "error", |
| 98 | + }, |
| 99 | + }, |
| 100 | +) |
0 commit comments