|
| 1 | +const { |
| 2 | + defineConfig, |
| 3 | +} = require("eslint/config"); |
| 4 | + |
| 5 | +const globals = require("globals"); |
| 6 | +const tsParser = require("@typescript-eslint/parser"); |
| 7 | +const react = require("eslint-plugin-react"); |
| 8 | +const reactHooks = require("eslint-plugin-react-hooks"); |
| 9 | +const typescriptEslint = require("@typescript-eslint/eslint-plugin"); |
| 10 | +const prettier = require("eslint-plugin-prettier"); |
| 11 | + |
| 12 | +const { |
| 13 | + fixupPluginRules, |
| 14 | +} = require("@eslint/compat"); |
| 15 | + |
| 16 | +const js = require("@eslint/js"); |
| 17 | + |
| 18 | +const { |
| 19 | + FlatCompat, |
| 20 | +} = require("@eslint/eslintrc"); |
| 21 | + |
| 22 | +const compat = new FlatCompat({ |
| 23 | + baseDirectory: __dirname, |
| 24 | + recommendedConfig: js.configs.recommended, |
| 25 | + allConfig: js.configs.all |
| 26 | +}); |
| 27 | + |
| 28 | +module.exports = defineConfig([{ |
| 29 | + languageOptions: { |
| 30 | + globals: { |
| 31 | + ...globals.browser, |
| 32 | + }, |
| 33 | + |
| 34 | + parser: tsParser, |
| 35 | + ecmaVersion: 11, |
| 36 | + sourceType: "module", |
| 37 | + |
| 38 | + parserOptions: { |
| 39 | + ecmaFeatures: { |
| 40 | + jsx: true, |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + |
| 45 | + extends: compat.extends( |
| 46 | + "plugin:react/recommended", |
| 47 | + "airbnb", |
| 48 | + "plugin:@typescript-eslint/recommended", |
| 49 | + "prettier/@typescript-eslint", |
| 50 | + "plugin:prettier/recommended", |
| 51 | + ), |
| 52 | + |
| 53 | + plugins: { |
| 54 | + react, |
| 55 | + "react-hooks": fixupPluginRules(reactHooks), |
| 56 | + "@typescript-eslint": typescriptEslint, |
| 57 | + prettier, |
| 58 | + }, |
| 59 | + |
| 60 | + rules: { |
| 61 | + "prettier/prettier": "error", |
| 62 | + "react-hooks/rules-of-hooks": "error", |
| 63 | + "react-hooks/exhaustive-deps": "warn", |
| 64 | + |
| 65 | + "react/jsx-filename-extension": [1, { |
| 66 | + extensions: [".tsx"], |
| 67 | + }], |
| 68 | + |
| 69 | + "import/prefer-default-export": "off", |
| 70 | + "react/jsx-one-expression-per-line": "off", |
| 71 | + "react/jsx-props-no-spreading": "off", |
| 72 | + "no-unused-expressions": "off", |
| 73 | + "react/prop-types": "off", |
| 74 | + |
| 75 | + "@typescript-eslint/explicit-function-return-type": ["error", { |
| 76 | + allowExpressions: true, |
| 77 | + }], |
| 78 | + |
| 79 | + "import/extensions": ["error", "ignorePackages", { |
| 80 | + ts: "never", |
| 81 | + tsx: "never", |
| 82 | + }], |
| 83 | + }, |
| 84 | + |
| 85 | + settings: { |
| 86 | + "import/resolver": { |
| 87 | + typescript: {}, |
| 88 | + }, |
| 89 | + }, |
| 90 | +}]); |
0 commit comments