@pob/eslint-config-typescript-react 67.14.0 → 68.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +25 -166
- package/lib/oxlint-plugins/react-x.js +3 -0
- package/oxlint/react.json +40 -67
- package/package.json +3 -6
- package/lib/eslint-rules.test.js +0 -51
- package/lib/oxlint-plugins/react.js +0 -3
- package/lib/plugins/jsx-a11y.js +0 -3
- package/lib/plugins/react-hooks.js +0 -14
- package/lib/plugins/react.js +0 -203
package/lib/index.js
CHANGED
|
@@ -1,154 +1,52 @@
|
|
|
1
|
-
import basePobConfig, {
|
|
2
|
-
createOxlintConfigs,
|
|
3
|
-
isOxlintConfigExtended,
|
|
4
|
-
tsExtensions,
|
|
5
|
-
} from "@pob/eslint-config";
|
|
6
|
-
import pobPlugin from "@pob/eslint-plugin";
|
|
1
|
+
import basePobConfig, { tsExtensions } from "@pob/eslint-config";
|
|
7
2
|
import { createNodeResolver } from "eslint-plugin-import-x";
|
|
8
|
-
import oxlintReactNativeWebConfig from "../oxlint/react-native-web.json" with { type: "json" };
|
|
9
|
-
import oxlintReactNativeConfig from "../oxlint/react-native.json" with { type: "json" };
|
|
10
|
-
import oxlintReactConfig from "../oxlint/react.json" with { type: "json" };
|
|
11
3
|
import importPluginOverrideConfig from "./plugins/import.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
|
|
5
|
+
// react, react-hooks and jsx-a11y rules are checked by oxlint, see
|
|
6
|
+
// oxlint/react.json: eslint only resolves the imports of TSX files
|
|
15
7
|
|
|
16
8
|
export { apply, applyTs } from "@pob/eslint-config";
|
|
17
9
|
|
|
18
10
|
const { configs } = basePobConfig;
|
|
19
11
|
|
|
20
|
-
// react.json is extended by React projects, once regenerated by pob: until
|
|
21
|
-
// then its rules stay in eslint, and import-x/extensions is re-enabled with
|
|
22
|
-
// the react options after the oxlint turn-off of @pob/eslint-config.
|
|
23
|
-
const oxlintReact = isOxlintConfigExtended(
|
|
24
|
-
"@pob/eslint-config-typescript-react/oxlint/react.json",
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
// react-native.json and react-native-web.json replace the import-x/extensions
|
|
28
|
-
// options of the matching configs, extended after react.json
|
|
29
|
-
const oxlintReactNative =
|
|
30
|
-
oxlintReact &&
|
|
31
|
-
isOxlintConfigExtended(
|
|
32
|
-
"@pob/eslint-config-typescript-react/oxlint/react-native.json",
|
|
33
|
-
);
|
|
34
|
-
const oxlintReactNativeWeb =
|
|
35
|
-
oxlintReact &&
|
|
36
|
-
isOxlintConfigExtended(
|
|
37
|
-
"@pob/eslint-config-typescript-react/oxlint/react-native-web.json",
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// module.json and node.json check import/extensions in oxlint, requiring
|
|
41
|
-
// extensions: without react.json, re-enabling import-x/extensions with the
|
|
42
|
-
// react options would require the opposite, and no import would pass both.
|
|
43
|
-
const enableImportExtensions =
|
|
44
|
-
oxlintReact ||
|
|
45
|
-
(!isOxlintConfigExtended("@pob/eslint-config/oxlint/module.json") &&
|
|
46
|
-
!isOxlintConfigExtended("@pob/eslint-config/oxlint/node.json"));
|
|
47
|
-
|
|
48
|
-
// turns off the rules of react.json, and those of @pob/eslint-config again as
|
|
49
|
-
// the react configs re-enable import-x/extensions
|
|
50
|
-
const oxlintTurnOffConfigs = createOxlintConfigs([
|
|
51
|
-
oxlintReactConfig,
|
|
52
|
-
...(oxlintReactNative ? [oxlintReactNativeConfig] : []),
|
|
53
|
-
...(oxlintReactNativeWeb ? [oxlintReactNativeWebConfig] : []),
|
|
54
|
-
]);
|
|
55
|
-
/** @type {import("eslint").Linter.Config[]} */
|
|
56
|
-
const oxlintReactConfigs =
|
|
57
|
-
oxlintTurnOffConfigs.length > 0
|
|
58
|
-
? [
|
|
59
|
-
...oxlintTurnOffConfigs,
|
|
60
|
-
{
|
|
61
|
-
name: "@pob/eslint-config-typescript-react/oxlint",
|
|
62
|
-
files: [`**/*.${tsExtensions}`],
|
|
63
|
-
rules: {
|
|
64
|
-
// only marks JSX variables as used for no-unused-vars, checked by
|
|
65
|
-
// oxlint
|
|
66
|
-
"react/jsx-uses-vars": "off",
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
]
|
|
70
|
-
: [];
|
|
71
|
-
|
|
72
12
|
/**
|
|
73
|
-
* @param {import("
|
|
74
|
-
* @returns {import("
|
|
13
|
+
* @param {import("eslint").Linter.Config[]} base
|
|
14
|
+
* @returns {import("eslint").Linter.Config[]}
|
|
75
15
|
*/
|
|
76
16
|
const createConfig = (base) => [
|
|
77
17
|
...base,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
".d.tsx",
|
|
94
|
-
],
|
|
95
|
-
}),
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
rules: {
|
|
99
|
-
// with react.json, turned off again by oxlintReactConfigs
|
|
100
|
-
...(enableImportExtensions && {
|
|
101
|
-
"import-x/extensions": [
|
|
102
|
-
"error",
|
|
103
|
-
"always",
|
|
104
|
-
{
|
|
105
|
-
ignorePackages: true,
|
|
106
|
-
pattern: {
|
|
107
|
-
js: "always",
|
|
108
|
-
cjs: "always",
|
|
109
|
-
mjs: "always",
|
|
110
|
-
cts: "always",
|
|
111
|
-
mts: "always",
|
|
112
|
-
ts: "never",
|
|
113
|
-
tsx: "never",
|
|
114
|
-
},
|
|
115
|
-
},
|
|
18
|
+
{
|
|
19
|
+
...importPluginOverrideConfig,
|
|
20
|
+
files: [`**/*.${tsExtensions}`],
|
|
21
|
+
settings: {
|
|
22
|
+
...importPluginOverrideConfig.settings,
|
|
23
|
+
"import-x/resolver-next": [
|
|
24
|
+
createNodeResolver({
|
|
25
|
+
extensions: [
|
|
26
|
+
".mjs",
|
|
27
|
+
".js",
|
|
28
|
+
".json",
|
|
29
|
+
".ts",
|
|
30
|
+
".tsx",
|
|
31
|
+
".d.ts",
|
|
32
|
+
".d.tsx",
|
|
116
33
|
],
|
|
117
34
|
}),
|
|
118
|
-
|
|
119
|
-
},
|
|
35
|
+
],
|
|
120
36
|
},
|
|
121
|
-
|
|
122
|
-
...reactHooksConfigs,
|
|
123
|
-
...jsxA11yConfigs,
|
|
124
|
-
].map((config) => ({
|
|
125
|
-
...config,
|
|
126
|
-
files: [`**/*.${tsExtensions}`],
|
|
127
|
-
})),
|
|
128
|
-
...(oxlintReact ? oxlintReactConfigs : []),
|
|
37
|
+
},
|
|
129
38
|
];
|
|
130
39
|
|
|
131
|
-
/**
|
|
132
|
-
* @satisfies {{ configs: Record<string, import("typescript-eslint").ConfigArray> }}
|
|
133
|
-
*/
|
|
134
40
|
export default {
|
|
135
41
|
configs: {
|
|
136
42
|
base: createConfig(configs.baseModule),
|
|
137
43
|
node: createConfig(configs.node),
|
|
138
44
|
|
|
139
|
-
allowUnsafe: configs.allowUnsafe,
|
|
140
|
-
allowUnsafeAsWarn: configs.allowUnsafeAsWarn,
|
|
141
|
-
allowImplicitReturnType: configs.allowImplicitReturnType,
|
|
142
|
-
app: configs.app,
|
|
143
|
-
|
|
144
45
|
monorepo: configs.monorepo,
|
|
145
46
|
|
|
146
|
-
// for projects extending react.json from a nested .oxlintrc.json, like
|
|
147
|
-
// this repo's test-lint: apply it last on the same files
|
|
148
|
-
oxlint: oxlintReactConfigs,
|
|
149
|
-
|
|
150
47
|
"react-native": [
|
|
151
48
|
{
|
|
49
|
+
name: "@pob/eslint-config-typescript-react/react-native",
|
|
152
50
|
settings: {
|
|
153
51
|
"import-x/resolver-next": [
|
|
154
52
|
createNodeResolver({
|
|
@@ -167,31 +65,12 @@ export default {
|
|
|
167
65
|
}),
|
|
168
66
|
],
|
|
169
67
|
},
|
|
170
|
-
rules: oxlintReactNative
|
|
171
|
-
? {}
|
|
172
|
-
: {
|
|
173
|
-
"import-x/extensions": [
|
|
174
|
-
"error",
|
|
175
|
-
"always",
|
|
176
|
-
{
|
|
177
|
-
ignorePackages: true,
|
|
178
|
-
pattern: {
|
|
179
|
-
js: "always",
|
|
180
|
-
cjs: "always",
|
|
181
|
-
mjs: "always",
|
|
182
|
-
cts: "always",
|
|
183
|
-
mts: "always",
|
|
184
|
-
ts: "never",
|
|
185
|
-
tsx: "never",
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
68
|
},
|
|
191
69
|
],
|
|
192
70
|
|
|
193
71
|
"react-native-web": [
|
|
194
72
|
{
|
|
73
|
+
name: "@pob/eslint-config-typescript-react/react-native-web",
|
|
195
74
|
settings: {
|
|
196
75
|
"import-x/resolver-next": [
|
|
197
76
|
createNodeResolver({
|
|
@@ -209,26 +88,6 @@ export default {
|
|
|
209
88
|
],
|
|
210
89
|
},
|
|
211
90
|
rules: {
|
|
212
|
-
...(oxlintReactNativeWeb
|
|
213
|
-
? {}
|
|
214
|
-
: {
|
|
215
|
-
"import-x/extensions": [
|
|
216
|
-
"error",
|
|
217
|
-
"always",
|
|
218
|
-
{
|
|
219
|
-
ignorePackages: true,
|
|
220
|
-
pattern: {
|
|
221
|
-
js: "always",
|
|
222
|
-
cjs: "always",
|
|
223
|
-
mjs: "always",
|
|
224
|
-
cts: "always",
|
|
225
|
-
mts: "never",
|
|
226
|
-
ts: "never",
|
|
227
|
-
tsx: "never",
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
}),
|
|
232
91
|
"import-x/no-unresolved": [
|
|
233
92
|
"error",
|
|
234
93
|
{
|
package/oxlint/react.json
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"plugins": ["react", "jsx-a11y"],
|
|
3
3
|
"jsPlugins": [
|
|
4
|
-
{
|
|
4
|
+
{
|
|
5
|
+
"name": "react-x",
|
|
6
|
+
"specifier": "../lib/oxlint-plugins/react-x.js"
|
|
7
|
+
}
|
|
5
8
|
],
|
|
6
9
|
"overrides": [
|
|
7
10
|
{
|
|
8
11
|
"files": ["**/*.{ts,cts,mts,tsx}"],
|
|
9
12
|
"rules": {
|
|
13
|
+
"@pob/jsx-no-leaked-render": "error",
|
|
14
|
+
"@pob/jsx-sort-props": "error",
|
|
10
15
|
"@pob/react-function-component-return-react-node": "error",
|
|
11
16
|
"@pob/react-named-import": "error",
|
|
12
17
|
"func-names": "error",
|
|
13
18
|
"import/extensions": [
|
|
14
19
|
"error",
|
|
15
20
|
"ignorePackages",
|
|
16
|
-
{
|
|
21
|
+
{
|
|
22
|
+
"pattern": {
|
|
23
|
+
"ts": "never",
|
|
24
|
+
"tsx": "never"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
17
27
|
],
|
|
18
28
|
"jsx_a11y/alt-text": "error",
|
|
19
29
|
"jsx_a11y/anchor-has-content": "error",
|
|
@@ -101,10 +111,19 @@
|
|
|
101
111
|
}
|
|
102
112
|
],
|
|
103
113
|
"react/hook-use-state": "error",
|
|
104
|
-
"react/jsx-boolean-value": [
|
|
114
|
+
"react/jsx-boolean-value": [
|
|
115
|
+
"error",
|
|
116
|
+
"never",
|
|
117
|
+
{
|
|
118
|
+
"always": []
|
|
119
|
+
}
|
|
120
|
+
],
|
|
105
121
|
"react/jsx-curly-brace-presence": [
|
|
106
122
|
"error",
|
|
107
|
-
{
|
|
123
|
+
{
|
|
124
|
+
"children": "never",
|
|
125
|
+
"props": "never"
|
|
126
|
+
}
|
|
108
127
|
],
|
|
109
128
|
"react/jsx-fragments": ["error", "syntax"],
|
|
110
129
|
"react/jsx-key": "error",
|
|
@@ -113,14 +132,22 @@
|
|
|
113
132
|
"react/jsx-no-duplicate-props": "error",
|
|
114
133
|
"react/jsx-no-script-url": [
|
|
115
134
|
"error",
|
|
116
|
-
[
|
|
135
|
+
[
|
|
136
|
+
{
|
|
137
|
+
"name": "Link",
|
|
138
|
+
"props": ["to"]
|
|
139
|
+
}
|
|
140
|
+
]
|
|
117
141
|
],
|
|
118
142
|
"react/jsx-no-target-blank": "error",
|
|
119
143
|
"react/jsx-no-undef": "error",
|
|
120
144
|
"react/jsx-no-useless-fragment": "error",
|
|
121
145
|
"react/jsx-pascal-case": [
|
|
122
146
|
"error",
|
|
123
|
-
{
|
|
147
|
+
{
|
|
148
|
+
"allowAllCaps": true,
|
|
149
|
+
"ignore": []
|
|
150
|
+
}
|
|
124
151
|
],
|
|
125
152
|
"react/no-array-index-key": "error",
|
|
126
153
|
"react/no-children-prop": "error",
|
|
@@ -137,67 +164,13 @@
|
|
|
137
164
|
"react/require-render-return": "error",
|
|
138
165
|
"react/rules-of-hooks": "error",
|
|
139
166
|
"react/self-closing-comp": "error",
|
|
140
|
-
"react-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"react-
|
|
146
|
-
"react-
|
|
147
|
-
"error",
|
|
148
|
-
{
|
|
149
|
-
"noSortAlphabetically": true,
|
|
150
|
-
"reservedFirst": true,
|
|
151
|
-
"shorthandFirst": true,
|
|
152
|
-
"callbacksLast": true,
|
|
153
|
-
"multiline": "ignore",
|
|
154
|
-
"locale": "auto"
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
"react-js/no-arrow-function-lifecycle": "error",
|
|
158
|
-
"react-js/no-deprecated": "error",
|
|
159
|
-
"react-js/no-invalid-html-attribute": "error",
|
|
160
|
-
"react-js/prefer-stateless-function": [
|
|
161
|
-
"error",
|
|
162
|
-
{ "ignorePureComponents": true }
|
|
163
|
-
],
|
|
164
|
-
"react-js/sort-comp": [
|
|
165
|
-
"error",
|
|
166
|
-
{
|
|
167
|
-
"order": [
|
|
168
|
-
"static-variables",
|
|
169
|
-
"static-methods",
|
|
170
|
-
"instance-variables",
|
|
171
|
-
"lifecycle",
|
|
172
|
-
"getters",
|
|
173
|
-
"setters",
|
|
174
|
-
"instance-methods",
|
|
175
|
-
"/^(on|handle).+$/",
|
|
176
|
-
"everything-else",
|
|
177
|
-
"rendering"
|
|
178
|
-
],
|
|
179
|
-
"groups": {
|
|
180
|
-
"lifecycle": [
|
|
181
|
-
"state",
|
|
182
|
-
"constructor",
|
|
183
|
-
"getDerivedStateFromProps",
|
|
184
|
-
"componentWillMount",
|
|
185
|
-
"UNSAFE_componentWillMount",
|
|
186
|
-
"componentDidMount",
|
|
187
|
-
"componentWillReceiveProps",
|
|
188
|
-
"UNSAFE_componentWillReceiveProps",
|
|
189
|
-
"shouldComponentUpdate",
|
|
190
|
-
"componentWillUpdate",
|
|
191
|
-
"UNSAFE_componentWillUpdate",
|
|
192
|
-
"getSnapshotBeforeUpdate",
|
|
193
|
-
"componentDidUpdate",
|
|
194
|
-
"componentDidCatch",
|
|
195
|
-
"componentWillUnmount"
|
|
196
|
-
],
|
|
197
|
-
"rendering": ["/^render.+$/", "render"]
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
]
|
|
167
|
+
"react-x/no-class-component": "error",
|
|
168
|
+
"react-x/no-component-will-mount": "error",
|
|
169
|
+
"react-x/no-component-will-receive-props": "error",
|
|
170
|
+
"react-x/no-component-will-update": "error",
|
|
171
|
+
"react-x/no-context-provider": "error",
|
|
172
|
+
"react-x/no-forward-ref": "error",
|
|
173
|
+
"react-x/no-use-context": "error"
|
|
201
174
|
}
|
|
202
175
|
}
|
|
203
176
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/eslint-config-typescript-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "68.0.0",
|
|
4
4
|
"description": "eslint config files",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/christophehurpeau/pob",
|
|
@@ -34,12 +34,9 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@pob/eslint-config": "
|
|
38
|
-
"@pob/eslint-plugin": "66.7.0",
|
|
37
|
+
"@pob/eslint-config": "68.0.0",
|
|
39
38
|
"eslint-plugin-import-x": "4.17.1",
|
|
40
|
-
"eslint-plugin-
|
|
41
|
-
"eslint-plugin-react": "7.37.5",
|
|
42
|
-
"eslint-plugin-react-hooks": "5.2.0"
|
|
39
|
+
"eslint-plugin-react-x": "5.26.1"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
42
|
"@types/node": "24.19.1",
|
package/lib/eslint-rules.test.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import pobConfig from "./index.js";
|
|
3
|
-
|
|
4
|
-
// plugins added by this package, the others are in @pob/eslint-config inventory
|
|
5
|
-
const pluginNames = new Set(["react", "react-hooks", "jsx-a11y"]);
|
|
6
|
-
|
|
7
|
-
describe("eslint rules inventory", () => {
|
|
8
|
-
// New rules and newly deprecated ones of the react plugins show up in the
|
|
9
|
-
// snapshot diff on upgrades. Same format as @pob/eslint-config inventory.
|
|
10
|
-
it("matches the snapshot", async () => {
|
|
11
|
-
const configs = Object.values(pobConfig.configs).flat();
|
|
12
|
-
|
|
13
|
-
/** @type {Map<string, import("eslint").Rule.RuleModule>} */
|
|
14
|
-
const rules = new Map();
|
|
15
|
-
/** @type {Map<string, boolean>} */
|
|
16
|
-
const enabledRules = new Map();
|
|
17
|
-
for (const config of configs) {
|
|
18
|
-
for (const [pluginName, plugin] of Object.entries(config.plugins ?? {})) {
|
|
19
|
-
if (!pluginNames.has(pluginName)) continue;
|
|
20
|
-
for (const [ruleName, rule] of Object.entries(plugin.rules ?? {})) {
|
|
21
|
-
rules.set(
|
|
22
|
-
`${pluginName}/${ruleName}`,
|
|
23
|
-
/** @type {import("eslint").Rule.RuleModule} */ (rule),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
for (const [ruleName, ruleEntry] of Object.entries(config.rules ?? {})) {
|
|
28
|
-
const severity = Array.isArray(ruleEntry) ? ruleEntry[0] : ruleEntry;
|
|
29
|
-
const enabled = severity !== "off" && severity !== 0;
|
|
30
|
-
enabledRules.set(ruleName, enabledRules.get(ruleName) || enabled);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** @type {Record<string, "enabled" | "off" | "unset" | "deprecated">} */
|
|
35
|
-
const status = {};
|
|
36
|
-
for (const ruleName of [...rules.keys()].toSorted()) {
|
|
37
|
-
const enabled = enabledRules.get(ruleName);
|
|
38
|
-
if (rules.get(ruleName)?.meta?.deprecated) {
|
|
39
|
-
if (enabled) status[ruleName] = "deprecated";
|
|
40
|
-
} else if (enabled === undefined) {
|
|
41
|
-
status[ruleName] = "unset";
|
|
42
|
-
} else {
|
|
43
|
-
status[ruleName] = enabled ? "enabled" : "off";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
await expect(`${JSON.stringify(status, null, 2)}\n`).toMatchFileSnapshot(
|
|
48
|
-
"../inventory/eslint-rules.json",
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
});
|
package/lib/plugins/jsx-a11y.js
DELETED
package/lib/plugins/react.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import reactPlugin from "eslint-plugin-react";
|
|
4
|
-
|
|
5
|
-
// "detect" crashes with eslint 10: it uses the removed context.getFilename
|
|
6
|
-
const getReactVersion = () => {
|
|
7
|
-
try {
|
|
8
|
-
const require = createRequire(path.resolve("package.json"));
|
|
9
|
-
return /** @type {{ version: string }} */ (require("react/package.json"))
|
|
10
|
-
.version;
|
|
11
|
-
} catch {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const reactVersion = getReactVersion();
|
|
16
|
-
|
|
17
|
-
export default [
|
|
18
|
-
reactPlugin.configs.flat.recommended,
|
|
19
|
-
reactPlugin.configs.flat["jsx-runtime"],
|
|
20
|
-
{
|
|
21
|
-
...(reactVersion && { settings: { react: { version: reactVersion } } }),
|
|
22
|
-
rules: {
|
|
23
|
-
// https://github.com/airbnb/javascript/issues/2829
|
|
24
|
-
"func-names": "error",
|
|
25
|
-
|
|
26
|
-
// legacy prop-types. We use TypeScript for type checking.
|
|
27
|
-
"react/prop-types": "off",
|
|
28
|
-
|
|
29
|
-
// Enforce event handler naming conventions in JSX
|
|
30
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
31
|
-
// 'react/jsx-handler-names': [
|
|
32
|
-
// 'error',
|
|
33
|
-
// {
|
|
34
|
-
// eventHandlerPrefix: 'handle',
|
|
35
|
-
// eventHandlerPropPrefix: 'on',
|
|
36
|
-
// },
|
|
37
|
-
// ],
|
|
38
|
-
|
|
39
|
-
// Prevent direct mutation of this.state
|
|
40
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
41
|
-
"react/no-direct-mutation-state": "error",
|
|
42
|
-
|
|
43
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
44
|
-
"react/button-has-type": "error",
|
|
45
|
-
|
|
46
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
47
|
-
"react/destructuring-assignment": [
|
|
48
|
-
"error",
|
|
49
|
-
"always",
|
|
50
|
-
{ ignoreClassFields: false, destructureInSignature: "always" },
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
54
|
-
"react/display-name": "off",
|
|
55
|
-
|
|
56
|
-
"react/function-component-definition": [
|
|
57
|
-
"error",
|
|
58
|
-
{
|
|
59
|
-
namedComponents: ["function-declaration"],
|
|
60
|
-
// https://github.com/airbnb/javascript/issues/2829
|
|
61
|
-
unnamedComponents: ["function-expression"],
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
|
|
65
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
66
|
-
"react/hook-use-state": "error",
|
|
67
|
-
|
|
68
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
69
|
-
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
70
|
-
|
|
71
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
72
|
-
"react/jsx-curly-brace-presence": [
|
|
73
|
-
"error",
|
|
74
|
-
{ props: "never", children: "never" },
|
|
75
|
-
],
|
|
76
|
-
|
|
77
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
78
|
-
"react/jsx-curly-newline": "off",
|
|
79
|
-
|
|
80
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
81
|
-
"react/jsx-fragments": ["error", "syntax"],
|
|
82
|
-
|
|
83
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md
|
|
84
|
-
"react/jsx-no-constructed-context-values": "error",
|
|
85
|
-
|
|
86
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
87
|
-
"react/jsx-no-leaked-render": "error",
|
|
88
|
-
|
|
89
|
-
// Prevent usage of `javascript:` URLs
|
|
90
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
91
|
-
"react/jsx-no-script-url": [
|
|
92
|
-
"error",
|
|
93
|
-
[
|
|
94
|
-
{
|
|
95
|
-
name: "Link",
|
|
96
|
-
props: ["to"],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
],
|
|
100
|
-
|
|
101
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
102
|
-
"react/jsx-no-undef": "error",
|
|
103
|
-
|
|
104
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
105
|
-
"react/jsx-no-useless-fragment": "error",
|
|
106
|
-
|
|
107
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
108
|
-
"react/jsx-pascal-case": [
|
|
109
|
-
"error",
|
|
110
|
-
{
|
|
111
|
-
allowAllCaps: true,
|
|
112
|
-
ignore: [],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
116
|
-
"react/jsx-sort-props": [
|
|
117
|
-
"error",
|
|
118
|
-
{
|
|
119
|
-
noSortAlphabetically: true,
|
|
120
|
-
reservedFirst: true,
|
|
121
|
-
shorthandFirst: true,
|
|
122
|
-
callbacksLast: true,
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md
|
|
126
|
-
"react/no-arrow-function-lifecycle": "error",
|
|
127
|
-
|
|
128
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
129
|
-
"react/no-array-index-key": "error",
|
|
130
|
-
|
|
131
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md
|
|
132
|
-
"react/no-invalid-html-attribute": "error",
|
|
133
|
-
|
|
134
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md
|
|
135
|
-
"react/no-namespace": "error",
|
|
136
|
-
|
|
137
|
-
// entities does not need to be escaped as color syntaxing makes it clear when it's a body or it's a property.
|
|
138
|
-
"react/no-unescaped-entities": "off",
|
|
139
|
-
|
|
140
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md
|
|
141
|
-
"react/no-unstable-nested-components": "error",
|
|
142
|
-
|
|
143
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
|
|
144
|
-
// only checks propTypes and Flow types, not TypeScript types
|
|
145
|
-
"react/prefer-exact-props": "off",
|
|
146
|
-
|
|
147
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
148
|
-
"react/prefer-es6-class": ["error", "always"],
|
|
149
|
-
|
|
150
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
151
|
-
"react/prefer-stateless-function": [
|
|
152
|
-
"error",
|
|
153
|
-
{ ignorePureComponents: true },
|
|
154
|
-
],
|
|
155
|
-
|
|
156
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
157
|
-
"react/self-closing-comp": "error",
|
|
158
|
-
|
|
159
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
|
|
160
|
-
"react/sort-comp": [
|
|
161
|
-
"error",
|
|
162
|
-
{
|
|
163
|
-
order: [
|
|
164
|
-
"static-variables",
|
|
165
|
-
"static-methods",
|
|
166
|
-
"instance-variables",
|
|
167
|
-
"lifecycle",
|
|
168
|
-
"getters",
|
|
169
|
-
"setters",
|
|
170
|
-
"instance-methods",
|
|
171
|
-
"/^(on|handle).+$/",
|
|
172
|
-
"everything-else",
|
|
173
|
-
"rendering",
|
|
174
|
-
],
|
|
175
|
-
groups: {
|
|
176
|
-
lifecycle: [
|
|
177
|
-
"state",
|
|
178
|
-
"constructor",
|
|
179
|
-
"getDerivedStateFromProps",
|
|
180
|
-
"componentWillMount",
|
|
181
|
-
"UNSAFE_componentWillMount",
|
|
182
|
-
"componentDidMount",
|
|
183
|
-
"componentWillReceiveProps",
|
|
184
|
-
"UNSAFE_componentWillReceiveProps",
|
|
185
|
-
"shouldComponentUpdate",
|
|
186
|
-
"componentWillUpdate",
|
|
187
|
-
"UNSAFE_componentWillUpdate",
|
|
188
|
-
"getSnapshotBeforeUpdate",
|
|
189
|
-
"componentDidUpdate",
|
|
190
|
-
"componentDidCatch",
|
|
191
|
-
"componentWillUnmount",
|
|
192
|
-
],
|
|
193
|
-
rendering: ["/^render.+$/", "render"],
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
|
|
198
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
199
|
-
// only checks propTypes, not TypeScript types
|
|
200
|
-
"react/sort-prop-types": "off",
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
];
|