eslint-plugin-react-dom 3.0.0-beta.7 → 3.0.0-beta.8
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 +38 -38
- package/package.json +6 -6
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.8";
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils/create-jsx-element-resolver.ts
|
|
@@ -83,14 +83,14 @@ var no_dangerously_set_innerhtml_default = createRule({
|
|
|
83
83
|
});
|
|
84
84
|
function create$17(context) {
|
|
85
85
|
if (!context.sourceCode.text.includes(DSIH$1)) return {};
|
|
86
|
-
return { JSXElement(node) {
|
|
86
|
+
return defineRuleListener({ JSXElement(node) {
|
|
87
87
|
const dsihProp = core.getJsxAttribute(context, node)(DSIH$1);
|
|
88
88
|
if (dsihProp == null) return;
|
|
89
89
|
context.report({
|
|
90
90
|
messageId: "default",
|
|
91
91
|
node: dsihProp
|
|
92
92
|
});
|
|
93
|
-
} };
|
|
93
|
+
} });
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
//#endregion
|
|
@@ -119,7 +119,7 @@ function isSignificantChildren(node) {
|
|
|
119
119
|
}
|
|
120
120
|
function create$16(context) {
|
|
121
121
|
if (!context.sourceCode.text.includes(DSIH)) return {};
|
|
122
|
-
return { JSXElement(node) {
|
|
122
|
+
return defineRuleListener({ JSXElement(node) {
|
|
123
123
|
const findJsxAttribute = core.getJsxAttribute(context, node);
|
|
124
124
|
if (findJsxAttribute(DSIH) == null) return;
|
|
125
125
|
const childrenPropOrNode = findJsxAttribute("children") ?? node.children.find(isSignificantChildren);
|
|
@@ -128,7 +128,7 @@ function create$16(context) {
|
|
|
128
128
|
messageId: "default",
|
|
129
129
|
node: childrenPropOrNode
|
|
130
130
|
});
|
|
131
|
-
} };
|
|
131
|
+
} });
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
//#endregion
|
|
@@ -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,7 +164,7 @@ function create$15(context) {
|
|
|
164
164
|
});
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
} };
|
|
167
|
+
} });
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
//#endregion
|
|
@@ -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,7 +200,7 @@ function create$14(context) {
|
|
|
200
200
|
});
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
|
-
} };
|
|
203
|
+
} });
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
//#endregion
|
|
@@ -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);
|
|
@@ -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,7 +305,7 @@ 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
|
|
@@ -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,7 +361,7 @@ function create$11(context) {
|
|
|
361
361
|
}
|
|
362
362
|
}]
|
|
363
363
|
});
|
|
364
|
-
} };
|
|
364
|
+
} });
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
//#endregion
|
|
@@ -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,7 +387,7 @@ 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
|
|
@@ -410,7 +410,7 @@ function create$9(context) {
|
|
|
410
410
|
if (compare(getSettingsFromContext(context).version, "18.0.0", "<")) return {};
|
|
411
411
|
const reactDomNames = new Set(["ReactDOM", "ReactDOM"]);
|
|
412
412
|
const renderNames = /* @__PURE__ */ new Set();
|
|
413
|
-
return {
|
|
413
|
+
return defineRuleListener({
|
|
414
414
|
CallExpression(node) {
|
|
415
415
|
switch (true) {
|
|
416
416
|
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name):
|
|
@@ -443,7 +443,7 @@ function create$9(context) {
|
|
|
443
443
|
continue;
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
};
|
|
446
|
+
});
|
|
447
447
|
}
|
|
448
448
|
/**
|
|
449
449
|
* Provides a fixer function to replace `render(app, container)` with `createRoot(container).render(app)`
|
|
@@ -484,7 +484,7 @@ var no_render_return_value_default = createRule({
|
|
|
484
484
|
function create$8(context) {
|
|
485
485
|
const reactDomNames = new Set(["ReactDOM", "ReactDOM"]);
|
|
486
486
|
const renderNames = /* @__PURE__ */ new Set();
|
|
487
|
-
return {
|
|
487
|
+
return defineRuleListener({
|
|
488
488
|
CallExpression(node) {
|
|
489
489
|
switch (true) {
|
|
490
490
|
case node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name) && banParentTypes.includes(node.parent.type):
|
|
@@ -515,7 +515,7 @@ function create$8(context) {
|
|
|
515
515
|
continue;
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
};
|
|
518
|
+
});
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
//#endregion
|
|
@@ -533,14 +533,14 @@ 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
|
|
@@ -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,7 +567,7 @@ 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
|
|
@@ -1646,7 +1646,7 @@ 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
1652
|
if (ignoreNames.indexOf(actualName) >= 0) return;
|
|
@@ -1702,7 +1702,7 @@ function create$5(context) {
|
|
|
1702
1702
|
node,
|
|
1703
1703
|
data: { name: actualName }
|
|
1704
1704
|
});
|
|
1705
|
-
} };
|
|
1705
|
+
} });
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
1708
|
//#endregion
|
|
@@ -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,7 +1742,7 @@ 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
|
|
@@ -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,7 +1821,7 @@ function create$3(context) {
|
|
|
1821
1821
|
}
|
|
1822
1822
|
}]
|
|
1823
1823
|
});
|
|
1824
|
-
} };
|
|
1824
|
+
} });
|
|
1825
1825
|
}
|
|
1826
1826
|
|
|
1827
1827
|
//#endregion
|
|
@@ -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);
|
|
@@ -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,7 +1931,7 @@ function create$1(context) {
|
|
|
1931
1931
|
node,
|
|
1932
1932
|
data: { elementType: domElementType }
|
|
1933
1933
|
});
|
|
1934
|
-
} };
|
|
1934
|
+
} });
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
1937
|
//#endregion
|
|
@@ -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.8",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
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.8",
|
|
47
|
+
"@eslint-react/core": "3.0.0-beta.8",
|
|
48
|
+
"@eslint-react/shared": "3.0.0-beta.8",
|
|
49
|
+
"@eslint-react/eff": "3.0.0-beta.8",
|
|
50
|
+
"@eslint-react/var": "3.0.0-beta.8"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|