eslint-plugin-react-dom 5.30.0-beta.9 → 5.30.0-rc.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 +69 -13
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
|
3
3
|
import { findAttribute, getAttributeStaticValue, getAttributeStaticValueByName, getAttributeValue, getAttributeValueByName, getElementFullType, hasAnyAttribute, hasAttribute, isEmptyExpressionContainer, isHostElement, isPaddingWhitespace, isPlainAttribute } from "@eslint-react/jsx";
|
|
4
4
|
import { getText } from "@eslint-react/eslint";
|
|
5
5
|
import { Check, Extract } from "@eslint-react/ast";
|
|
6
|
-
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
6
|
+
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from "@typescript-eslint/types";
|
|
7
7
|
import { createImportLookup } from "@eslint-react/var";
|
|
8
8
|
import { compare } from "compare-versions";
|
|
9
9
|
// \0rolldown/runtime.js
|
|
@@ -19,7 +19,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
19
19
|
};
|
|
20
20
|
// package.json
|
|
21
21
|
var name$2 = "eslint-plugin-react-dom";
|
|
22
|
-
var version = "5.30.0-
|
|
22
|
+
var version = "5.30.0-rc.0";
|
|
23
23
|
// src/utils/create-rule.ts
|
|
24
24
|
function getDocsUrl(ruleName) {
|
|
25
25
|
return `https://eslint-react.xyz/docs/rules/dom-${ruleName}`;
|
|
@@ -123,6 +123,48 @@ function create$12(context) {
|
|
|
123
123
|
});
|
|
124
124
|
} };
|
|
125
125
|
}
|
|
126
|
+
// src/utils/add-import-fix.ts
|
|
127
|
+
function addImportFix(context, fixer, name, source) {
|
|
128
|
+
const { ast } = context.sourceCode;
|
|
129
|
+
let lastImport = null;
|
|
130
|
+
let lastDirective = null;
|
|
131
|
+
let sameSourceImport = null;
|
|
132
|
+
for (const statement of ast.body) {
|
|
133
|
+
if (Check.isDirective(statement)) {
|
|
134
|
+
lastDirective = statement;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (statement.type !== AST_NODE_TYPES.ImportDeclaration) continue;
|
|
138
|
+
lastImport = statement;
|
|
139
|
+
if (statement.importKind === "type") continue;
|
|
140
|
+
for (const specifier of statement.specifiers) {
|
|
141
|
+
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type") continue;
|
|
142
|
+
if (specifier.local.name !== name) continue;
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
if (statement.source.value !== source) continue;
|
|
146
|
+
sameSourceImport ??= statement;
|
|
147
|
+
}
|
|
148
|
+
const lastNamedSpecifier = (sameSourceImport?.specifiers.filter((s) => s.type === AST_NODE_TYPES.ImportSpecifier) ?? []).at(-1);
|
|
149
|
+
if (lastNamedSpecifier != null) return fixer.insertTextAfter(lastNamedSpecifier, `, ${name}`);
|
|
150
|
+
const text = `import { ${name} } from "${source}";`;
|
|
151
|
+
const eol = context.sourceCode.text.includes("\r\n") ? "\r\n" : "\n";
|
|
152
|
+
if (lastImport != null) return fixer.insertTextAfterRange(getLineEndAnchor(context, lastImport), `${eol}${text}`);
|
|
153
|
+
if (lastDirective != null) return fixer.insertTextAfterRange(getLineEndAnchor(context, lastDirective), `${eol}${text}`);
|
|
154
|
+
const lastComment = (ast.body[0] == null ? ast.comments : context.sourceCode.getCommentsBefore(ast.body[0])).at(-1);
|
|
155
|
+
if (lastComment != null) return fixer.insertTextAfter(lastComment, `${eol}${text}`);
|
|
156
|
+
return fixer.insertTextBefore(ast, `${text}${eol}`);
|
|
157
|
+
}
|
|
158
|
+
function getLineEndAnchor(context, node) {
|
|
159
|
+
let anchor = node;
|
|
160
|
+
for (;;) {
|
|
161
|
+
const next = context.sourceCode.getTokenAfter(anchor, { includeComments: true });
|
|
162
|
+
if (next == null || next.type !== AST_TOKEN_TYPES.Line && next.type !== AST_TOKEN_TYPES.Block) break;
|
|
163
|
+
if (next.loc.start.line !== anchor.loc.end.line) break;
|
|
164
|
+
anchor = next;
|
|
165
|
+
}
|
|
166
|
+
return anchor.range;
|
|
167
|
+
}
|
|
126
168
|
var no_hydrate_default = createRule({
|
|
127
169
|
meta: {
|
|
128
170
|
type: "problem",
|
|
@@ -151,8 +193,14 @@ function create$11(context) {
|
|
|
151
193
|
function buildFix$2(context, node) {
|
|
152
194
|
return (fixer) => {
|
|
153
195
|
const [arg0, arg1] = node.arguments;
|
|
154
|
-
if (arg0 == null
|
|
155
|
-
|
|
196
|
+
if (arg0 == null) return null;
|
|
197
|
+
if (arg1 == null) return null;
|
|
198
|
+
if (node.arguments.length !== 2) return null;
|
|
199
|
+
if (arg0.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
200
|
+
if (arg1.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
201
|
+
if (node.parent.type !== AST_NODE_TYPES.ExpressionStatement) return null;
|
|
202
|
+
const importFix = addImportFix(context, fixer, "hydrateRoot", "react-dom/client");
|
|
203
|
+
return [...importFix == null ? [] : [importFix], fixer.replaceText(node, `hydrateRoot(${getText(context, arg1)}, ${getText(context, arg0)})`)];
|
|
156
204
|
};
|
|
157
205
|
}
|
|
158
206
|
// ../../.pkgs/eff/dist/index.js
|
|
@@ -434,8 +482,14 @@ function create$7(context) {
|
|
|
434
482
|
function buildFix$1(context, node) {
|
|
435
483
|
return (fixer) => {
|
|
436
484
|
const [arg0, arg1] = node.arguments;
|
|
437
|
-
if (arg0 == null
|
|
438
|
-
|
|
485
|
+
if (arg0 == null) return null;
|
|
486
|
+
if (arg1 == null) return null;
|
|
487
|
+
if (node.arguments.length !== 2) return null;
|
|
488
|
+
if (arg0.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
489
|
+
if (arg1.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
490
|
+
if (node.parent.type !== AST_NODE_TYPES.ExpressionStatement) return null;
|
|
491
|
+
const importFix = addImportFix(context, fixer, "createRoot", "react-dom/client");
|
|
492
|
+
return [...importFix == null ? [] : [importFix], fixer.replaceText(node, `createRoot(${getText(context, arg1)}).render(${getText(context, arg0)})`)];
|
|
439
493
|
};
|
|
440
494
|
}
|
|
441
495
|
var no_script_url_default = createRule({
|
|
@@ -1511,9 +1565,9 @@ var no_unknown_property_default = createRule({
|
|
|
1511
1565
|
create: create$4
|
|
1512
1566
|
});
|
|
1513
1567
|
function create$4(context) {
|
|
1514
|
-
const options =
|
|
1515
|
-
const ignore = options.ignore
|
|
1516
|
-
const requireDataLowercase = options.requireDataLowercase
|
|
1568
|
+
const options = context.options[0] ?? {};
|
|
1569
|
+
const ignore = options.ignore ?? [];
|
|
1570
|
+
const requireDataLowercase = options.requireDataLowercase ?? false;
|
|
1517
1571
|
let attributeTagsMap = null;
|
|
1518
1572
|
return { JSXAttribute(node) {
|
|
1519
1573
|
const actualName = getText(context, node.name);
|
|
@@ -1593,7 +1647,9 @@ function create$3(context) {
|
|
|
1593
1647
|
const sandboxValue = getAttributeValueByName(node, "sandbox");
|
|
1594
1648
|
if (sandboxValue == null) return;
|
|
1595
1649
|
const value = getAttributeStaticValue(context, sandboxValue);
|
|
1596
|
-
if (!isString(value)
|
|
1650
|
+
if (!isString(value)) return;
|
|
1651
|
+
const tokens = new Set(value.split(/\s+/u));
|
|
1652
|
+
if (!UNSAFE_SANDBOX_VALUES.every((a) => tokens.has(a))) return;
|
|
1597
1653
|
context.report({
|
|
1598
1654
|
messageId: "default",
|
|
1599
1655
|
node: getAttributeReportNode(sandboxValue)
|
|
@@ -1634,8 +1690,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1634
1690
|
create: create$2
|
|
1635
1691
|
});
|
|
1636
1692
|
function create$2(context) {
|
|
1637
|
-
const
|
|
1638
|
-
const allowReferrer = options.allowReferrer ??= false;
|
|
1693
|
+
const allowReferrer = (context.options[0] ?? {}).allowReferrer ?? false;
|
|
1639
1694
|
const resolver = createJSXElementResolver(context);
|
|
1640
1695
|
const requiredRelAttribute = `rel="${allowReferrer ? "noopener" : "noreferrer"}"`;
|
|
1641
1696
|
return { JSXElement(node) {
|
|
@@ -1698,7 +1753,8 @@ function create$1(context) {
|
|
|
1698
1753
|
}
|
|
1699
1754
|
function buildFix(context, node, importSource) {
|
|
1700
1755
|
return (fixer) => {
|
|
1701
|
-
|
|
1756
|
+
const importFix = addImportFix(context, fixer, "useActionState", importSource);
|
|
1757
|
+
return [...importFix == null ? [] : [importFix], fixer.replaceText(node.callee, "useActionState")];
|
|
1702
1758
|
};
|
|
1703
1759
|
}
|
|
1704
1760
|
// src/rules/no-void-elements-with-children/lib.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "5.30.0-
|
|
3
|
+
"version": "5.30.0-rc.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eslint-react/ast": "5.30.0-
|
|
41
|
-
"@eslint-react/eslint": "5.30.0-
|
|
42
|
-
"@eslint-react/jsx": "5.30.0-
|
|
43
|
-
"@eslint-react/shared": "5.30.0-
|
|
44
|
-
"@eslint-react/var": "5.30.0-
|
|
40
|
+
"@eslint-react/ast": "5.30.0-rc.0",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0-rc.0",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0-rc.0",
|
|
43
|
+
"@eslint-react/shared": "5.30.0-rc.0",
|
|
44
|
+
"@eslint-react/var": "5.30.0-rc.0",
|
|
45
45
|
"@typescript-eslint/types": "^8.72.1",
|
|
46
46
|
"@typescript-eslint/utils": "^8.72.1",
|
|
47
47
|
"compare-versions": "^6.1.1",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@types/react": "^19.3.0",
|
|
57
57
|
"@types/react-dom": "^19.3.0",
|
|
58
58
|
"dedent": "^1.7.2",
|
|
59
|
-
"eslint": "^10.
|
|
60
|
-
"tsdown": "^0.23.
|
|
59
|
+
"eslint": "^10.14.0",
|
|
60
|
+
"tsdown": "^0.23.5",
|
|
61
61
|
"typescript": "6.0.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|