eslint-plugin-react-dom 1.24.0-next.11 → 1.24.0-next.12
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 +47 -47
- package/dist/index.mjs +47 -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.12";
|
|
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(polymorphicPropName, attributeNode, 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(propNameOnJsx, attributeNode, 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(propNameOnJsx, attributeNode, 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,9 @@ var no_script_url_default = createRule({
|
|
|
433
430
|
return;
|
|
434
431
|
}
|
|
435
432
|
const attributeScope = context.sourceCode.getScope(node);
|
|
436
|
-
const attributeValue = JSX__namespace.
|
|
437
|
-
|
|
438
|
-
if (
|
|
439
|
-
if (shared.RE_JAVASCRIPT_PROTOCOL.test(attributeValueResolved)) {
|
|
433
|
+
const attributeValue = JSX__namespace.getAttributeValue(JSX__namespace.toString(node.name), node, attributeScope);
|
|
434
|
+
if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
|
|
435
|
+
if (shared.RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
|
|
440
436
|
context.report({
|
|
441
437
|
messageId: "noScriptUrl",
|
|
442
438
|
node: node.value
|
|
@@ -1511,8 +1507,8 @@ var RULE_FEATURES9 = [
|
|
|
1511
1507
|
var unsafeSandboxValues = [
|
|
1512
1508
|
["allow-scripts", "allow-same-origin"]
|
|
1513
1509
|
];
|
|
1514
|
-
function
|
|
1515
|
-
if (value
|
|
1510
|
+
function hasSafeSandbox(value) {
|
|
1511
|
+
if (typeof value !== "string") return false;
|
|
1516
1512
|
return !unsafeSandboxValues.some((values) => {
|
|
1517
1513
|
return values.every((v) => value.includes(v));
|
|
1518
1514
|
});
|
|
@@ -1537,7 +1533,7 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1537
1533
|
return {
|
|
1538
1534
|
JSXElement(node) {
|
|
1539
1535
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1540
|
-
node
|
|
1536
|
+
node,
|
|
1541
1537
|
context,
|
|
1542
1538
|
polymorphicPropName,
|
|
1543
1539
|
additionalComponents
|
|
@@ -1547,23 +1543,24 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1547
1543
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1548
1544
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1549
1545
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1550
|
-
const attributeNode = JSX__namespace.
|
|
1546
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
1551
1547
|
propNameOnJsx,
|
|
1552
1548
|
elementScope,
|
|
1553
1549
|
node.openingElement.attributes
|
|
1554
1550
|
);
|
|
1555
1551
|
if (attributeNode != null) {
|
|
1556
1552
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1553
|
+
const attributeValue = JSX__namespace.getAttributeValue(propNameOnJsx, attributeNode, attributeScope);
|
|
1554
|
+
if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
|
|
1555
|
+
context.report({
|
|
1556
|
+
messageId: "noUnsafeIframeSandbox",
|
|
1557
|
+
node: attributeNode
|
|
1558
|
+
});
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1565
1561
|
}
|
|
1566
|
-
if (
|
|
1562
|
+
if (customComponentProp?.defaultValue == null) return;
|
|
1563
|
+
if (!hasSafeSandbox(customComponentProp.defaultValue)) {
|
|
1567
1564
|
context.report({
|
|
1568
1565
|
messageId: "noUnsafeIframeSandbox",
|
|
1569
1566
|
node
|
|
@@ -1606,7 +1603,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1606
1603
|
return {
|
|
1607
1604
|
JSXElement(node) {
|
|
1608
1605
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1609
|
-
node
|
|
1606
|
+
node,
|
|
1610
1607
|
context,
|
|
1611
1608
|
polymorphicPropName,
|
|
1612
1609
|
additionalComponents
|
|
@@ -1614,26 +1611,29 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1614
1611
|
if (elementNameOnDom !== "a") return;
|
|
1615
1612
|
const elementScope = context.sourceCode.getScope(node);
|
|
1616
1613
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1617
|
-
const
|
|
1614
|
+
const getAttributeStringValue = (name2) => {
|
|
1618
1615
|
const customComponentProp = findCustomComponentProp(name2, customComponent?.attributes ?? []);
|
|
1619
1616
|
const propNameOnJsx = customComponentProp?.name ?? name2;
|
|
1620
|
-
const attributeNode = JSX__namespace.
|
|
1617
|
+
const attributeNode = JSX__namespace.getAttribute(
|
|
1621
1618
|
propNameOnJsx,
|
|
1622
1619
|
elementScope,
|
|
1623
1620
|
node.openingElement.attributes
|
|
1624
1621
|
);
|
|
1625
1622
|
if (attributeNode == null) return customComponentProp?.defaultValue;
|
|
1626
1623
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1624
|
+
const attributeValue = JSX__namespace.getAttributeValue(propNameOnJsx, attributeNode, attributeScope);
|
|
1625
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
|
|
1626
|
+
return attributeValue.value;
|
|
1627
|
+
}
|
|
1628
|
+
return eff._;
|
|
1629
1629
|
};
|
|
1630
|
-
if (
|
|
1630
|
+
if (getAttributeStringValue("target") !== "_blank") {
|
|
1631
1631
|
return;
|
|
1632
1632
|
}
|
|
1633
|
-
if (!isExternalLinkLike(
|
|
1633
|
+
if (!isExternalLinkLike(getAttributeStringValue("href"))) {
|
|
1634
1634
|
return;
|
|
1635
1635
|
}
|
|
1636
|
-
if (isSafeRel(
|
|
1636
|
+
if (isSafeRel(getAttributeStringValue("rel"))) {
|
|
1637
1637
|
return;
|
|
1638
1638
|
}
|
|
1639
1639
|
context.report({
|
|
@@ -1683,7 +1683,7 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1683
1683
|
create(context) {
|
|
1684
1684
|
return {
|
|
1685
1685
|
JSXElement(node) {
|
|
1686
|
-
const elementName = JSX__namespace.getElementName(node
|
|
1686
|
+
const elementName = JSX__namespace.getElementName(node);
|
|
1687
1687
|
if (elementName.length === 0 || !voidElements.has(elementName)) {
|
|
1688
1688
|
return;
|
|
1689
1689
|
}
|
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.12";
|
|
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(polymorphicPropName, attributeNode, 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(propNameOnJsx, attributeNode, 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(propNameOnJsx, attributeNode, 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,9 @@ var no_script_url_default = createRule({
|
|
|
409
407
|
return;
|
|
410
408
|
}
|
|
411
409
|
const attributeScope = context.sourceCode.getScope(node);
|
|
412
|
-
const attributeValue = JSX.
|
|
413
|
-
|
|
414
|
-
if (
|
|
415
|
-
if (RE_JAVASCRIPT_PROTOCOL.test(attributeValueResolved)) {
|
|
410
|
+
const attributeValue = JSX.getAttributeValue(JSX.toString(node.name), node, attributeScope);
|
|
411
|
+
if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
|
|
412
|
+
if (RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
|
|
416
413
|
context.report({
|
|
417
414
|
messageId: "noScriptUrl",
|
|
418
415
|
node: node.value
|
|
@@ -1487,8 +1484,8 @@ var RULE_FEATURES9 = [
|
|
|
1487
1484
|
var unsafeSandboxValues = [
|
|
1488
1485
|
["allow-scripts", "allow-same-origin"]
|
|
1489
1486
|
];
|
|
1490
|
-
function
|
|
1491
|
-
if (value
|
|
1487
|
+
function hasSafeSandbox(value) {
|
|
1488
|
+
if (typeof value !== "string") return false;
|
|
1492
1489
|
return !unsafeSandboxValues.some((values) => {
|
|
1493
1490
|
return values.every((v) => value.includes(v));
|
|
1494
1491
|
});
|
|
@@ -1513,7 +1510,7 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1513
1510
|
return {
|
|
1514
1511
|
JSXElement(node) {
|
|
1515
1512
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1516
|
-
node
|
|
1513
|
+
node,
|
|
1517
1514
|
context,
|
|
1518
1515
|
polymorphicPropName,
|
|
1519
1516
|
additionalComponents
|
|
@@ -1523,23 +1520,24 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1523
1520
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1524
1521
|
const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
|
|
1525
1522
|
const propNameOnJsx = customComponentProp?.name ?? "sandbox";
|
|
1526
|
-
const attributeNode = JSX.
|
|
1523
|
+
const attributeNode = JSX.getAttribute(
|
|
1527
1524
|
propNameOnJsx,
|
|
1528
1525
|
elementScope,
|
|
1529
1526
|
node.openingElement.attributes
|
|
1530
1527
|
);
|
|
1531
1528
|
if (attributeNode != null) {
|
|
1532
1529
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1530
|
+
const attributeValue = JSX.getAttributeValue(propNameOnJsx, attributeNode, attributeScope);
|
|
1531
|
+
if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
|
|
1532
|
+
context.report({
|
|
1533
|
+
messageId: "noUnsafeIframeSandbox",
|
|
1534
|
+
node: attributeNode
|
|
1535
|
+
});
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1541
1538
|
}
|
|
1542
|
-
if (
|
|
1539
|
+
if (customComponentProp?.defaultValue == null) return;
|
|
1540
|
+
if (!hasSafeSandbox(customComponentProp.defaultValue)) {
|
|
1543
1541
|
context.report({
|
|
1544
1542
|
messageId: "noUnsafeIframeSandbox",
|
|
1545
1543
|
node
|
|
@@ -1582,7 +1580,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1582
1580
|
return {
|
|
1583
1581
|
JSXElement(node) {
|
|
1584
1582
|
const [elementNameOnJsx, elementNameOnDom] = getElementNameOnJsxAndDom(
|
|
1585
|
-
node
|
|
1583
|
+
node,
|
|
1586
1584
|
context,
|
|
1587
1585
|
polymorphicPropName,
|
|
1588
1586
|
additionalComponents
|
|
@@ -1590,26 +1588,29 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1590
1588
|
if (elementNameOnDom !== "a") return;
|
|
1591
1589
|
const elementScope = context.sourceCode.getScope(node);
|
|
1592
1590
|
const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
|
|
1593
|
-
const
|
|
1591
|
+
const getAttributeStringValue = (name2) => {
|
|
1594
1592
|
const customComponentProp = findCustomComponentProp(name2, customComponent?.attributes ?? []);
|
|
1595
1593
|
const propNameOnJsx = customComponentProp?.name ?? name2;
|
|
1596
|
-
const attributeNode = JSX.
|
|
1594
|
+
const attributeNode = JSX.getAttribute(
|
|
1597
1595
|
propNameOnJsx,
|
|
1598
1596
|
elementScope,
|
|
1599
1597
|
node.openingElement.attributes
|
|
1600
1598
|
);
|
|
1601
1599
|
if (attributeNode == null) return customComponentProp?.defaultValue;
|
|
1602
1600
|
const attributeScope = context.sourceCode.getScope(attributeNode);
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1601
|
+
const attributeValue = JSX.getAttributeValue(propNameOnJsx, attributeNode, attributeScope);
|
|
1602
|
+
if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
|
|
1603
|
+
return attributeValue.value;
|
|
1604
|
+
}
|
|
1605
|
+
return _;
|
|
1605
1606
|
};
|
|
1606
|
-
if (
|
|
1607
|
+
if (getAttributeStringValue("target") !== "_blank") {
|
|
1607
1608
|
return;
|
|
1608
1609
|
}
|
|
1609
|
-
if (!isExternalLinkLike(
|
|
1610
|
+
if (!isExternalLinkLike(getAttributeStringValue("href"))) {
|
|
1610
1611
|
return;
|
|
1611
1612
|
}
|
|
1612
|
-
if (isSafeRel(
|
|
1613
|
+
if (isSafeRel(getAttributeStringValue("rel"))) {
|
|
1613
1614
|
return;
|
|
1614
1615
|
}
|
|
1615
1616
|
context.report({
|
|
@@ -1659,7 +1660,7 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1659
1660
|
create(context) {
|
|
1660
1661
|
return {
|
|
1661
1662
|
JSXElement(node) {
|
|
1662
|
-
const elementName = JSX.getElementName(node
|
|
1663
|
+
const elementName = JSX.getElementName(node);
|
|
1663
1664
|
if (elementName.length === 0 || !voidElements.has(elementName)) {
|
|
1664
1665
|
return;
|
|
1665
1666
|
}
|
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.12",
|
|
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/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
50
|
+
"@eslint-react/ast": "1.24.0-next.12",
|
|
51
|
+
"@eslint-react/core": "1.24.0-next.12",
|
|
52
|
+
"@eslint-react/eff": "1.24.0-next.12",
|
|
53
|
+
"@eslint-react/jsx": "1.24.0-next.12",
|
|
54
|
+
"@eslint-react/shared": "1.24.0-next.12",
|
|
55
|
+
"@eslint-react/var": "1.24.0-next.12"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/react": "^19.0.7",
|