|
| 1 | +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; |
| 2 | +import react from "eslint-plugin-react"; |
| 3 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 4 | +import security from "eslint-plugin-security"; |
| 5 | +import _import from "eslint-plugin-import"; |
| 6 | +import globals from "globals"; |
| 7 | +// eslint-disable-next-line import/no-unresolved |
| 8 | +import tsParser from "@typescript-eslint/parser"; |
| 9 | +import path from "node:path"; |
| 10 | +import { fileURLToPath } from "node:url"; |
| 11 | +import js from "@eslint/js"; |
| 12 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 13 | + |
| 14 | +const __filename = fileURLToPath(import.meta.url); |
| 15 | +const __dirname = path.dirname(__filename); |
| 16 | +const compat = new FlatCompat({ |
| 17 | + baseDirectory: __dirname, |
| 18 | + recommendedConfig: js.configs.recommended, |
| 19 | + allConfig: js.configs.all, |
| 20 | +}); |
| 21 | + |
| 22 | +export default [ |
| 23 | + { |
| 24 | + ignores: ["src/assets"], |
| 25 | + }, |
| 26 | + ...fixupConfigRules( |
| 27 | + compat.extends( |
| 28 | + "eslint:recommended", |
| 29 | + "plugin:react/recommended", |
| 30 | + "plugin:react-hooks/recommended", |
| 31 | + "plugin:import/recommended", |
| 32 | + "plugin:import/react", |
| 33 | + "plugin:@typescript-eslint/recommended", |
| 34 | + "plugin:prettier/recommended", |
| 35 | + "prettier", |
| 36 | + "plugin:security/recommended-legacy", |
| 37 | + ), |
| 38 | + ), |
| 39 | + { |
| 40 | + plugins: { |
| 41 | + react: fixupPluginRules(react), |
| 42 | + "react-hooks": fixupPluginRules(reactHooks), |
| 43 | + security: fixupPluginRules(security), |
| 44 | + import: fixupPluginRules(_import), |
| 45 | + }, |
| 46 | + |
| 47 | + languageOptions: { |
| 48 | + globals: { |
| 49 | + ...globals.browser, |
| 50 | + ...globals.node, |
| 51 | + Atomics: "readonly", |
| 52 | + SharedArrayBuffer: "readonly", |
| 53 | + }, |
| 54 | + |
| 55 | + parser: tsParser, |
| 56 | + ecmaVersion: 2020, |
| 57 | + sourceType: "module", |
| 58 | + |
| 59 | + parserOptions: { |
| 60 | + ecmaFeatures: { |
| 61 | + jsx: true, |
| 62 | + }, |
| 63 | + }, |
| 64 | + }, |
| 65 | + |
| 66 | + settings: { |
| 67 | + react: { |
| 68 | + version: "^16.12.0", |
| 69 | + }, |
| 70 | + |
| 71 | + "import/resolver": { |
| 72 | + parcel: { |
| 73 | + rootDir: "src", |
| 74 | + extensions: [".js", ".jsx", ".ts", ".tsx", ".svg", ".png", ".jpeg"], |
| 75 | + }, |
| 76 | + }, |
| 77 | + }, |
| 78 | + |
| 79 | + rules: { |
| 80 | + "max-len": [ |
| 81 | + "warn", |
| 82 | + { |
| 83 | + code: 80, |
| 84 | + }, |
| 85 | + ], |
| 86 | + |
| 87 | + "react/prop-types": 0, |
| 88 | + "no-unused-vars": "off", |
| 89 | + |
| 90 | + "@typescript-eslint/no-unused-vars": [ |
| 91 | + "error", |
| 92 | + { |
| 93 | + varsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)", |
| 94 | + argsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)", |
| 95 | + }, |
| 96 | + ], |
| 97 | + |
| 98 | + "no-console": [ |
| 99 | + "error", |
| 100 | + { |
| 101 | + allow: ["warn", "error", "info", "debug"], |
| 102 | + }, |
| 103 | + ], |
| 104 | + |
| 105 | + "@typescript-eslint/no-explicit-any": ["off"], |
| 106 | + "security/detect-object-injection": "off", |
| 107 | + "security/detect-non-literal-fs-filename": "off", |
| 108 | + |
| 109 | + "import/extensions": [ |
| 110 | + "error", |
| 111 | + "ignorePackages", |
| 112 | + { |
| 113 | + js: "never", |
| 114 | + jsx: "never", |
| 115 | + ts: "never", |
| 116 | + tsx: "never", |
| 117 | + }, |
| 118 | + ], |
| 119 | + }, |
| 120 | + }, |
| 121 | +]; |
0 commit comments