|
| 1 | +import path from "node:path" |
| 2 | +import { fileURLToPath } from "node:url" |
| 3 | +import { FlatCompat } from "@eslint/eslintrc" |
| 4 | +import js from "@eslint/js" |
| 5 | +import typescriptEslint from "@typescript-eslint/eslint-plugin" |
| 6 | +import unicorn from "eslint-plugin-unicorn" |
| 7 | + |
| 8 | +const __filename = fileURLToPath(import.meta.url) |
| 9 | +const __dirname = path.dirname(__filename) |
| 10 | +const compat = new FlatCompat({ |
| 11 | + baseDirectory: __dirname, |
| 12 | + recommendedConfig: js.configs.recommended, |
| 13 | + allConfig: js.configs.all, |
| 14 | +}) |
| 15 | + |
| 16 | +export default [ |
| 17 | + { |
| 18 | + ignores: ["**/*.config.*", "**/examples", "**/dist"], |
| 19 | + }, |
| 20 | + ...compat.extends( |
| 21 | + "eslint:recommended", |
| 22 | + "plugin:unicorn/recommended", |
| 23 | + "plugin:@typescript-eslint/recommended" |
| 24 | + ), |
| 25 | + { |
| 26 | + plugins: { |
| 27 | + "@typescript-eslint": typescriptEslint, |
| 28 | + unicorn, |
| 29 | + }, |
| 30 | + |
| 31 | + languageOptions: { |
| 32 | + globals: {}, |
| 33 | + ecmaVersion: 5, |
| 34 | + sourceType: "script", |
| 35 | + |
| 36 | + parserOptions: { |
| 37 | + project: "./tsconfig.json", |
| 38 | + }, |
| 39 | + }, |
| 40 | + |
| 41 | + rules: { |
| 42 | + "no-console": [ |
| 43 | + "error", |
| 44 | + { |
| 45 | + allow: ["warn", "error"], |
| 46 | + }, |
| 47 | + ], |
| 48 | + |
| 49 | + "@typescript-eslint/no-magic-numbers": "off", |
| 50 | + "@typescript-eslint/unbound-method": "off", |
| 51 | + "@typescript-eslint/prefer-as-const": "error", |
| 52 | + "@typescript-eslint/consistent-type-imports": "error", |
| 53 | + "@typescript-eslint/no-explicit-any": "off", |
| 54 | + "@typescript-eslint/restrict-template-expressions": "off", |
| 55 | + |
| 56 | + "@typescript-eslint/no-unused-vars": [ |
| 57 | + "error", |
| 58 | + { |
| 59 | + varsIgnorePattern: "^_", |
| 60 | + argsIgnorePattern: "^_", |
| 61 | + }, |
| 62 | + ], |
| 63 | + |
| 64 | + "@typescript-eslint/prefer-ts-expect-error": "off", |
| 65 | + |
| 66 | + "@typescript-eslint/no-misused-promises": [ |
| 67 | + "error", |
| 68 | + { |
| 69 | + checksVoidReturn: false, |
| 70 | + }, |
| 71 | + ], |
| 72 | + |
| 73 | + "unicorn/prevent-abbreviations": "off", |
| 74 | + |
| 75 | + "no-implicit-coercion": [ |
| 76 | + "error", |
| 77 | + { |
| 78 | + boolean: true, |
| 79 | + }, |
| 80 | + ], |
| 81 | + |
| 82 | + "no-extra-boolean-cast": [ |
| 83 | + "error", |
| 84 | + { |
| 85 | + enforceForLogicalOperands: true, |
| 86 | + }, |
| 87 | + ], |
| 88 | + |
| 89 | + "no-unneeded-ternary": [ |
| 90 | + "error", |
| 91 | + { |
| 92 | + defaultAssignment: true, |
| 93 | + }, |
| 94 | + ], |
| 95 | + |
| 96 | + "unicorn/no-array-reduce": ["off"], |
| 97 | + "unicorn/no-nested-ternary": "off", |
| 98 | + "unicorn/no-null": "off", |
| 99 | + "unicorn/filename-case": "off", |
| 100 | + }, |
| 101 | + }, |
| 102 | +] |
0 commit comments