@pob/eslint-config-typescript-react 67.10.0 → 67.12.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 +43 -16
- package/lib/oxlint-plugins/react.js +3 -0
- package/lib/plugins/react.js +23 -10
- package/oxlint/react.json +65 -1
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -37,13 +37,37 @@ const oxlintReactNativeWeb =
|
|
|
37
37
|
"@pob/eslint-config-typescript-react/oxlint/react-native-web.json",
|
|
38
38
|
);
|
|
39
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
|
+
|
|
40
48
|
// turns off the rules of react.json, and those of @pob/eslint-config again as
|
|
41
49
|
// the react configs re-enable import-x/extensions
|
|
42
|
-
const
|
|
50
|
+
const oxlintTurnOffConfigs = createOxlintConfigs([
|
|
43
51
|
oxlintReactConfig,
|
|
44
52
|
...(oxlintReactNative ? [oxlintReactNativeConfig] : []),
|
|
45
53
|
...(oxlintReactNativeWeb ? [oxlintReactNativeWebConfig] : []),
|
|
46
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
|
+
: [];
|
|
47
71
|
|
|
48
72
|
/**
|
|
49
73
|
* @param {import("typescript-eslint").ConfigArray} base
|
|
@@ -72,22 +96,25 @@ const createConfig = (base) => [
|
|
|
72
96
|
],
|
|
73
97
|
},
|
|
74
98
|
rules: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
},
|
|
88
115
|
},
|
|
89
|
-
|
|
90
|
-
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
91
118
|
// "react/jsx-filename-extension": ["error", { extensions: ["tsx"] }],
|
|
92
119
|
},
|
|
93
120
|
},
|
package/lib/plugins/react.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
1
3
|
import reactPlugin from "eslint-plugin-react";
|
|
2
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
|
+
|
|
3
17
|
export default [
|
|
4
18
|
reactPlugin.configs.flat.recommended,
|
|
5
19
|
reactPlugin.configs.flat["jsx-runtime"],
|
|
6
20
|
{
|
|
21
|
+
...(reactVersion && { settings: { react: { version: reactVersion } } }),
|
|
7
22
|
rules: {
|
|
8
23
|
// https://github.com/airbnb/javascript/issues/2829
|
|
9
24
|
"func-names": "error",
|
|
@@ -68,6 +83,9 @@ export default [
|
|
|
68
83
|
// https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md
|
|
69
84
|
"react/jsx-no-constructed-context-values": "error",
|
|
70
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
|
+
|
|
71
89
|
// Prevent usage of `javascript:` URLs
|
|
72
90
|
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
73
91
|
"react/jsx-no-script-url": [
|
|
@@ -123,7 +141,8 @@ export default [
|
|
|
123
141
|
"react/no-unstable-nested-components": "error",
|
|
124
142
|
|
|
125
143
|
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
|
|
126
|
-
|
|
144
|
+
// only checks propTypes and Flow types, not TypeScript types
|
|
145
|
+
"react/prefer-exact-props": "off",
|
|
127
146
|
|
|
128
147
|
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
129
148
|
"react/prefer-es6-class": ["error", "always"],
|
|
@@ -176,15 +195,9 @@ export default [
|
|
|
176
195
|
},
|
|
177
196
|
],
|
|
178
197
|
|
|
179
|
-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
noSortAlphabetically: true,
|
|
184
|
-
requiredFirst: false,
|
|
185
|
-
callbacksLast: true,
|
|
186
|
-
},
|
|
187
|
-
],
|
|
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",
|
|
188
201
|
},
|
|
189
202
|
},
|
|
190
203
|
];
|
package/oxlint/react.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"plugins": ["react", "jsx-a11y"],
|
|
3
|
+
"jsPlugins": [
|
|
4
|
+
{ "name": "react-js", "specifier": "../lib/oxlint-plugins/react.js" }
|
|
5
|
+
],
|
|
3
6
|
"overrides": [
|
|
4
7
|
{
|
|
5
8
|
"files": ["**/*.{ts,cts,mts,tsx}"],
|
|
@@ -133,7 +136,68 @@
|
|
|
133
136
|
"react/prefer-es6-class": ["error", "always"],
|
|
134
137
|
"react/require-render-return": "error",
|
|
135
138
|
"react/rules-of-hooks": "error",
|
|
136
|
-
"react/self-closing-comp": "error"
|
|
139
|
+
"react/self-closing-comp": "error",
|
|
140
|
+
"react-js/destructuring-assignment": [
|
|
141
|
+
"error",
|
|
142
|
+
"always",
|
|
143
|
+
{ "ignoreClassFields": false, "destructureInSignature": "always" }
|
|
144
|
+
],
|
|
145
|
+
"react-js/jsx-no-leaked-render": "error",
|
|
146
|
+
"react-js/jsx-sort-props": [
|
|
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
|
+
]
|
|
137
201
|
}
|
|
138
202
|
}
|
|
139
203
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/eslint-config-typescript-react",
|
|
3
|
-
"version": "67.
|
|
3
|
+
"version": "67.12.0",
|
|
4
4
|
"description": "eslint config files",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/christophehurpeau/pob",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@pob/eslint-config": "67.12.0",
|
|
38
|
+
"@pob/eslint-plugin": "66.5.0",
|
|
37
39
|
"eslint-plugin-import-x": "4.17.1",
|
|
38
40
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
39
41
|
"eslint-plugin-react": "7.37.5",
|
|
40
|
-
"eslint-plugin-react-hooks": "5.2.0"
|
|
41
|
-
"@pob/eslint-plugin": "66.4.0",
|
|
42
|
-
"@pob/eslint-config": "67.10.0"
|
|
42
|
+
"eslint-plugin-react-hooks": "5.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "24.
|
|
45
|
+
"@types/node": "24.19.1",
|
|
46
46
|
"@types/react": "19.2.18",
|
|
47
47
|
"react": "19.2.8",
|
|
48
48
|
"typescript": "npm:@typescript/typescript6@6.0.2"
|