eslint-plugin-react-dom 1.46.0-next.0 → 1.46.1-next.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 +57 -71
- package/dist/index.mjs +57 -71
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -67,35 +67,53 @@ var settings = {
|
|
|
67
67
|
|
|
68
68
|
// package.json
|
|
69
69
|
var name2 = "eslint-plugin-react-dom";
|
|
70
|
-
var version = "1.46.
|
|
70
|
+
var version = "1.46.1-next.0";
|
|
71
|
+
function createJsxElementResolver(context) {
|
|
72
|
+
const {
|
|
73
|
+
additionalComponents,
|
|
74
|
+
polymorphicPropName
|
|
75
|
+
} = shared.getSettingsFromContext(context);
|
|
76
|
+
return {
|
|
77
|
+
resolve(node) {
|
|
78
|
+
const name3 = JSX__namespace.getElementType(node);
|
|
79
|
+
const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
80
|
+
const result = {
|
|
81
|
+
attributes: component?.attributes ?? [],
|
|
82
|
+
domElementType: component?.as ?? name3,
|
|
83
|
+
jsxElementType: name3
|
|
84
|
+
};
|
|
85
|
+
if (name3 === name3.toLowerCase() || component != null || polymorphicPropName == null) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
89
|
+
const polymorphicPropAttr = JSX__namespace.getAttribute(
|
|
90
|
+
polymorphicPropName,
|
|
91
|
+
node.openingElement.attributes,
|
|
92
|
+
initialScope
|
|
93
|
+
);
|
|
94
|
+
if (polymorphicPropAttr != null) {
|
|
95
|
+
const polymorphicPropValue = JSX__namespace.getAttributeValue(
|
|
96
|
+
polymorphicPropAttr,
|
|
97
|
+
polymorphicPropName,
|
|
98
|
+
initialScope
|
|
99
|
+
);
|
|
100
|
+
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
101
|
+
return {
|
|
102
|
+
...result,
|
|
103
|
+
domElementType: polymorphicPropValue.value
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
71
111
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("dom"));
|
|
72
112
|
|
|
73
113
|
// src/utils/find-custom-component.ts
|
|
74
|
-
function findCustomComponent(name3, components) {
|
|
75
|
-
return components.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
76
|
-
}
|
|
77
114
|
function findCustomComponentProp(name3, props) {
|
|
78
115
|
return props.findLast((a) => a.as === name3);
|
|
79
116
|
}
|
|
80
|
-
function getElementTypeOnJsxAndDom(context, node, polymorphicPropName, additionalComponents = []) {
|
|
81
|
-
const name3 = JSX__namespace.getElementType(node);
|
|
82
|
-
if (name3 === name3.toLowerCase()) return [name3, name3];
|
|
83
|
-
const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
84
|
-
if (component != null) return [name3, component.as];
|
|
85
|
-
if (polymorphicPropName == null) return [name3, name3];
|
|
86
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
87
|
-
const attributeNode = JSX__namespace.getAttribute(
|
|
88
|
-
polymorphicPropName,
|
|
89
|
-
node.openingElement.attributes,
|
|
90
|
-
initialScope
|
|
91
|
-
);
|
|
92
|
-
if (attributeNode == null) return [name3, name3];
|
|
93
|
-
const polymorphicPropValue = JSX__namespace.getAttributeValue(attributeNode, polymorphicPropName, initialScope);
|
|
94
|
-
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
95
|
-
return [name3, polymorphicPropValue.value];
|
|
96
|
-
}
|
|
97
|
-
return [name3, name3];
|
|
98
|
-
}
|
|
99
117
|
|
|
100
118
|
// src/rules/no-dangerously-set-innerhtml.ts
|
|
101
119
|
var RULE_NAME = "no-dangerously-set-innerhtml";
|
|
@@ -343,21 +361,13 @@ var no_missing_button_type_default = createRule({
|
|
|
343
361
|
defaultOptions: []
|
|
344
362
|
});
|
|
345
363
|
function create6(context) {
|
|
346
|
-
const
|
|
347
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
348
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
|
|
364
|
+
const resolver = createJsxElementResolver(context);
|
|
349
365
|
return {
|
|
350
366
|
JSXElement(node) {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
node,
|
|
354
|
-
polymorphicPropName,
|
|
355
|
-
additionalComponents
|
|
356
|
-
);
|
|
357
|
-
if (elementNameOnDom !== "button") return;
|
|
367
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
368
|
+
if (domElementType !== "button") return;
|
|
358
369
|
const elementScope = context.sourceCode.getScope(node);
|
|
359
|
-
const
|
|
360
|
-
const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
|
|
370
|
+
const customComponentProp = findCustomComponentProp("type", attributes);
|
|
361
371
|
const propNameOnJsx = customComponentProp?.name ?? "type";
|
|
362
372
|
const attributeNode = JSX__namespace.getAttribute(
|
|
363
373
|
propNameOnJsx,
|
|
@@ -424,21 +434,13 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
424
434
|
defaultOptions: []
|
|
425
435
|
});
|
|
426
436
|
function create7(context) {
|
|
427
|
-
const
|
|
428
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
429
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
|
|
437
|
+
const resolver = createJsxElementResolver(context);
|
|
430
438
|
return {
|
|
431
439
|
JSXElement(node) {
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
node,
|
|
435
|
-
polymorphicPropName,
|
|
436
|
-
additionalComponents
|
|
437
|
-
);
|
|
438
|
-
if (elementNameOnDom !== "iframe") return;
|
|
440
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
441
|
+
if (domElementType !== "iframe") return;
|
|
439
442
|
const elementScope = context.sourceCode.getScope(node);
|
|
440
|
-
const
|
|
441
|
-
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
443
|
+
const customComponentProp = findCustomComponentProp("sandbox", attributes);
|
|
442
444
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
443
445
|
const attributeNode = JSX__namespace.getAttribute(
|
|
444
446
|
propNameOnJsx,
|
|
@@ -1751,21 +1753,13 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1751
1753
|
defaultOptions: []
|
|
1752
1754
|
});
|
|
1753
1755
|
function create13(context) {
|
|
1754
|
-
const
|
|
1755
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
1756
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
|
|
1756
|
+
const resolver = createJsxElementResolver(context);
|
|
1757
1757
|
return {
|
|
1758
1758
|
JSXElement(node) {
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1761
|
-
node,
|
|
1762
|
-
polymorphicPropName,
|
|
1763
|
-
additionalComponents
|
|
1764
|
-
);
|
|
1765
|
-
if (elementNameOnDom !== "iframe") return;
|
|
1759
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
1760
|
+
if (domElementType !== "iframe") return;
|
|
1766
1761
|
const elementScope = context.sourceCode.getScope(node);
|
|
1767
|
-
const
|
|
1768
|
-
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1762
|
+
const customComponentProp = findCustomComponentProp("sandbox", attributes);
|
|
1769
1763
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1770
1764
|
const attributeNode = JSX__namespace.getAttribute(
|
|
1771
1765
|
propNameOnJsx,
|
|
@@ -1820,22 +1814,14 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1820
1814
|
defaultOptions: []
|
|
1821
1815
|
});
|
|
1822
1816
|
function create14(context) {
|
|
1823
|
-
const
|
|
1824
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
1825
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
|
|
1817
|
+
const resolver = createJsxElementResolver(context);
|
|
1826
1818
|
return {
|
|
1827
1819
|
JSXElement(node) {
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
node,
|
|
1831
|
-
polymorphicPropName,
|
|
1832
|
-
additionalComponents
|
|
1833
|
-
);
|
|
1834
|
-
if (elementNameOnDom !== "a") return;
|
|
1820
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
1821
|
+
if (domElementType !== "a") return;
|
|
1835
1822
|
const elementScope = context.sourceCode.getScope(node);
|
|
1836
|
-
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1837
1823
|
const getAttributeStringValue = (name3) => {
|
|
1838
|
-
const customComponentProp = findCustomComponentProp(name3,
|
|
1824
|
+
const customComponentProp = findCustomComponentProp(name3, attributes);
|
|
1839
1825
|
const propNameOnJsx = customComponentProp?.name ?? name3;
|
|
1840
1826
|
const attributeNode = JSX__namespace.getAttribute(
|
|
1841
1827
|
propNameOnJsx,
|
package/dist/index.mjs
CHANGED
|
@@ -44,35 +44,53 @@ var settings = {
|
|
|
44
44
|
|
|
45
45
|
// package.json
|
|
46
46
|
var name2 = "eslint-plugin-react-dom";
|
|
47
|
-
var version = "1.46.
|
|
47
|
+
var version = "1.46.1-next.0";
|
|
48
|
+
function createJsxElementResolver(context) {
|
|
49
|
+
const {
|
|
50
|
+
additionalComponents,
|
|
51
|
+
polymorphicPropName
|
|
52
|
+
} = getSettingsFromContext(context);
|
|
53
|
+
return {
|
|
54
|
+
resolve(node) {
|
|
55
|
+
const name3 = JSX.getElementType(node);
|
|
56
|
+
const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
57
|
+
const result = {
|
|
58
|
+
attributes: component?.attributes ?? [],
|
|
59
|
+
domElementType: component?.as ?? name3,
|
|
60
|
+
jsxElementType: name3
|
|
61
|
+
};
|
|
62
|
+
if (name3 === name3.toLowerCase() || component != null || polymorphicPropName == null) {
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
66
|
+
const polymorphicPropAttr = JSX.getAttribute(
|
|
67
|
+
polymorphicPropName,
|
|
68
|
+
node.openingElement.attributes,
|
|
69
|
+
initialScope
|
|
70
|
+
);
|
|
71
|
+
if (polymorphicPropAttr != null) {
|
|
72
|
+
const polymorphicPropValue = JSX.getAttributeValue(
|
|
73
|
+
polymorphicPropAttr,
|
|
74
|
+
polymorphicPropName,
|
|
75
|
+
initialScope
|
|
76
|
+
);
|
|
77
|
+
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
78
|
+
return {
|
|
79
|
+
...result,
|
|
80
|
+
domElementType: polymorphicPropValue.value
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
48
88
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("dom"));
|
|
49
89
|
|
|
50
90
|
// src/utils/find-custom-component.ts
|
|
51
|
-
function findCustomComponent(name3, components) {
|
|
52
|
-
return components.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
53
|
-
}
|
|
54
91
|
function findCustomComponentProp(name3, props) {
|
|
55
92
|
return props.findLast((a) => a.as === name3);
|
|
56
93
|
}
|
|
57
|
-
function getElementTypeOnJsxAndDom(context, node, polymorphicPropName, additionalComponents = []) {
|
|
58
|
-
const name3 = JSX.getElementType(node);
|
|
59
|
-
if (name3 === name3.toLowerCase()) return [name3, name3];
|
|
60
|
-
const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
|
|
61
|
-
if (component != null) return [name3, component.as];
|
|
62
|
-
if (polymorphicPropName == null) return [name3, name3];
|
|
63
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
64
|
-
const attributeNode = JSX.getAttribute(
|
|
65
|
-
polymorphicPropName,
|
|
66
|
-
node.openingElement.attributes,
|
|
67
|
-
initialScope
|
|
68
|
-
);
|
|
69
|
-
if (attributeNode == null) return [name3, name3];
|
|
70
|
-
const polymorphicPropValue = JSX.getAttributeValue(attributeNode, polymorphicPropName, initialScope);
|
|
71
|
-
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
72
|
-
return [name3, polymorphicPropValue.value];
|
|
73
|
-
}
|
|
74
|
-
return [name3, name3];
|
|
75
|
-
}
|
|
76
94
|
|
|
77
95
|
// src/rules/no-dangerously-set-innerhtml.ts
|
|
78
96
|
var RULE_NAME = "no-dangerously-set-innerhtml";
|
|
@@ -320,21 +338,13 @@ var no_missing_button_type_default = createRule({
|
|
|
320
338
|
defaultOptions: []
|
|
321
339
|
});
|
|
322
340
|
function create6(context) {
|
|
323
|
-
const
|
|
324
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
325
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
|
|
341
|
+
const resolver = createJsxElementResolver(context);
|
|
326
342
|
return {
|
|
327
343
|
JSXElement(node) {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
node,
|
|
331
|
-
polymorphicPropName,
|
|
332
|
-
additionalComponents
|
|
333
|
-
);
|
|
334
|
-
if (elementNameOnDom !== "button") return;
|
|
344
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
345
|
+
if (domElementType !== "button") return;
|
|
335
346
|
const elementScope = context.sourceCode.getScope(node);
|
|
336
|
-
const
|
|
337
|
-
const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
|
|
347
|
+
const customComponentProp = findCustomComponentProp("type", attributes);
|
|
338
348
|
const propNameOnJsx = customComponentProp?.name ?? "type";
|
|
339
349
|
const attributeNode = JSX.getAttribute(
|
|
340
350
|
propNameOnJsx,
|
|
@@ -401,21 +411,13 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
401
411
|
defaultOptions: []
|
|
402
412
|
});
|
|
403
413
|
function create7(context) {
|
|
404
|
-
const
|
|
405
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
406
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
|
|
414
|
+
const resolver = createJsxElementResolver(context);
|
|
407
415
|
return {
|
|
408
416
|
JSXElement(node) {
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
node,
|
|
412
|
-
polymorphicPropName,
|
|
413
|
-
additionalComponents
|
|
414
|
-
);
|
|
415
|
-
if (elementNameOnDom !== "iframe") return;
|
|
417
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
418
|
+
if (domElementType !== "iframe") return;
|
|
416
419
|
const elementScope = context.sourceCode.getScope(node);
|
|
417
|
-
const
|
|
418
|
-
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
420
|
+
const customComponentProp = findCustomComponentProp("sandbox", attributes);
|
|
419
421
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
420
422
|
const attributeNode = JSX.getAttribute(
|
|
421
423
|
propNameOnJsx,
|
|
@@ -1728,21 +1730,13 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1728
1730
|
defaultOptions: []
|
|
1729
1731
|
});
|
|
1730
1732
|
function create13(context) {
|
|
1731
|
-
const
|
|
1732
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
1733
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
|
|
1733
|
+
const resolver = createJsxElementResolver(context);
|
|
1734
1734
|
return {
|
|
1735
1735
|
JSXElement(node) {
|
|
1736
|
-
const
|
|
1737
|
-
|
|
1738
|
-
node,
|
|
1739
|
-
polymorphicPropName,
|
|
1740
|
-
additionalComponents
|
|
1741
|
-
);
|
|
1742
|
-
if (elementNameOnDom !== "iframe") return;
|
|
1736
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
1737
|
+
if (domElementType !== "iframe") return;
|
|
1743
1738
|
const elementScope = context.sourceCode.getScope(node);
|
|
1744
|
-
const
|
|
1745
|
-
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1739
|
+
const customComponentProp = findCustomComponentProp("sandbox", attributes);
|
|
1746
1740
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1747
1741
|
const attributeNode = JSX.getAttribute(
|
|
1748
1742
|
propNameOnJsx,
|
|
@@ -1797,22 +1791,14 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1797
1791
|
defaultOptions: []
|
|
1798
1792
|
});
|
|
1799
1793
|
function create14(context) {
|
|
1800
|
-
const
|
|
1801
|
-
const polymorphicPropName = settings2.polymorphicPropName;
|
|
1802
|
-
const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
|
|
1794
|
+
const resolver = createJsxElementResolver(context);
|
|
1803
1795
|
return {
|
|
1804
1796
|
JSXElement(node) {
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
node,
|
|
1808
|
-
polymorphicPropName,
|
|
1809
|
-
additionalComponents
|
|
1810
|
-
);
|
|
1811
|
-
if (elementNameOnDom !== "a") return;
|
|
1797
|
+
const { attributes, domElementType } = resolver.resolve(node);
|
|
1798
|
+
if (domElementType !== "a") return;
|
|
1812
1799
|
const elementScope = context.sourceCode.getScope(node);
|
|
1813
|
-
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1814
1800
|
const getAttributeStringValue = (name3) => {
|
|
1815
|
-
const customComponentProp = findCustomComponentProp(name3,
|
|
1801
|
+
const customComponentProp = findCustomComponentProp(name3, attributes);
|
|
1816
1802
|
const propNameOnJsx = customComponentProp?.name ?? name3;
|
|
1817
1803
|
const attributeNode = JSX.getAttribute(
|
|
1818
1804
|
propNameOnJsx,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "1.46.
|
|
3
|
+
"version": "1.46.1-next.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"compare-versions": "^6.1.1",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.7.0",
|
|
52
|
-
"@eslint-react/ast": "1.46.
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.46.1-next.0",
|
|
53
|
+
"@eslint-react/core": "1.46.1-next.0",
|
|
54
|
+
"@eslint-react/jsx": "1.46.1-next.0",
|
|
55
|
+
"@eslint-react/kit": "1.46.1-next.0",
|
|
56
|
+
"@eslint-react/shared": "1.46.1-next.0",
|
|
57
|
+
"@eslint-react/eff": "1.46.1-next.0",
|
|
58
|
+
"@eslint-react/var": "1.46.1-next.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.1.1",
|