eslint-plugin-react-dom 5.11.2 → 5.12.0-beta.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/dist/index.js +23 -28
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region package.json
|
|
27
27
|
var name$2 = "eslint-plugin-react-dom";
|
|
28
|
-
var version = "5.
|
|
28
|
+
var version = "5.12.0-beta.0";
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/utils/create-rule.ts
|
|
@@ -48,11 +48,10 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
|
|
|
48
48
|
create: create$15,
|
|
49
49
|
defaultOptions: []
|
|
50
50
|
});
|
|
51
|
-
const DSIH$1 = "dangerouslySetInnerHTML";
|
|
52
51
|
function create$15(context) {
|
|
53
|
-
if (!context.sourceCode.text.includes(
|
|
52
|
+
if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
|
|
54
53
|
return { JSXElement(node) {
|
|
55
|
-
if (!hasAttribute(context, node,
|
|
54
|
+
if (!hasAttribute(context, node, "dangerouslySetInnerHTML")) return;
|
|
56
55
|
const childrenPropOrNode = findAttribute(context, node, "children") ?? node.children.find((child) => !isWhitespace(child));
|
|
57
56
|
if (childrenPropOrNode == null) return;
|
|
58
57
|
context.report({
|
|
@@ -65,7 +64,6 @@ function create$15(context) {
|
|
|
65
64
|
//#endregion
|
|
66
65
|
//#region src/rules/no-dangerously-set-innerhtml/no-dangerously-set-innerhtml.ts
|
|
67
66
|
const RULE_NAME$14 = "no-dangerously-set-innerhtml";
|
|
68
|
-
const DSIH = "dangerouslySetInnerHTML";
|
|
69
67
|
var no_dangerously_set_innerhtml_default = createRule({
|
|
70
68
|
meta: {
|
|
71
69
|
type: "problem",
|
|
@@ -78,9 +76,9 @@ var no_dangerously_set_innerhtml_default = createRule({
|
|
|
78
76
|
defaultOptions: []
|
|
79
77
|
});
|
|
80
78
|
function create$14(context) {
|
|
81
|
-
if (!context.sourceCode.text.includes(
|
|
79
|
+
if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
|
|
82
80
|
return { JSXElement(node) {
|
|
83
|
-
const dsihProp = findAttribute(context, node,
|
|
81
|
+
const dsihProp = findAttribute(context, node, "dangerouslySetInnerHTML");
|
|
84
82
|
if (dsihProp == null) return;
|
|
85
83
|
context.report({
|
|
86
84
|
messageId: "default",
|
|
@@ -103,20 +101,19 @@ var no_find_dom_node_default = createRule({
|
|
|
103
101
|
create: create$13,
|
|
104
102
|
defaultOptions: []
|
|
105
103
|
});
|
|
106
|
-
const findDOMNode = "findDOMNode";
|
|
107
104
|
function create$13(context) {
|
|
108
|
-
if (!context.sourceCode.text.includes(findDOMNode)) return {};
|
|
105
|
+
if (!context.sourceCode.text.includes("findDOMNode")) return {};
|
|
109
106
|
return { CallExpression(node) {
|
|
110
107
|
const { callee } = node;
|
|
111
108
|
switch (callee.type) {
|
|
112
109
|
case AST_NODE_TYPES.Identifier:
|
|
113
|
-
if (callee.name === findDOMNode) context.report({
|
|
110
|
+
if (callee.name === "findDOMNode") context.report({
|
|
114
111
|
messageId: "default",
|
|
115
112
|
node
|
|
116
113
|
});
|
|
117
114
|
return;
|
|
118
115
|
case AST_NODE_TYPES.MemberExpression:
|
|
119
|
-
if (Extract.getPropertyName(callee.property) === findDOMNode) context.report({
|
|
116
|
+
if (Extract.getPropertyName(callee.property) === "findDOMNode") context.report({
|
|
120
117
|
messageId: "default",
|
|
121
118
|
node
|
|
122
119
|
});
|
|
@@ -139,20 +136,19 @@ var no_flush_sync_default = createRule({
|
|
|
139
136
|
create: create$12,
|
|
140
137
|
defaultOptions: []
|
|
141
138
|
});
|
|
142
|
-
const flushSync = "flushSync";
|
|
143
139
|
function create$12(context) {
|
|
144
|
-
if (!context.sourceCode.text.includes(flushSync)) return {};
|
|
140
|
+
if (!context.sourceCode.text.includes("flushSync")) return {};
|
|
145
141
|
return { CallExpression(node) {
|
|
146
142
|
const { callee } = node;
|
|
147
143
|
switch (callee.type) {
|
|
148
144
|
case AST_NODE_TYPES.Identifier:
|
|
149
|
-
if (callee.name === flushSync) context.report({
|
|
145
|
+
if (callee.name === "flushSync") context.report({
|
|
150
146
|
messageId: "default",
|
|
151
147
|
node
|
|
152
148
|
});
|
|
153
149
|
return;
|
|
154
150
|
case AST_NODE_TYPES.MemberExpression:
|
|
155
|
-
if (Extract.getPropertyName(callee.property) === flushSync) context.report({
|
|
151
|
+
if (Extract.getPropertyName(callee.property) === "flushSync") context.report({
|
|
156
152
|
messageId: "default",
|
|
157
153
|
node
|
|
158
154
|
});
|
|
@@ -176,9 +172,8 @@ var no_hydrate_default = createRule({
|
|
|
176
172
|
create: create$11,
|
|
177
173
|
defaultOptions: []
|
|
178
174
|
});
|
|
179
|
-
const hydrate = "hydrate";
|
|
180
175
|
function create$11(context) {
|
|
181
|
-
if (!context.sourceCode.text.includes(hydrate)) return {};
|
|
176
|
+
if (!context.sourceCode.text.includes("hydrate")) return {};
|
|
182
177
|
if (compare(getSettingsFromContext(context).version, "18.0.0", "<")) return {};
|
|
183
178
|
const reactDomNames = /* @__PURE__ */ new Set();
|
|
184
179
|
const hydrateNames = /* @__PURE__ */ new Set();
|
|
@@ -188,14 +183,14 @@ function create$11(context) {
|
|
|
188
183
|
switch (true) {
|
|
189
184
|
case callee.type === AST_NODE_TYPES.Identifier && hydrateNames.has(callee.name):
|
|
190
185
|
context.report({
|
|
191
|
-
fix:
|
|
186
|
+
fix: buildFix$2(context, node),
|
|
192
187
|
messageId: "default",
|
|
193
188
|
node
|
|
194
189
|
});
|
|
195
190
|
return;
|
|
196
|
-
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && Extract.getPropertyName(callee.property) === hydrate && reactDomNames.has(callee.object.name):
|
|
191
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && Extract.getPropertyName(callee.property) === "hydrate" && reactDomNames.has(callee.object.name):
|
|
197
192
|
context.report({
|
|
198
|
-
fix:
|
|
193
|
+
fix: buildFix$2(context, node),
|
|
199
194
|
messageId: "default",
|
|
200
195
|
node
|
|
201
196
|
});
|
|
@@ -208,7 +203,7 @@ function create$11(context) {
|
|
|
208
203
|
for (const specifier of node.specifiers) switch (specifier.type) {
|
|
209
204
|
case AST_NODE_TYPES.ImportSpecifier:
|
|
210
205
|
if (specifier.imported.type !== AST_NODE_TYPES.Identifier) continue;
|
|
211
|
-
if (specifier.imported.name === hydrate) hydrateNames.add(specifier.local.name);
|
|
206
|
+
if (specifier.imported.name === "hydrate") hydrateNames.add(specifier.local.name);
|
|
212
207
|
continue;
|
|
213
208
|
case AST_NODE_TYPES.ImportDefaultSpecifier:
|
|
214
209
|
case AST_NODE_TYPES.ImportNamespaceSpecifier:
|
|
@@ -218,7 +213,7 @@ function create$11(context) {
|
|
|
218
213
|
}
|
|
219
214
|
};
|
|
220
215
|
}
|
|
221
|
-
function
|
|
216
|
+
function buildFix$2(context, node) {
|
|
222
217
|
const getText = (n) => context.sourceCode.getText(n);
|
|
223
218
|
return (fixer) => {
|
|
224
219
|
const [arg0, arg1] = node.arguments;
|
|
@@ -452,14 +447,14 @@ function create$7(context) {
|
|
|
452
447
|
switch (true) {
|
|
453
448
|
case callee.type === AST_NODE_TYPES.Identifier && renderNames.has(callee.name):
|
|
454
449
|
context.report({
|
|
455
|
-
fix:
|
|
450
|
+
fix: buildFix$1(context, node),
|
|
456
451
|
messageId: "default",
|
|
457
452
|
node
|
|
458
453
|
});
|
|
459
454
|
return;
|
|
460
455
|
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && Extract.getPropertyName(callee.property) === "render" && reactDomNames.has(callee.object.name):
|
|
461
456
|
context.report({
|
|
462
|
-
fix:
|
|
457
|
+
fix: buildFix$1(context, node),
|
|
463
458
|
messageId: "default",
|
|
464
459
|
node
|
|
465
460
|
});
|
|
@@ -488,7 +483,7 @@ function create$7(context) {
|
|
|
488
483
|
* @param node The `CallExpression` node to fix
|
|
489
484
|
* @returns A fixer function or null if the fix cannot be applied
|
|
490
485
|
*/
|
|
491
|
-
function
|
|
486
|
+
function buildFix$1(context, node) {
|
|
492
487
|
const getText = (n) => context.sourceCode.getText(n);
|
|
493
488
|
return (fixer) => {
|
|
494
489
|
const [arg0, arg1] = node.arguments;
|
|
@@ -1858,14 +1853,14 @@ function create$1(context) {
|
|
|
1858
1853
|
switch (true) {
|
|
1859
1854
|
case callee.type === AST_NODE_TYPES.Identifier && useFormStateNames.has(callee.name):
|
|
1860
1855
|
context.report({
|
|
1861
|
-
fix:
|
|
1856
|
+
fix: buildFix(context, node),
|
|
1862
1857
|
messageId: "default",
|
|
1863
1858
|
node
|
|
1864
1859
|
});
|
|
1865
1860
|
return;
|
|
1866
1861
|
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && Extract.getPropertyName(callee.property) === "useFormState" && reactDomNames.has(callee.object.name):
|
|
1867
1862
|
context.report({
|
|
1868
|
-
fix:
|
|
1863
|
+
fix: buildFix(context, node),
|
|
1869
1864
|
messageId: "default",
|
|
1870
1865
|
node
|
|
1871
1866
|
});
|
|
@@ -1888,7 +1883,7 @@ function create$1(context) {
|
|
|
1888
1883
|
}
|
|
1889
1884
|
};
|
|
1890
1885
|
}
|
|
1891
|
-
function
|
|
1886
|
+
function buildFix(context, node) {
|
|
1892
1887
|
const { importSource } = getSettingsFromContext(context);
|
|
1893
1888
|
return (fixer) => {
|
|
1894
1889
|
return [fixer.insertTextBefore(context.sourceCode.ast, `import { useActionState } from "${importSource}";\n`), fixer.replaceText(node.callee, "useActionState")];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@typescript-eslint/types": "^8.62.1",
|
|
41
41
|
"@typescript-eslint/utils": "^8.62.1",
|
|
42
42
|
"compare-versions": "^6.1.1",
|
|
43
|
-
"@eslint-react/ast": "5.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/shared": "5.
|
|
43
|
+
"@eslint-react/ast": "5.12.0-beta.0",
|
|
44
|
+
"@eslint-react/jsx": "5.12.0-beta.0",
|
|
45
|
+
"@eslint-react/eslint": "5.12.0-beta.0",
|
|
46
|
+
"@eslint-react/shared": "5.12.0-beta.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/react": "^19.2.17",
|