|
| 1 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 2 | +import _import from "eslint-plugin-import"; |
| 3 | +import onlyWarn from "eslint-plugin-only-warn"; |
| 4 | +import prettier from "eslint-plugin-prettier"; |
| 5 | +import react from "eslint-plugin-react"; |
| 6 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 7 | +import globals from "globals"; |
| 8 | +import tsParser from "@typescript-eslint/parser"; |
| 9 | +import path from "node:path"; |
| 10 | +import js from "@eslint/js"; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all |
| 18 | +}); |
| 19 | + |
| 20 | +export default [{ |
| 21 | + ignores: ["**/*.css", "ui-icons/src/"], |
| 22 | +}, ...fixupConfigRules(compat.extends( |
| 23 | + "eslint:recommended", |
| 24 | + "prettier", |
| 25 | + "plugin:@typescript-eslint/recommended", |
| 26 | + "plugin:@typescript-eslint/eslint-recommended", |
| 27 | + "plugin:prettier/recommended", |
| 28 | + "plugin:react/recommended", |
| 29 | + "plugin:react-hooks/recommended", |
| 30 | + "plugin:storybook/recommended", |
| 31 | + "plugin:import/recommended", |
| 32 | + "plugin:import/typescript", |
| 33 | +)), { |
| 34 | + plugins: { |
| 35 | + "@typescript-eslint": fixupPluginRules(typescriptEslint), |
| 36 | + import: fixupPluginRules(_import), |
| 37 | + "only-warn": onlyWarn, |
| 38 | + prettier: fixupPluginRules(prettier), |
| 39 | + react: fixupPluginRules(react), |
| 40 | + "react-hooks": fixupPluginRules(reactHooks), |
| 41 | + }, |
| 42 | + |
| 43 | + languageOptions: { |
| 44 | + globals: { |
| 45 | + ...globals.browser, |
| 46 | + }, |
| 47 | + |
| 48 | + parser: tsParser, |
| 49 | + }, |
| 50 | + |
| 51 | + settings: { |
| 52 | + react: { |
| 53 | + version: "detect", |
| 54 | + }, |
| 55 | + }, |
| 56 | + |
| 57 | + rules: { |
| 58 | + "import/order": ["error", { |
| 59 | + groups: ["builtin", "external", "internal"], |
| 60 | + |
| 61 | + pathGroups: [{ |
| 62 | + pattern: "react", |
| 63 | + group: "builtin", |
| 64 | + position: "before", |
| 65 | + }], |
| 66 | + |
| 67 | + pathGroupsExcludedImportTypes: ["react"], |
| 68 | + "newlines-between": "always", |
| 69 | + |
| 70 | + alphabetize: { |
| 71 | + order: "asc", |
| 72 | + caseInsensitive: true, |
| 73 | + }, |
| 74 | + }], |
| 75 | + |
| 76 | + "no-shadow": "off", |
| 77 | + |
| 78 | + "@typescript-eslint/consistent-type-imports": ["error", { |
| 79 | + fixStyle: "inline-type-imports", |
| 80 | + }], |
| 81 | + |
| 82 | + "@typescript-eslint/no-shadow": "error", |
| 83 | + "@typescript-eslint/no-use-before-define": "error", |
| 84 | + "@typescript-eslint/no-explicit-any": 2, |
| 85 | + "@typescript-eslint/explicit-module-boundary-types": 0, |
| 86 | + "@typescript-eslint/space-before-blocks": 0, |
| 87 | + |
| 88 | + "@typescript-eslint/no-restricted-types": ["error", { |
| 89 | + types: { |
| 90 | + LegacyFilterSpecification: { |
| 91 | + message: "Use ExpressionFilterSpecification instead", |
| 92 | + fixWith: "ExpressionFilterSpecification", |
| 93 | + }, |
| 94 | + |
| 95 | + FC: "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177", |
| 96 | + "React.FC": "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177", |
| 97 | + "React.FunctionComponent": "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177", |
| 98 | + "React.FunctionalComponent": "Preact specific, useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177", |
| 99 | + }, |
| 100 | + }], |
| 101 | + |
| 102 | + "@typescript-eslint/no-unused-vars": ["warn", { |
| 103 | + argsIgnorePattern: "^_", |
| 104 | + }], |
| 105 | + |
| 106 | + camelcase: 0, |
| 107 | + "no-nonoctal-decimal-escape": 0, |
| 108 | + "no-unsafe-optional-chaining": 0, |
| 109 | + "object-curly-newline": 0, |
| 110 | + "react/function-component-definition": 0, |
| 111 | + "react/no-array-index-key": 0, |
| 112 | + "react/require-default-props": 0, |
| 113 | + "arrow-body-style": ["error", "as-needed"], |
| 114 | + "global-require": "off", |
| 115 | + |
| 116 | + "import/extensions": ["error", "ignorePackages", { |
| 117 | + js: "never", |
| 118 | + jsx: "never", |
| 119 | + ts: "never", |
| 120 | + tsx: "never", |
| 121 | + }], |
| 122 | + |
| 123 | + "import/no-extraneous-dependencies": 0, |
| 124 | + |
| 125 | + "import/no-unresolved": [2, { |
| 126 | + commonjs: true, |
| 127 | + amd: true, |
| 128 | + }], |
| 129 | + |
| 130 | + "jsx-a11y/click-events-have-key-events": "off", |
| 131 | + "linebreak-style": ["error", "unix"], |
| 132 | + |
| 133 | + "no-console": ["error", { |
| 134 | + allow: ["info", "debug", "warn", "error"], |
| 135 | + }], |
| 136 | + |
| 137 | + "no-named-as-default": "off", |
| 138 | + "no-param-reassign": 0, |
| 139 | + "no-use-before-define": "off", |
| 140 | + "prettier/prettier": ["warn"], |
| 141 | + "react/forbid-prop-types": "off", |
| 142 | + "react/jsx-filename-extension": "off", |
| 143 | + "react/jsx-no-useless-fragment": "error", |
| 144 | + "react/jsx-props-no-spreading": 0, |
| 145 | + "react/prefer-stateless-function": "off", |
| 146 | + "react/static-property-placement": 0, |
| 147 | + "vitest/prefer-to-be": "off", |
| 148 | + }, |
| 149 | +}]; |
0 commit comments