eslint-plugin-react-dom 1.24.0-next.11 → 1.24.0-next.13
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 +48 -47
- package/dist/index.mjs +48 -46
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var JSX = require('@eslint-react/jsx');
|
|
4
4
|
var shared = require('@eslint-react/shared');
|
|
5
|
-
var VAR = require('@eslint-react/var');
|
|
6
5
|
var types = require('@typescript-eslint/types');
|
|
7
6
|
var AST = require('@eslint-react/ast');
|
|
8
7
|
var compareVersions = require('compare-versions');
|
|
8
|
+
var eff = require('@eslint-react/eff');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
11
11
|
if (e && e.__esModule) return e;
|
|
@@ -26,12 +26,11 @@ function _interopNamespace(e) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
var JSX__namespace = /*#__PURE__*/_interopNamespace(JSX);
|
|
29
|
-
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
30
29
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
31
30
|
|
|
32
31
|
// package.json
|
|
33
32
|
var name = "eslint-plugin-react-dom";
|
|
34
|
-
var version = "1.24.0-next.
|
|
33
|
+
var version = "1.24.0-next.13";
|
|
35
34
|
var createRule = shared.createRuleForPlugin("dom");
|
|
36
35
|
|
|
37
36
|
// src/utils/find-custom-component.ts
|
|
@@ -48,15 +47,15 @@ function getElementNameOnJsxAndDom(node, context, polymorphicPropName, additiona
|
|
|
48
47
|
if (component != null) return [name2, component.as];
|
|
49
48
|
if (polymorphicPropName == null) return [name2, name2];
|
|
50
49
|
const initialScope = context.sourceCode.getScope(node);
|
|
51
|
-
const attributeNode = JSX__namespace.
|
|
50
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
52
51
|
polymorphicPropName,
|
|
53
52
|
initialScope,
|
|
54
|
-
node.attributes
|
|
53
|
+
node.openingElement.attributes
|
|
55
54
|
);
|
|
56
55
|
if (attributeNode == null) return [name2, name2];
|
|
57
|
-
const polymorphicPropValue =
|
|
58
|
-
if (typeof polymorphicPropValue === "string") {
|
|
59
|
-
return [name2, polymorphicPropValue];
|
|
56
|
+
const polymorphicPropValue = JSX__namespace.getAttributeValue(attributeNode, polymorphicPropName, initialScope);
|
|
57
|
+
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
58
|
+
return [name2, polymorphicPropValue.value];
|
|
60
59
|
}
|
|
61
60
|
return [name2, name2];
|
|
62
61
|
}
|
|
@@ -84,7 +83,7 @@ var no_dangerously_set_innerhtml_default = createRule({
|
|
|
84
83
|
return {
|
|
85
84
|
JSXElement(node) {
|
|
86
85
|
const attributes = node.openingElement.attributes;
|
|
87
|
-
const attribute = JSX__namespace.
|
|
86
|
+
const attribute = JSX__namespace.getAttribute(
|
|
88
87
|
"dangerouslySetInnerHTML",
|
|
89
88
|
context.sourceCode.getScope(node),
|
|
90
89
|
attributes
|
|
@@ -200,7 +199,7 @@ var no_missing_button_type_default = createRule({
|
|
|
200
199
|
return {
|
|
201
200
|
JSXElement(node) {
|
|
202
201
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
203
|
-
node
|
|
202
|
+
node,
|
|
204
203
|
context,
|
|
205
204
|
polymorphicPropName,
|
|
206
205
|
additionalComponents
|
|
@@ -210,16 +209,15 @@ var no_missing_button_type_default = createRule({
|
|
|
210
209
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
211
210
|
const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
|
|
212
211
|
const propNameOnJsx = customComponentProp?.name ?? "type";
|
|
213
|
-
const attributeNode = JSX__namespace.
|
|
212
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
214
213
|
propNameOnJsx,
|
|
215
214
|
elementScope,
|
|
216
215
|
node.openingElement.attributes
|
|
217
216
|
);
|
|
218
217
|
if (attributeNode != null) {
|
|
219
218
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
if (typeof attributeStringValue !== "string") {
|
|
219
|
+
const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
220
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
|
|
223
221
|
context.report({
|
|
224
222
|
messageId: "noMissingButtonType",
|
|
225
223
|
node: attributeNode
|
|
@@ -283,7 +281,7 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
283
281
|
return {
|
|
284
282
|
JSXElement(node) {
|
|
285
283
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
286
|
-
node
|
|
284
|
+
node,
|
|
287
285
|
context,
|
|
288
286
|
polymorphicPropName,
|
|
289
287
|
additionalComponents
|
|
@@ -293,16 +291,15 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
293
291
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
294
292
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
295
293
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
296
|
-
const attributeNode = JSX__namespace.
|
|
294
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
297
295
|
propNameOnJsx,
|
|
298
296
|
elementScope,
|
|
299
297
|
node.openingElement.attributes
|
|
300
298
|
);
|
|
301
299
|
if (attributeNode != null) {
|
|
302
300
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
if (hasValidSandBox(attributeStringValue)) return;
|
|
301
|
+
const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
302
|
+
if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
|
|
306
303
|
context.report({
|
|
307
304
|
messageId: "noMissingIframeSandbox",
|
|
308
305
|
node: attributeNode
|
|
@@ -339,14 +336,14 @@ var no_namespace_default = createRule({
|
|
|
339
336
|
name: RULE_NAME6,
|
|
340
337
|
create(context) {
|
|
341
338
|
return {
|
|
342
|
-
|
|
339
|
+
JSXElement(node) {
|
|
343
340
|
const name2 = JSX__namespace.getElementName(node);
|
|
344
341
|
if (typeof name2 !== "string" || !name2.includes(":")) {
|
|
345
342
|
return;
|
|
346
343
|
}
|
|
347
344
|
context.report({
|
|
348
345
|
messageId: "noNamespace",
|
|
349
|
-
node,
|
|
346
|
+
node: node.openingElement.name,
|
|
350
347
|
data: {
|
|
351
348
|
name: name2
|
|
352
349
|
}
|
|
@@ -433,10 +430,10 @@ var no_script_url_default = createRule({
|
|
|
433
430
|
return;
|
|
434
431
|
}
|
|
435
432
|
const attributeScope = context.sourceCode.getScope(node);
|
|
436
|
-
const
|
|
437
|
-
const
|
|
438
|
-
if (typeof
|
|
439
|
-
if (shared.RE_JAVASCRIPT_PROTOCOL.test(
|
|
433
|
+
const attributeName = JSX__namespace.getAttributeName(node);
|
|
434
|
+
const attributeValue = JSX__namespace.getAttributeValue(node, attributeName, attributeScope);
|
|
435
|
+
if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
|
|
436
|
+
if (shared.RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
|
|
440
437
|
context.report({
|
|
441
438
|
messageId: "noScriptUrl",
|
|
442
439
|
node: node.value
|
|
@@ -1511,8 +1508,8 @@ var RULE_FEATURES9 = [
|
|
|
1511
1508
|
var unsafeSandboxValues = [
|
|
1512
1509
|
["allow-scripts", "allow-same-origin"]
|
|
1513
1510
|
];
|
|
1514
|
-
function
|
|
1515
|
-
if (value
|
|
1511
|
+
function hasSafeSandbox(value) {
|
|
1512
|
+
if (typeof value !== "string") return false;
|
|
1516
1513
|
return !unsafeSandboxValues.some((values) => {
|
|
1517
1514
|
return values.every((v) => value.includes(v));
|
|
1518
1515
|
});
|
|
@@ -1537,7 +1534,7 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1537
1534
|
return {
|
|
1538
1535
|
JSXElement(node) {
|
|
1539
1536
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1540
|
-
node
|
|
1537
|
+
node,
|
|
1541
1538
|
context,
|
|
1542
1539
|
polymorphicPropName,
|
|
1543
1540
|
additionalComponents
|
|
@@ -1547,23 +1544,24 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1547
1544
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1548
1545
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1549
1546
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1550
|
-
const attributeNode = JSX__namespace.
|
|
1547
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
1551
1548
|
propNameOnJsx,
|
|
1552
1549
|
elementScope,
|
|
1553
1550
|
node.openingElement.attributes
|
|
1554
1551
|
);
|
|
1555
1552
|
if (attributeNode != null) {
|
|
1556
1553
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1554
|
+
const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
1555
|
+
if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
|
|
1556
|
+
context.report({
|
|
1557
|
+
messageId: "noUnsafeIframeSandbox",
|
|
1558
|
+
node: attributeNode
|
|
1559
|
+
});
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1565
1562
|
}
|
|
1566
|
-
if (
|
|
1563
|
+
if (customComponentProp?.defaultValue == null) return;
|
|
1564
|
+
if (!hasSafeSandbox(customComponentProp.defaultValue)) {
|
|
1567
1565
|
context.report({
|
|
1568
1566
|
messageId: "noUnsafeIframeSandbox",
|
|
1569
1567
|
node
|
|
@@ -1606,7 +1604,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1606
1604
|
return {
|
|
1607
1605
|
JSXElement(node) {
|
|
1608
1606
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1609
|
-
node
|
|
1607
|
+
node,
|
|
1610
1608
|
context,
|
|
1611
1609
|
polymorphicPropName,
|
|
1612
1610
|
additionalComponents
|
|
@@ -1614,26 +1612,29 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1614
1612
|
if (elementNameOnDom !== "a") return;
|
|
1615
1613
|
const elementScope = context.sourceCode.getScope(node);
|
|
1616
1614
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1617
|
-
const
|
|
1615
|
+
const getAttributeStringValue = (name2) => {
|
|
1618
1616
|
const customComponentProp = findCustomComponentProp(name2, customComponent?.attributes ?? []);
|
|
1619
1617
|
const propNameOnJsx = customComponentProp?.name ?? name2;
|
|
1620
|
-
const attributeNode = JSX__namespace.
|
|
1618
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
1621
1619
|
propNameOnJsx,
|
|
1622
1620
|
elementScope,
|
|
1623
1621
|
node.openingElement.attributes
|
|
1624
1622
|
);
|
|
1625
1623
|
if (attributeNode == null) return customComponentProp?.defaultValue;
|
|
1626
1624
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1625
|
+
const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
1626
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
|
|
1627
|
+
return attributeValue.value;
|
|
1628
|
+
}
|
|
1629
|
+
return eff._;
|
|
1629
1630
|
};
|
|
1630
|
-
if (
|
|
1631
|
+
if (getAttributeStringValue("target") !== "_blank") {
|
|
1631
1632
|
return;
|
|
1632
1633
|
}
|
|
1633
|
-
if (!isExternalLinkLike(
|
|
1634
|
+
if (!isExternalLinkLike(getAttributeStringValue("href"))) {
|
|
1634
1635
|
return;
|
|
1635
1636
|
}
|
|
1636
|
-
if (isSafeRel(
|
|
1637
|
+
if (isSafeRel(getAttributeStringValue("rel"))) {
|
|
1637
1638
|
return;
|
|
1638
1639
|
}
|
|
1639
1640
|
context.report({
|
|
@@ -1683,7 +1684,7 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1683
1684
|
create(context) {
|
|
1684
1685
|
return {
|
|
1685
1686
|
JSXElement(node) {
|
|
1686
|
-
const elementName = JSX__namespace.getElementName(node
|
|
1687
|
+
const elementName = JSX__namespace.getElementName(node);
|
|
1687
1688
|
if (elementName.length === 0 || !voidElements.has(elementName)) {
|
|
1688
1689
|
return;
|
|
1689
1690
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as JSX from '@eslint-react/jsx';
|
|
2
2
|
import { createRuleForPlugin, getSettingsFromContext, RE_JAVASCRIPT_PROTOCOL } from '@eslint-react/shared';
|
|
3
|
-
import * as VAR from '@eslint-react/var';
|
|
4
3
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
4
|
import * as AST from '@eslint-react/ast';
|
|
6
5
|
import { compare } from 'compare-versions';
|
|
6
|
+
import { _ } from '@eslint-react/eff';
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
9
|
var name = "eslint-plugin-react-dom";
|
|
10
|
-
var version = "1.24.0-next.
|
|
10
|
+
var version = "1.24.0-next.13";
|
|
11
11
|
var createRule = createRuleForPlugin("dom");
|
|
12
12
|
|
|
13
13
|
// src/utils/find-custom-component.ts
|
|
@@ -24,15 +24,15 @@ function getElementNameOnJsxAndDom(node, context, polymorphicPropName, additiona
|
|
|
24
24
|
if (component != null) return [name2, component.as];
|
|
25
25
|
if (polymorphicPropName == null) return [name2, name2];
|
|
26
26
|
const initialScope = context.sourceCode.getScope(node);
|
|
27
|
-
const attributeNode = JSX.
|
|
27
|
+
const attributeNode = JSX.getAttribute(
|
|
28
28
|
polymorphicPropName,
|
|
29
29
|
initialScope,
|
|
30
|
-
node.attributes
|
|
30
|
+
node.openingElement.attributes
|
|
31
31
|
);
|
|
32
32
|
if (attributeNode == null) return [name2, name2];
|
|
33
|
-
const polymorphicPropValue =
|
|
34
|
-
if (typeof polymorphicPropValue === "string") {
|
|
35
|
-
return [name2, polymorphicPropValue];
|
|
33
|
+
const polymorphicPropValue = JSX.getAttributeValue(attributeNode, polymorphicPropName, initialScope);
|
|
34
|
+
if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
|
|
35
|
+
return [name2, polymorphicPropValue.value];
|
|
36
36
|
}
|
|
37
37
|
return [name2, name2];
|
|
38
38
|
}
|
|
@@ -60,7 +60,7 @@ var no_dangerously_set_innerhtml_default = createRule({
|
|
|
60
60
|
return {
|
|
61
61
|
JSXElement(node) {
|
|
62
62
|
const attributes = node.openingElement.attributes;
|
|
63
|
-
const attribute = JSX.
|
|
63
|
+
const attribute = JSX.getAttribute(
|
|
64
64
|
"dangerouslySetInnerHTML",
|
|
65
65
|
context.sourceCode.getScope(node),
|
|
66
66
|
attributes
|
|
@@ -176,7 +176,7 @@ var no_missing_button_type_default = createRule({
|
|
|
176
176
|
return {
|
|
177
177
|
JSXElement(node) {
|
|
178
178
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
179
|
-
node
|
|
179
|
+
node,
|
|
180
180
|
context,
|
|
181
181
|
polymorphicPropName,
|
|
182
182
|
additionalComponents
|
|
@@ -186,16 +186,15 @@ var no_missing_button_type_default = createRule({
|
|
|
186
186
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
187
187
|
const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
|
|
188
188
|
const propNameOnJsx = customComponentProp?.name ?? "type";
|
|
189
|
-
const attributeNode = JSX.
|
|
189
|
+
const attributeNode = JSX.getAttribute(
|
|
190
190
|
propNameOnJsx,
|
|
191
191
|
elementScope,
|
|
192
192
|
node.openingElement.attributes
|
|
193
193
|
);
|
|
194
194
|
if (attributeNode != null) {
|
|
195
195
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
if (typeof attributeStringValue !== "string") {
|
|
196
|
+
const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
197
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
|
|
199
198
|
context.report({
|
|
200
199
|
messageId: "noMissingButtonType",
|
|
201
200
|
node: attributeNode
|
|
@@ -259,7 +258,7 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
259
258
|
return {
|
|
260
259
|
JSXElement(node) {
|
|
261
260
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
262
|
-
node
|
|
261
|
+
node,
|
|
263
262
|
context,
|
|
264
263
|
polymorphicPropName,
|
|
265
264
|
additionalComponents
|
|
@@ -269,16 +268,15 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
269
268
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
270
269
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
271
270
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
272
|
-
const attributeNode = JSX.
|
|
271
|
+
const attributeNode = JSX.getAttribute(
|
|
273
272
|
propNameOnJsx,
|
|
274
273
|
elementScope,
|
|
275
274
|
node.openingElement.attributes
|
|
276
275
|
);
|
|
277
276
|
if (attributeNode != null) {
|
|
278
277
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
if (hasValidSandBox(attributeStringValue)) return;
|
|
278
|
+
const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
279
|
+
if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
|
|
282
280
|
context.report({
|
|
283
281
|
messageId: "noMissingIframeSandbox",
|
|
284
282
|
node: attributeNode
|
|
@@ -315,14 +313,14 @@ var no_namespace_default = createRule({
|
|
|
315
313
|
name: RULE_NAME6,
|
|
316
314
|
create(context) {
|
|
317
315
|
return {
|
|
318
|
-
|
|
316
|
+
JSXElement(node) {
|
|
319
317
|
const name2 = JSX.getElementName(node);
|
|
320
318
|
if (typeof name2 !== "string" || !name2.includes(":")) {
|
|
321
319
|
return;
|
|
322
320
|
}
|
|
323
321
|
context.report({
|
|
324
322
|
messageId: "noNamespace",
|
|
325
|
-
node,
|
|
323
|
+
node: node.openingElement.name,
|
|
326
324
|
data: {
|
|
327
325
|
name: name2
|
|
328
326
|
}
|
|
@@ -409,10 +407,10 @@ var no_script_url_default = createRule({
|
|
|
409
407
|
return;
|
|
410
408
|
}
|
|
411
409
|
const attributeScope = context.sourceCode.getScope(node);
|
|
412
|
-
const
|
|
413
|
-
const
|
|
414
|
-
if (typeof
|
|
415
|
-
if (RE_JAVASCRIPT_PROTOCOL.test(
|
|
410
|
+
const attributeName = JSX.getAttributeName(node);
|
|
411
|
+
const attributeValue = JSX.getAttributeValue(node, attributeName, attributeScope);
|
|
412
|
+
if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
|
|
413
|
+
if (RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
|
|
416
414
|
context.report({
|
|
417
415
|
messageId: "noScriptUrl",
|
|
418
416
|
node: node.value
|
|
@@ -1487,8 +1485,8 @@ var RULE_FEATURES9 = [
|
|
|
1487
1485
|
var unsafeSandboxValues = [
|
|
1488
1486
|
["allow-scripts", "allow-same-origin"]
|
|
1489
1487
|
];
|
|
1490
|
-
function
|
|
1491
|
-
if (value
|
|
1488
|
+
function hasSafeSandbox(value) {
|
|
1489
|
+
if (typeof value !== "string") return false;
|
|
1492
1490
|
return !unsafeSandboxValues.some((values) => {
|
|
1493
1491
|
return values.every((v) => value.includes(v));
|
|
1494
1492
|
});
|
|
@@ -1513,7 +1511,7 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1513
1511
|
return {
|
|
1514
1512
|
JSXElement(node) {
|
|
1515
1513
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1516
|
-
node
|
|
1514
|
+
node,
|
|
1517
1515
|
context,
|
|
1518
1516
|
polymorphicPropName,
|
|
1519
1517
|
additionalComponents
|
|
@@ -1523,23 +1521,24 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1523
1521
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1524
1522
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1525
1523
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1526
|
-
const attributeNode = JSX.
|
|
1524
|
+
const attributeNode = JSX.getAttribute(
|
|
1527
1525
|
propNameOnJsx,
|
|
1528
1526
|
elementScope,
|
|
1529
1527
|
node.openingElement.attributes
|
|
1530
1528
|
);
|
|
1531
1529
|
if (attributeNode != null) {
|
|
1532
1530
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1531
|
+
const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
1532
|
+
if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
|
|
1533
|
+
context.report({
|
|
1534
|
+
messageId: "noUnsafeIframeSandbox",
|
|
1535
|
+
node: attributeNode
|
|
1536
|
+
});
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1541
1539
|
}
|
|
1542
|
-
if (
|
|
1540
|
+
if (customComponentProp?.defaultValue == null) return;
|
|
1541
|
+
if (!hasSafeSandbox(customComponentProp.defaultValue)) {
|
|
1543
1542
|
context.report({
|
|
1544
1543
|
messageId: "noUnsafeIframeSandbox",
|
|
1545
1544
|
node
|
|
@@ -1582,7 +1581,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1582
1581
|
return {
|
|
1583
1582
|
JSXElement(node) {
|
|
1584
1583
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1585
|
-
node
|
|
1584
|
+
node,
|
|
1586
1585
|
context,
|
|
1587
1586
|
polymorphicPropName,
|
|
1588
1587
|
additionalComponents
|
|
@@ -1590,26 +1589,29 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1590
1589
|
if (elementNameOnDom !== "a") return;
|
|
1591
1590
|
const elementScope = context.sourceCode.getScope(node);
|
|
1592
1591
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1593
|
-
const
|
|
1592
|
+
const getAttributeStringValue = (name2) => {
|
|
1594
1593
|
const customComponentProp = findCustomComponentProp(name2, customComponent?.attributes ?? []);
|
|
1595
1594
|
const propNameOnJsx = customComponentProp?.name ?? name2;
|
|
1596
|
-
const attributeNode = JSX.
|
|
1595
|
+
const attributeNode = JSX.getAttribute(
|
|
1597
1596
|
propNameOnJsx,
|
|
1598
1597
|
elementScope,
|
|
1599
1598
|
node.openingElement.attributes
|
|
1600
1599
|
);
|
|
1601
1600
|
if (attributeNode == null) return customComponentProp?.defaultValue;
|
|
1602
1601
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1602
|
+
const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
|
|
1603
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
|
|
1604
|
+
return attributeValue.value;
|
|
1605
|
+
}
|
|
1606
|
+
return _;
|
|
1605
1607
|
};
|
|
1606
|
-
if (
|
|
1608
|
+
if (getAttributeStringValue("target") !== "_blank") {
|
|
1607
1609
|
return;
|
|
1608
1610
|
}
|
|
1609
|
-
if (!isExternalLinkLike(
|
|
1611
|
+
if (!isExternalLinkLike(getAttributeStringValue("href"))) {
|
|
1610
1612
|
return;
|
|
1611
1613
|
}
|
|
1612
|
-
if (isSafeRel(
|
|
1614
|
+
if (isSafeRel(getAttributeStringValue("rel"))) {
|
|
1613
1615
|
return;
|
|
1614
1616
|
}
|
|
1615
1617
|
context.report({
|
|
@@ -1659,7 +1661,7 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1659
1661
|
create(context) {
|
|
1660
1662
|
return {
|
|
1661
1663
|
JSXElement(node) {
|
|
1662
|
-
const elementName = JSX.getElementName(node
|
|
1664
|
+
const elementName = JSX.getElementName(node);
|
|
1663
1665
|
if (elementName.length === 0 || !voidElements.has(elementName)) {
|
|
1664
1666
|
return;
|
|
1665
1667
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.13",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"compare-versions": "^6.1.1",
|
|
48
48
|
"string-ts": "^2.2.0",
|
|
49
49
|
"ts-pattern": "^5.6.0",
|
|
50
|
-
"@eslint-react/ast": "1.24.0-next.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/jsx": "1.24.0-next.
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
50
|
+
"@eslint-react/ast": "1.24.0-next.13",
|
|
51
|
+
"@eslint-react/core": "1.24.0-next.13",
|
|
52
|
+
"@eslint-react/jsx": "1.24.0-next.13",
|
|
53
|
+
"@eslint-react/shared": "1.24.0-next.13",
|
|
54
|
+
"@eslint-react/eff": "1.24.0-next.13",
|
|
55
|
+
"@eslint-react/var": "1.24.0-next.13"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/react": "^19.0.7",
|