eslint-plugin-react-dom 3.0.0-beta.4 → 3.0.0-beta.40
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 +126 -126
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_ESLINT_REACT_SETTINGS, RE_JAVASCRIPT_PROTOCOL, WEBSITE_URL, getConfigAdapters, getSettingsFromContext } from "@eslint-react/shared";
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, RE_JAVASCRIPT_PROTOCOL, WEBSITE_URL, defineRuleListener, getConfigAdapters, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
2
|
import * as core from "@eslint-react/core";
|
|
3
3
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
4
4
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
@@ -23,7 +23,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region package.json
|
|
25
25
|
var name$2 = "eslint-plugin-react-dom";
|
|
26
|
-
var version = "3.0.0-beta.
|
|
26
|
+
var version = "3.0.0-beta.40";
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils/create-jsx-element-resolver.ts
|
|
@@ -67,72 +67,72 @@ function getDocsUrl(ruleName) {
|
|
|
67
67
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
|
-
//#region src/rules/no-dangerously-set-innerhtml.ts
|
|
71
|
-
const RULE_NAME$17 = "no-dangerously-set-innerhtml";
|
|
72
|
-
|
|
73
|
-
var no_dangerously_set_innerhtml_default = createRule({
|
|
70
|
+
//#region src/rules/no-dangerously-set-innerhtml-with-children/no-dangerously-set-innerhtml-with-children.ts
|
|
71
|
+
const RULE_NAME$17 = "no-dangerously-set-innerhtml-with-children";
|
|
72
|
+
var no_dangerously_set_innerhtml_with_children_default = createRule({
|
|
74
73
|
meta: {
|
|
75
74
|
type: "problem",
|
|
76
|
-
docs: { description: "Disallows DOM elements from using 'dangerouslySetInnerHTML'." },
|
|
77
|
-
messages: { default: "
|
|
75
|
+
docs: { description: "Disallows DOM elements from using 'dangerouslySetInnerHTML' and 'children' at the same time." },
|
|
76
|
+
messages: { default: "A DOM component cannot use both children and 'dangerouslySetInnerHTML'." },
|
|
78
77
|
schema: []
|
|
79
78
|
},
|
|
80
79
|
name: RULE_NAME$17,
|
|
81
80
|
create: create$17,
|
|
82
81
|
defaultOptions: []
|
|
83
82
|
});
|
|
83
|
+
const DSIH$1 = "dangerouslySetInnerHTML";
|
|
84
|
+
/**
|
|
85
|
+
* Check if a JSX child node is considered significant (i.e., not just whitespace for formatting)
|
|
86
|
+
* @param node The JSX child node to check
|
|
87
|
+
* @returns `true` if the node is significant, `false` otherwise
|
|
88
|
+
*/
|
|
89
|
+
function isSignificantChildren(node) {
|
|
90
|
+
if (!core.isJsxText(node)) return true;
|
|
91
|
+
return !(node.raw.trim() === "" && node.raw.includes("\n"));
|
|
92
|
+
}
|
|
84
93
|
function create$17(context) {
|
|
85
94
|
if (!context.sourceCode.text.includes(DSIH$1)) return {};
|
|
86
|
-
return { JSXElement(node) {
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
95
|
+
return defineRuleListener({ JSXElement(node) {
|
|
96
|
+
const findJsxAttribute = core.getJsxAttribute(context, node);
|
|
97
|
+
if (findJsxAttribute(DSIH$1) == null) return;
|
|
98
|
+
const childrenPropOrNode = findJsxAttribute("children") ?? node.children.find(isSignificantChildren);
|
|
99
|
+
if (childrenPropOrNode == null) return;
|
|
89
100
|
context.report({
|
|
90
101
|
messageId: "default",
|
|
91
|
-
node:
|
|
102
|
+
node: childrenPropOrNode
|
|
92
103
|
});
|
|
93
|
-
} };
|
|
104
|
+
} });
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
//#endregion
|
|
97
|
-
//#region src/rules/no-dangerously-set-innerhtml-
|
|
98
|
-
const RULE_NAME$16 = "no-dangerously-set-innerhtml
|
|
99
|
-
|
|
108
|
+
//#region src/rules/no-dangerously-set-innerhtml/no-dangerously-set-innerhtml.ts
|
|
109
|
+
const RULE_NAME$16 = "no-dangerously-set-innerhtml";
|
|
110
|
+
const DSIH = "dangerouslySetInnerHTML";
|
|
111
|
+
var no_dangerously_set_innerhtml_default = createRule({
|
|
100
112
|
meta: {
|
|
101
113
|
type: "problem",
|
|
102
|
-
docs: { description: "Disallows DOM elements from using 'dangerouslySetInnerHTML'
|
|
103
|
-
messages: { default: "
|
|
114
|
+
docs: { description: "Disallows DOM elements from using 'dangerouslySetInnerHTML'." },
|
|
115
|
+
messages: { default: "Using 'dangerouslySetInnerHTML' may have security implications." },
|
|
104
116
|
schema: []
|
|
105
117
|
},
|
|
106
118
|
name: RULE_NAME$16,
|
|
107
119
|
create: create$16,
|
|
108
120
|
defaultOptions: []
|
|
109
121
|
});
|
|
110
|
-
const DSIH = "dangerouslySetInnerHTML";
|
|
111
|
-
/**
|
|
112
|
-
* Check if a JSX child node is considered significant (i.e., not just whitespace for formatting)
|
|
113
|
-
* @param node The JSX child node to check
|
|
114
|
-
* @returns `true` if the node is significant, `false` otherwise
|
|
115
|
-
*/
|
|
116
|
-
function isSignificantChildren(node) {
|
|
117
|
-
if (!core.isJsxText(node)) return true;
|
|
118
|
-
return !(node.raw.trim() === "" && node.raw.includes("\n"));
|
|
119
|
-
}
|
|
120
122
|
function create$16(context) {
|
|
121
123
|
if (!context.sourceCode.text.includes(DSIH)) return {};
|
|
122
|
-
return { JSXElement(node) {
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
const childrenPropOrNode = findJsxAttribute("children") ?? node.children.find(isSignificantChildren);
|
|
126
|
-
if (childrenPropOrNode == null) return;
|
|
124
|
+
return defineRuleListener({ JSXElement(node) {
|
|
125
|
+
const dsihProp = core.getJsxAttribute(context, node)(DSIH);
|
|
126
|
+
if (dsihProp == null) return;
|
|
127
127
|
context.report({
|
|
128
128
|
messageId: "default",
|
|
129
|
-
node:
|
|
129
|
+
node: dsihProp
|
|
130
130
|
});
|
|
131
|
-
} };
|
|
131
|
+
} });
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region src/rules/no-find-dom-node.ts
|
|
135
|
+
//#region src/rules/no-find-dom-node/no-find-dom-node.ts
|
|
136
136
|
const RULE_NAME$15 = "no-find-dom-node";
|
|
137
137
|
var no_find_dom_node_default = createRule({
|
|
138
138
|
meta: {
|
|
@@ -148,7 +148,7 @@ var no_find_dom_node_default = createRule({
|
|
|
148
148
|
const findDOMNode = "findDOMNode";
|
|
149
149
|
function create$15(context) {
|
|
150
150
|
if (!context.sourceCode.text.includes(findDOMNode)) return {};
|
|
151
|
-
return { CallExpression(node) {
|
|
151
|
+
return defineRuleListener({ CallExpression(node) {
|
|
152
152
|
const { callee } = node;
|
|
153
153
|
switch (callee.type) {
|
|
154
154
|
case AST_NODE_TYPES.Identifier:
|
|
@@ -164,11 +164,11 @@ function create$15(context) {
|
|
|
164
164
|
});
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
} };
|
|
167
|
+
} });
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
//#endregion
|
|
171
|
-
//#region src/rules/no-flush-sync.ts
|
|
171
|
+
//#region src/rules/no-flush-sync/no-flush-sync.ts
|
|
172
172
|
const RULE_NAME$14 = "no-flush-sync";
|
|
173
173
|
var no_flush_sync_default = createRule({
|
|
174
174
|
meta: {
|
|
@@ -184,7 +184,7 @@ var no_flush_sync_default = createRule({
|
|
|
184
184
|
const flushSync = "flushSync";
|
|
185
185
|
function create$14(context) {
|
|
186
186
|
if (!context.sourceCode.text.includes(flushSync)) return {};
|
|
187
|
-
return { CallExpression(node) {
|
|
187
|
+
return defineRuleListener({ CallExpression(node) {
|
|
188
188
|
const { callee } = node;
|
|
189
189
|
switch (callee.type) {
|
|
190
190
|
case AST_NODE_TYPES.Identifier:
|
|
@@ -200,11 +200,11 @@ function create$14(context) {
|
|
|
200
200
|
});
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
|
-
} };
|
|
203
|
+
} });
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
//#endregion
|
|
207
|
-
//#region src/rules/no-hydrate.ts
|
|
207
|
+
//#region src/rules/no-hydrate/no-hydrate.ts
|
|
208
208
|
const RULE_NAME$13 = "no-hydrate";
|
|
209
209
|
var no_hydrate_default = createRule({
|
|
210
210
|
meta: {
|
|
@@ -224,7 +224,7 @@ function create$13(context) {
|
|
|
224
224
|
if (compare(getSettingsFromContext(context).version, "18.0.0", "<")) return {};
|
|
225
225
|
const reactDomNames = /* @__PURE__ */ new Set();
|
|
226
226
|
const hydrateNames = /* @__PURE__ */ new Set();
|
|
227
|
-
return {
|
|
227
|
+
return defineRuleListener({
|
|
228
228
|
CallExpression(node) {
|
|
229
229
|
switch (true) {
|
|
230
230
|
case node.callee.type === AST_NODE_TYPES.Identifier && hydrateNames.has(node.callee.name):
|
|
@@ -257,7 +257,7 @@ function create$13(context) {
|
|
|
257
257
|
continue;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
};
|
|
260
|
+
});
|
|
261
261
|
}
|
|
262
262
|
function getFix$2(context, node) {
|
|
263
263
|
const getText = (n) => context.sourceCode.getText(n);
|
|
@@ -269,7 +269,7 @@ function getFix$2(context, node) {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
//#endregion
|
|
272
|
-
//#region src/rules/no-missing-button-type.ts
|
|
272
|
+
//#region src/rules/no-missing-button-type/no-missing-button-type.ts
|
|
273
273
|
const RULE_NAME$12 = "no-missing-button-type";
|
|
274
274
|
const BUTTON_TYPES = [
|
|
275
275
|
"button",
|
|
@@ -293,7 +293,7 @@ var no_missing_button_type_default = createRule({
|
|
|
293
293
|
});
|
|
294
294
|
function create$12(context) {
|
|
295
295
|
const resolver = createJsxElementResolver(context);
|
|
296
|
-
return { JSXElement(node) {
|
|
296
|
+
return defineRuleListener({ JSXElement(node) {
|
|
297
297
|
if (resolver.resolve(node).domElementType !== "button") return;
|
|
298
298
|
if (core.getJsxAttribute(context, node)("type") != null) return;
|
|
299
299
|
context.report({
|
|
@@ -305,11 +305,11 @@ function create$12(context) {
|
|
|
305
305
|
fix: (fixer) => fixer.insertTextAfter(node.openingElement.name, ` type="${type}"`)
|
|
306
306
|
}))
|
|
307
307
|
});
|
|
308
|
-
} };
|
|
308
|
+
} });
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
//#endregion
|
|
312
|
-
//#region src/rules/no-missing-iframe-sandbox.ts
|
|
312
|
+
//#region src/rules/no-missing-iframe-sandbox/no-missing-iframe-sandbox.ts
|
|
313
313
|
const RULE_NAME$11 = "no-missing-iframe-sandbox";
|
|
314
314
|
var no_missing_iframe_sandbox_default = createRule({
|
|
315
315
|
meta: {
|
|
@@ -329,7 +329,7 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
329
329
|
});
|
|
330
330
|
function create$11(context) {
|
|
331
331
|
const resolver = createJsxElementResolver(context);
|
|
332
|
-
return { JSXElement(node) {
|
|
332
|
+
return defineRuleListener({ JSXElement(node) {
|
|
333
333
|
const { domElementType } = resolver.resolve(node);
|
|
334
334
|
if (domElementType !== "iframe") return;
|
|
335
335
|
const sandboxProp = core.getJsxAttribute(context, node)("sandbox");
|
|
@@ -361,11 +361,11 @@ function create$11(context) {
|
|
|
361
361
|
}
|
|
362
362
|
}]
|
|
363
363
|
});
|
|
364
|
-
} };
|
|
364
|
+
} });
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
//#endregion
|
|
368
|
-
//#region src/rules/no-namespace.ts
|
|
368
|
+
//#region src/rules/no-namespace/no-namespace.ts
|
|
369
369
|
const RULE_NAME$10 = "no-namespace";
|
|
370
370
|
var no_namespace_default = createRule({
|
|
371
371
|
meta: {
|
|
@@ -379,7 +379,7 @@ var no_namespace_default = createRule({
|
|
|
379
379
|
defaultOptions: []
|
|
380
380
|
});
|
|
381
381
|
function create$10(context) {
|
|
382
|
-
return { JSXElement(node) {
|
|
382
|
+
return defineRuleListener({ JSXElement(node) {
|
|
383
383
|
const name = core.getJsxElementType(context, node);
|
|
384
384
|
if (typeof name !== "string" || !name.includes(":")) return;
|
|
385
385
|
context.report({
|
|
@@ -387,18 +387,24 @@ function create$10(context) {
|
|
|
387
387
|
node: node.openingElement.name,
|
|
388
388
|
data: { name }
|
|
389
389
|
});
|
|
390
|
-
} };
|
|
390
|
+
} });
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
//#endregion
|
|
394
|
-
//#region src/rules/no-render.ts
|
|
395
|
-
const RULE_NAME$9 = "no-render";
|
|
396
|
-
|
|
394
|
+
//#region src/rules/no-render-return-value/no-render-return-value.ts
|
|
395
|
+
const RULE_NAME$9 = "no-render-return-value";
|
|
396
|
+
const banParentTypes = [
|
|
397
|
+
AST_NODE_TYPES.VariableDeclarator,
|
|
398
|
+
AST_NODE_TYPES.Property,
|
|
399
|
+
AST_NODE_TYPES.ReturnStatement,
|
|
400
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
401
|
+
AST_NODE_TYPES.AssignmentExpression
|
|
402
|
+
];
|
|
403
|
+
var no_render_return_value_default = createRule({
|
|
397
404
|
meta: {
|
|
398
405
|
type: "problem",
|
|
399
|
-
docs: { description: "
|
|
400
|
-
|
|
401
|
-
messages: { default: "[Deprecated] Use 'createRoot(node).render()' instead." },
|
|
406
|
+
docs: { description: "Disallows the return value of 'ReactDOM.render'." },
|
|
407
|
+
messages: { default: "Do not depend on the return value from 'ReactDOM.render'." },
|
|
402
408
|
schema: []
|
|
403
409
|
},
|
|
404
410
|
name: RULE_NAME$9,
|
|
@@ -406,25 +412,21 @@ var no_render_default = createRule({
|
|
|
406
412
|
defaultOptions: []
|
|
407
413
|
});
|
|
408
414
|
function create$9(context) {
|
|
409
|
-
if (!context.sourceCode.text.includes("render")) return {};
|
|
410
|
-
if (compare(getSettingsFromContext(context).version, "18.0.0", "<")) return {};
|
|
411
415
|
const reactDomNames = new Set(["ReactDOM", "ReactDOM"]);
|
|
412
416
|
const renderNames = /* @__PURE__ */ new Set();
|
|
413
|
-
return {
|
|
417
|
+
return defineRuleListener({
|
|
414
418
|
CallExpression(node) {
|
|
415
419
|
switch (true) {
|
|
416
|
-
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name):
|
|
420
|
+
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name) && banParentTypes.includes(node.parent.type):
|
|
417
421
|
context.report({
|
|
418
422
|
messageId: "default",
|
|
419
|
-
node
|
|
420
|
-
fix: getFix$1(context, node)
|
|
423
|
+
node
|
|
421
424
|
});
|
|
422
425
|
return;
|
|
423
|
-
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name):
|
|
426
|
+
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name) && banParentTypes.includes(node.parent.type):
|
|
424
427
|
context.report({
|
|
425
428
|
messageId: "default",
|
|
426
|
-
node
|
|
427
|
-
fix: getFix$1(context, node)
|
|
429
|
+
node
|
|
428
430
|
});
|
|
429
431
|
return;
|
|
430
432
|
}
|
|
@@ -443,38 +445,18 @@ function create$9(context) {
|
|
|
443
445
|
continue;
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Provides a fixer function to replace `render(app, container)` with `createRoot(container).render(app)`
|
|
450
|
-
* @param context The rule context
|
|
451
|
-
* @param node The `CallExpression` node to fix
|
|
452
|
-
* @returns A fixer function or null if the fix cannot be applied
|
|
453
|
-
*/
|
|
454
|
-
function getFix$1(context, node) {
|
|
455
|
-
const getText = (n) => context.sourceCode.getText(n);
|
|
456
|
-
return (fixer) => {
|
|
457
|
-
const [arg0, arg1] = node.arguments;
|
|
458
|
-
if (arg0 == null || arg1 == null) return null;
|
|
459
|
-
return [fixer.insertTextBefore(context.sourceCode.ast, "import { createRoot } from \"react-dom/client\";\n"), fixer.replaceText(node, `createRoot(${getText(arg1)}).render(${getText(arg0)})`)];
|
|
460
|
-
};
|
|
448
|
+
});
|
|
461
449
|
}
|
|
462
450
|
|
|
463
451
|
//#endregion
|
|
464
|
-
//#region src/rules/no-render-
|
|
465
|
-
const RULE_NAME$8 = "no-render
|
|
466
|
-
|
|
467
|
-
AST_NODE_TYPES.VariableDeclarator,
|
|
468
|
-
AST_NODE_TYPES.Property,
|
|
469
|
-
AST_NODE_TYPES.ReturnStatement,
|
|
470
|
-
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
471
|
-
AST_NODE_TYPES.AssignmentExpression
|
|
472
|
-
];
|
|
473
|
-
var no_render_return_value_default = createRule({
|
|
452
|
+
//#region src/rules/no-render/no-render.ts
|
|
453
|
+
const RULE_NAME$8 = "no-render";
|
|
454
|
+
var no_render_default = createRule({
|
|
474
455
|
meta: {
|
|
475
456
|
type: "problem",
|
|
476
|
-
docs: { description: "
|
|
477
|
-
|
|
457
|
+
docs: { description: "Replaces usage of 'ReactDOM.render()' with 'createRoot(node).render()'." },
|
|
458
|
+
fixable: "code",
|
|
459
|
+
messages: { default: "[Deprecated] Use 'createRoot(node).render()' instead." },
|
|
478
460
|
schema: []
|
|
479
461
|
},
|
|
480
462
|
name: RULE_NAME$8,
|
|
@@ -482,21 +464,25 @@ var no_render_return_value_default = createRule({
|
|
|
482
464
|
defaultOptions: []
|
|
483
465
|
});
|
|
484
466
|
function create$8(context) {
|
|
467
|
+
if (!context.sourceCode.text.includes("render")) return {};
|
|
468
|
+
if (compare(getSettingsFromContext(context).version, "18.0.0", "<")) return {};
|
|
485
469
|
const reactDomNames = new Set(["ReactDOM", "ReactDOM"]);
|
|
486
470
|
const renderNames = /* @__PURE__ */ new Set();
|
|
487
|
-
return {
|
|
471
|
+
return defineRuleListener({
|
|
488
472
|
CallExpression(node) {
|
|
489
473
|
switch (true) {
|
|
490
|
-
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name)
|
|
474
|
+
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name):
|
|
491
475
|
context.report({
|
|
492
476
|
messageId: "default",
|
|
493
|
-
node
|
|
477
|
+
node,
|
|
478
|
+
fix: getFix$1(context, node)
|
|
494
479
|
});
|
|
495
480
|
return;
|
|
496
|
-
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name)
|
|
481
|
+
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name):
|
|
497
482
|
context.report({
|
|
498
483
|
messageId: "default",
|
|
499
|
-
node
|
|
484
|
+
node,
|
|
485
|
+
fix: getFix$1(context, node)
|
|
500
486
|
});
|
|
501
487
|
return;
|
|
502
488
|
}
|
|
@@ -515,11 +501,25 @@ function create$8(context) {
|
|
|
515
501
|
continue;
|
|
516
502
|
}
|
|
517
503
|
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Provides a fixer function to replace `render(app, container)` with `createRoot(container).render(app)`
|
|
508
|
+
* @param context The rule context
|
|
509
|
+
* @param node The `CallExpression` node to fix
|
|
510
|
+
* @returns A fixer function or null if the fix cannot be applied
|
|
511
|
+
*/
|
|
512
|
+
function getFix$1(context, node) {
|
|
513
|
+
const getText = (n) => context.sourceCode.getText(n);
|
|
514
|
+
return (fixer) => {
|
|
515
|
+
const [arg0, arg1] = node.arguments;
|
|
516
|
+
if (arg0 == null || arg1 == null) return null;
|
|
517
|
+
return [fixer.insertTextBefore(context.sourceCode.ast, "import { createRoot } from \"react-dom/client\";\n"), fixer.replaceText(node, `createRoot(${getText(arg1)}).render(${getText(arg0)})`)];
|
|
518
518
|
};
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
//#endregion
|
|
522
|
-
//#region src/rules/no-script-url.ts
|
|
522
|
+
//#region src/rules/no-script-url/no-script-url.ts
|
|
523
523
|
const RULE_NAME$7 = "no-script-url";
|
|
524
524
|
var no_script_url_default = createRule({
|
|
525
525
|
meta: {
|
|
@@ -533,18 +533,18 @@ var no_script_url_default = createRule({
|
|
|
533
533
|
defaultOptions: []
|
|
534
534
|
});
|
|
535
535
|
function create$7(context) {
|
|
536
|
-
return { JSXAttribute(node) {
|
|
536
|
+
return defineRuleListener({ JSXAttribute(node) {
|
|
537
537
|
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) return;
|
|
538
538
|
const value = core.resolveJsxAttributeValue(context, node).toStatic();
|
|
539
539
|
if (typeof value === "string" && RE_JAVASCRIPT_PROTOCOL.test(value)) context.report({
|
|
540
540
|
messageId: "default",
|
|
541
541
|
node: node.value
|
|
542
542
|
});
|
|
543
|
-
} };
|
|
543
|
+
} });
|
|
544
544
|
}
|
|
545
545
|
|
|
546
546
|
//#endregion
|
|
547
|
-
//#region src/rules/no-string-style-prop.ts
|
|
547
|
+
//#region src/rules/no-string-style-prop/no-string-style-prop.ts
|
|
548
548
|
const RULE_NAME$6 = "no-string-style-prop";
|
|
549
549
|
var no_string_style_prop_default = createRule({
|
|
550
550
|
meta: {
|
|
@@ -558,7 +558,7 @@ var no_string_style_prop_default = createRule({
|
|
|
558
558
|
defaultOptions: []
|
|
559
559
|
});
|
|
560
560
|
function create$6(context) {
|
|
561
|
-
return { JSXElement(node) {
|
|
561
|
+
return defineRuleListener({ JSXElement(node) {
|
|
562
562
|
if (!core.isJsxHostElement(context, node)) return;
|
|
563
563
|
const styleProp = core.getJsxAttribute(context, node)("style");
|
|
564
564
|
if (styleProp == null) return;
|
|
@@ -567,11 +567,11 @@ function create$6(context) {
|
|
|
567
567
|
messageId: "default",
|
|
568
568
|
node: styleValue.node ?? styleProp
|
|
569
569
|
});
|
|
570
|
-
} };
|
|
570
|
+
} });
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
//#endregion
|
|
574
|
-
//#region src/rules/no-unknown-property.ts
|
|
574
|
+
//#region src/rules/no-unknown-property/no-unknown-property.ts
|
|
575
575
|
const RULE_NAME$5 = "no-unknown-property";
|
|
576
576
|
const DEFAULTS = {
|
|
577
577
|
ignore: [],
|
|
@@ -1646,10 +1646,10 @@ function create$5(context) {
|
|
|
1646
1646
|
function getRequireDataLowercase() {
|
|
1647
1647
|
return context.options[0]?.requireDataLowercase ?? DEFAULTS.requireDataLowercase;
|
|
1648
1648
|
}
|
|
1649
|
-
return { JSXAttribute(node) {
|
|
1649
|
+
return defineRuleListener({ JSXAttribute(node) {
|
|
1650
1650
|
const ignoreNames = getIgnoreConfig();
|
|
1651
1651
|
const actualName = getText(context, node.name);
|
|
1652
|
-
if (ignoreNames.
|
|
1652
|
+
if (ignoreNames.includes(actualName)) return;
|
|
1653
1653
|
const name = normalizeAttributeCase(actualName);
|
|
1654
1654
|
if (tagNameHasDot(node)) return;
|
|
1655
1655
|
if (isValidDataAttribute(name)) {
|
|
@@ -1669,7 +1669,7 @@ function create$5(context) {
|
|
|
1669
1669
|
if (!isValidHTMLTagInJSX(node)) return;
|
|
1670
1670
|
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[name] : null;
|
|
1671
1671
|
if (tagName != null && allowedTags != null) {
|
|
1672
|
-
if (allowedTags.
|
|
1672
|
+
if (!allowedTags.includes(tagName)) context.report({
|
|
1673
1673
|
messageId: "invalidPropOnTag",
|
|
1674
1674
|
node,
|
|
1675
1675
|
data: {
|
|
@@ -1702,11 +1702,11 @@ function create$5(context) {
|
|
|
1702
1702
|
node,
|
|
1703
1703
|
data: { name: actualName }
|
|
1704
1704
|
});
|
|
1705
|
-
} };
|
|
1705
|
+
} });
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
1708
|
//#endregion
|
|
1709
|
-
//#region src/rules/no-unsafe-iframe-sandbox.ts
|
|
1709
|
+
//#region src/rules/no-unsafe-iframe-sandbox/no-unsafe-iframe-sandbox.ts
|
|
1710
1710
|
const RULE_NAME$4 = "no-unsafe-iframe-sandbox";
|
|
1711
1711
|
const UNSAFE_SANDBOX_VALUES = ["allow-scripts", "allow-same-origin"];
|
|
1712
1712
|
/**
|
|
@@ -1733,7 +1733,7 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1733
1733
|
});
|
|
1734
1734
|
function create$4(context) {
|
|
1735
1735
|
const resolver = createJsxElementResolver(context);
|
|
1736
|
-
return { JSXElement(node) {
|
|
1736
|
+
return defineRuleListener({ JSXElement(node) {
|
|
1737
1737
|
if (resolver.resolve(node).domElementType !== "iframe") return;
|
|
1738
1738
|
const sandboxProp = core.getJsxAttribute(context, node)("sandbox");
|
|
1739
1739
|
if (sandboxProp == null) return;
|
|
@@ -1742,11 +1742,11 @@ function create$4(context) {
|
|
|
1742
1742
|
messageId: "default",
|
|
1743
1743
|
node: sandboxValue.node ?? sandboxProp
|
|
1744
1744
|
});
|
|
1745
|
-
} };
|
|
1745
|
+
} });
|
|
1746
1746
|
}
|
|
1747
1747
|
|
|
1748
1748
|
//#endregion
|
|
1749
|
-
//#region src/rules/no-unsafe-target-blank.ts
|
|
1749
|
+
//#region src/rules/no-unsafe-target-blank/no-unsafe-target-blank.ts
|
|
1750
1750
|
const RULE_NAME$3 = "no-unsafe-target-blank";
|
|
1751
1751
|
/**
|
|
1752
1752
|
* Check if a value appears to be an external link.
|
|
@@ -1786,7 +1786,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1786
1786
|
});
|
|
1787
1787
|
function create$3(context) {
|
|
1788
1788
|
const resolver = createJsxElementResolver(context);
|
|
1789
|
-
return { JSXElement(node) {
|
|
1789
|
+
return defineRuleListener({ JSXElement(node) {
|
|
1790
1790
|
const { domElementType } = resolver.resolve(node);
|
|
1791
1791
|
if (domElementType !== "a") return;
|
|
1792
1792
|
const findAttribute = core.getJsxAttribute(context, node);
|
|
@@ -1821,11 +1821,11 @@ function create$3(context) {
|
|
|
1821
1821
|
}
|
|
1822
1822
|
}]
|
|
1823
1823
|
});
|
|
1824
|
-
} };
|
|
1824
|
+
} });
|
|
1825
1825
|
}
|
|
1826
1826
|
|
|
1827
1827
|
//#endregion
|
|
1828
|
-
//#region src/rules/no-use-form-state.ts
|
|
1828
|
+
//#region src/rules/no-use-form-state/no-use-form-state.ts
|
|
1829
1829
|
const RULE_NAME$2 = "no-use-form-state";
|
|
1830
1830
|
var no_use_form_state_default = createRule({
|
|
1831
1831
|
meta: {
|
|
@@ -1844,7 +1844,7 @@ function create$2(context) {
|
|
|
1844
1844
|
if (compare(getSettingsFromContext(context).version, "19.0.0", "<")) return {};
|
|
1845
1845
|
const reactDomNames = /* @__PURE__ */ new Set();
|
|
1846
1846
|
const useFormStateNames = /* @__PURE__ */ new Set();
|
|
1847
|
-
return {
|
|
1847
|
+
return defineRuleListener({
|
|
1848
1848
|
CallExpression(node) {
|
|
1849
1849
|
switch (true) {
|
|
1850
1850
|
case node.callee.type === AST_NODE_TYPES.Identifier && useFormStateNames.has(node.callee.name):
|
|
@@ -1877,7 +1877,7 @@ function create$2(context) {
|
|
|
1877
1877
|
continue;
|
|
1878
1878
|
}
|
|
1879
1879
|
}
|
|
1880
|
-
};
|
|
1880
|
+
});
|
|
1881
1881
|
}
|
|
1882
1882
|
function getFix(context, node) {
|
|
1883
1883
|
const { importSource } = getSettingsFromContext(context);
|
|
@@ -1887,7 +1887,7 @@ function getFix(context, node) {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
|
|
1889
1889
|
//#endregion
|
|
1890
|
-
//#region src/rules/no-void-elements-with-children.ts
|
|
1890
|
+
//#region src/rules/no-void-elements-with-children/no-void-elements-with-children.ts
|
|
1891
1891
|
const RULE_NAME$1 = "no-void-elements-with-children";
|
|
1892
1892
|
const voidElements = new Set([
|
|
1893
1893
|
"area",
|
|
@@ -1920,7 +1920,7 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1920
1920
|
});
|
|
1921
1921
|
function create$1(context) {
|
|
1922
1922
|
const resolver = createJsxElementResolver(context);
|
|
1923
|
-
return { JSXElement(node) {
|
|
1923
|
+
return defineRuleListener({ JSXElement(node) {
|
|
1924
1924
|
const { domElementType } = resolver.resolve(node);
|
|
1925
1925
|
if (!voidElements.has(domElementType)) return;
|
|
1926
1926
|
const findJsxAttribute = core.getJsxAttribute(context, node);
|
|
@@ -1931,11 +1931,11 @@ function create$1(context) {
|
|
|
1931
1931
|
node,
|
|
1932
1932
|
data: { elementType: domElementType }
|
|
1933
1933
|
});
|
|
1934
|
-
} };
|
|
1934
|
+
} });
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
1937
|
//#endregion
|
|
1938
|
-
//#region src/rules/prefer-namespace-import.ts
|
|
1938
|
+
//#region src/rules/prefer-namespace-import/prefer-namespace-import.ts
|
|
1939
1939
|
const RULE_NAME = "prefer-namespace-import";
|
|
1940
1940
|
var prefer_namespace_import_default = createRule({
|
|
1941
1941
|
meta: {
|
|
@@ -1955,7 +1955,7 @@ const importSources = [
|
|
|
1955
1955
|
"react-dom/server"
|
|
1956
1956
|
];
|
|
1957
1957
|
function create(context) {
|
|
1958
|
-
return { [`ImportDeclaration ImportDefaultSpecifier`](node) {
|
|
1958
|
+
return defineRuleListener({ [`ImportDeclaration ImportDefaultSpecifier`](node) {
|
|
1959
1959
|
const importSource = node.parent.source.value;
|
|
1960
1960
|
if (!importSources.includes(importSource)) return;
|
|
1961
1961
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -1974,7 +1974,7 @@ function create(context) {
|
|
|
1974
1974
|
return fixer.replaceText(node.parent, [`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`, `${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semi}`].join("\n"));
|
|
1975
1975
|
}
|
|
1976
1976
|
});
|
|
1977
|
-
} };
|
|
1977
|
+
} });
|
|
1978
1978
|
}
|
|
1979
1979
|
|
|
1980
1980
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.40",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"./package.json"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/scope-manager": "
|
|
42
|
-
"@typescript-eslint/types": "
|
|
43
|
-
"@typescript-eslint/utils": "
|
|
41
|
+
"@typescript-eslint/scope-manager": "canary",
|
|
42
|
+
"@typescript-eslint/types": "canary",
|
|
43
|
+
"@typescript-eslint/utils": "canary",
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "3.0.0-beta.
|
|
47
|
-
"@eslint-react/core": "3.0.0-beta.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/var": "3.0.0-beta.
|
|
46
|
+
"@eslint-react/ast": "3.0.0-beta.40",
|
|
47
|
+
"@eslint-react/core": "3.0.0-beta.40",
|
|
48
|
+
"@eslint-react/shared": "3.0.0-beta.40",
|
|
49
|
+
"@eslint-react/eff": "3.0.0-beta.40",
|
|
50
|
+
"@eslint-react/var": "3.0.0-beta.40"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsdown",
|
|
70
70
|
"lint:publish": "publint",
|
|
71
|
-
"lint:ts": "
|
|
71
|
+
"lint:ts": "tsl"
|
|
72
72
|
}
|
|
73
73
|
}
|