-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact.js
More file actions
63 lines (61 loc) · 1.86 KB
/
Copy pathreact.js
File metadata and controls
63 lines (61 loc) · 1.86 KB
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
import baseConfig from "./index.js";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
/**
* @param {string|string[]} [projectPaths="./tsconfig.json"] - One or more tsconfig paths.
* @returns {import('eslint').Linter.FlatConfig[]} An array of ESLint flat config objects.
*/
export function reactBaseConfig(projectPaths) {
return [
{
files: ["**/*.{ts,tsx,js,jsx}"],
settings: {
react: { version: "detect" },
...react.configs.recommended.settings,
...reactHooks.configs.recommended.settings,
...react.configs["jsx-runtime"].settings,
},
plugins: {
react,
"react-hooks": reactHooks,
},
rules: {
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
...react.configs["jsx-runtime"].rules,
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/self-closing-comp": "warn",
// TypeScript rules are defined in baseConfig (tseslint.config)
},
},
...baseConfig(projectPaths),
];
}
/**
* @param {string|string[]} [projectPaths="./tsconfig.json"] - One or more tsconfig paths.
* @returns {import('eslint').Linter.FlatConfig[]} An array of ESLint flat config objects.
*/
export default function reactConfig(projectPaths) {
return [
{
files: ["**/*.{ts,tsx,js,jsx}"],
languageOptions: {
globals: globals.browser,
},
plugins: {
"react-refresh": reactRefresh,
},
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
// TypeScript rules are defined in baseConfig (tseslint.config)
},
},
...reactBaseConfig(projectPaths),
];
}