-
Notifications
You must be signed in to change notification settings - Fork 26
/
eslint.config.mjs
68 lines (65 loc) · 2.38 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import path from "node:path";
import {fileURLToPath} from "node:url";
import {includeIgnoreFile} from "@eslint/compat";
import {fixupPluginRules} from "@eslint/compat";
import globals from "globals";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");
export default [
includeIgnoreFile(gitignorePath),
eslint.configs.recommended,
reactPlugin.configs.flat["jsx-runtime"],
eslintPluginPrettierRecommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
...reactPlugin.configs.flat.recommended,
settings: {
...reactPlugin.configs.flat.recommended.settings,
react: {version: "detect"},
},
},
{
files: ["**/*.ts", "**/*.tsx", "**/*.js"],
languageOptions: {
globals: {
...globals.node,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
},
rules: {
// We don't consider those rules helpful
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": ["error", {vars: "all", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_"}],
// We use `react-jsx` and there `React` does not need to be in scope
"react/react-in-jsx-scope": "off",
// The following rules should be enabled, but aren't yet due to legacy code which still needs
// to be adapted
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-prototype-builtins": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
},
},
{
files: ["**/*.js"],
rules: {
"@typescript-eslint/no-require-imports": 0,
},
},
];