eslint-plugin-react-dom 5.30.0-beta.21 → 5.30.0-beta.23
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 +50 -5
- package/package.json +6 -6
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-beta.
|
|
22
|
+
var version = "5.30.0-beta.23";
|
|
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",
|
|
@@ -157,7 +199,8 @@ function buildFix$2(context, node) {
|
|
|
157
199
|
if (arg0.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
158
200
|
if (arg1.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
159
201
|
if (node.parent.type !== AST_NODE_TYPES.ExpressionStatement) return null;
|
|
160
|
-
|
|
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)})`)];
|
|
161
204
|
};
|
|
162
205
|
}
|
|
163
206
|
// ../../.pkgs/eff/dist/index.js
|
|
@@ -445,7 +488,8 @@ function buildFix$1(context, node) {
|
|
|
445
488
|
if (arg0.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
446
489
|
if (arg1.type === AST_NODE_TYPES.SpreadElement) return null;
|
|
447
490
|
if (node.parent.type !== AST_NODE_TYPES.ExpressionStatement) return null;
|
|
448
|
-
|
|
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)})`)];
|
|
449
493
|
};
|
|
450
494
|
}
|
|
451
495
|
var no_script_url_default = createRule({
|
|
@@ -1707,7 +1751,8 @@ function create$1(context) {
|
|
|
1707
1751
|
}
|
|
1708
1752
|
function buildFix(context, node, importSource) {
|
|
1709
1753
|
return (fixer) => {
|
|
1710
|
-
|
|
1754
|
+
const importFix = addImportFix(context, fixer, "useActionState", importSource);
|
|
1755
|
+
return [...importFix == null ? [] : [importFix], fixer.replaceText(node.callee, "useActionState")];
|
|
1711
1756
|
};
|
|
1712
1757
|
}
|
|
1713
1758
|
// 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-beta.
|
|
3
|
+
"version": "5.30.0-beta.23",
|
|
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-beta.
|
|
41
|
-
"@eslint-react/eslint": "5.30.0-beta.
|
|
42
|
-
"@eslint-react/jsx": "5.30.0-beta.
|
|
43
|
-
"@eslint-react/shared": "5.30.0-beta.
|
|
44
|
-
"@eslint-react/var": "5.30.0-beta.
|
|
40
|
+
"@eslint-react/ast": "5.30.0-beta.23",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0-beta.23",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0-beta.23",
|
|
43
|
+
"@eslint-react/shared": "5.30.0-beta.23",
|
|
44
|
+
"@eslint-react/var": "5.30.0-beta.23",
|
|
45
45
|
"@typescript-eslint/types": "^8.72.1",
|
|
46
46
|
"@typescript-eslint/utils": "^8.72.1",
|
|
47
47
|
"compare-versions": "^6.1.1",
|