|
| 1 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 2 | +import prettier from "eslint-plugin-prettier"; |
| 3 | +import simpleImportSort from "eslint-plugin-simple-import-sort"; |
| 4 | +import globals from "globals"; |
| 5 | +import tsParser from "@typescript-eslint/parser"; |
| 6 | +import path from "node:path"; |
| 7 | +import { fileURLToPath } from "node:url"; |
| 8 | +import js from "@eslint/js"; |
| 9 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: __dirname, |
| 15 | + recommendedConfig: js.configs.recommended, |
| 16 | + allConfig: js.configs.all |
| 17 | +}); |
| 18 | +export default [...compat.extends( |
| 19 | + "eslint:recommended", |
| 20 | + "plugin:@typescript-eslint/recommended", |
| 21 | +).map(config => ({files: ["**/*.ts"], ...config})), { |
| 22 | + plugins: { |
| 23 | + "@typescript-eslint": typescriptEslint, |
| 24 | + prettier, |
| 25 | + "simple-import-sort": simpleImportSort, |
| 26 | + }, |
| 27 | + |
| 28 | + languageOptions: { |
| 29 | + globals: { |
| 30 | + ...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])), |
| 31 | + self: true, |
| 32 | + }, |
| 33 | + |
| 34 | + parser: tsParser, |
| 35 | + }, |
| 36 | + |
| 37 | + settings: { |
| 38 | + "import/resolver": { |
| 39 | + node: { |
| 40 | + extensions: [".js", ".json", ".ts"], |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + |
| 45 | + rules: { |
| 46 | + "no-console": 0, |
| 47 | + |
| 48 | + "max-len": ["error", { |
| 49 | + code: 140, |
| 50 | + ignoreUrls: true, |
| 51 | + }], |
| 52 | + |
| 53 | + "prefer-template": "off", |
| 54 | + "arrow-body-style": "off", |
| 55 | + "padded-blocks": "off", |
| 56 | + "class-methods-use-this": "off", |
| 57 | + "no-else-return": "off", |
| 58 | + "lines-between-class-members": "off", |
| 59 | + "no-param-reassign": "off", |
| 60 | + "no-return-assign": "off", |
| 61 | + "no-plusplus": "off", |
| 62 | + "prefer-destructuring": "off", |
| 63 | + "sort-imports": "off", |
| 64 | + "simple-import-sort/imports": "warn", |
| 65 | + "no-restricted-globals": "off", |
| 66 | + |
| 67 | + "@typescript-eslint/explicit-function-return-type": ["warn", { |
| 68 | + allowExpressions: true, |
| 69 | + }], |
| 70 | + |
| 71 | + "@typescript-eslint/interface-name-prefix": "off", |
| 72 | + "@typescript-eslint/explicit-member-accessibility": "error", |
| 73 | + |
| 74 | + "@typescript-eslint/no-inferrable-types": ["error", { |
| 75 | + ignoreParameters: true, |
| 76 | + ignoreProperties: true, |
| 77 | + }], |
| 78 | + |
| 79 | + "@typescript-eslint/no-explicit-any": ["warn", { |
| 80 | + fixToUnknown: true, |
| 81 | + }], |
| 82 | + |
| 83 | + "@typescript-eslint/no-unused-vars": ["warn", { |
| 84 | + argsIgnorePattern: "^_", |
| 85 | + }], |
| 86 | + |
| 87 | + "prettier/prettier": "warn", |
| 88 | + }, |
| 89 | +}, { |
| 90 | + files: ["**/*.test.ts"], |
| 91 | + |
| 92 | + languageOptions: { |
| 93 | + globals: { |
| 94 | + window: true, |
| 95 | + }, |
| 96 | + }, |
| 97 | + |
| 98 | + rules: { |
| 99 | + "import/first": 0, |
| 100 | + "@typescript-eslint/no-explicit-any": "off", |
| 101 | + "@typescript-eslint/no-unused-vars": "off", |
| 102 | + }, |
| 103 | +}]; |
0 commit comments