eslint-plugin-react-dom 1.17.4-next.5 → 1.17.4-next.9
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 +11 -22
- package/dist/index.mjs +11 -22
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var core = require('@eslint-react/core');
|
|
3
4
|
var JSX9 = require('@eslint-react/jsx');
|
|
4
|
-
var shared = require('@eslint-react/shared');
|
|
5
5
|
var tools = require('@eslint-react/tools');
|
|
6
|
+
var shared = require('@eslint-react/shared');
|
|
6
7
|
var types = require('@typescript-eslint/types');
|
|
7
8
|
var AST = require('@eslint-react/ast');
|
|
8
9
|
var compareVersions = require('compare-versions');
|
|
@@ -31,7 +32,7 @@ var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
|
31
32
|
|
|
32
33
|
// package.json
|
|
33
34
|
var name = "eslint-plugin-react-dom";
|
|
34
|
-
var version = "1.17.4-next.
|
|
35
|
+
var version = "1.17.4-next.9";
|
|
35
36
|
var createRule = shared.createRuleForPlugin("dom");
|
|
36
37
|
function findAttrInCustomAttributes(name2, attributes) {
|
|
37
38
|
return tools.F.pipe(
|
|
@@ -74,12 +75,9 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
74
75
|
},
|
|
75
76
|
name: RULE_NAME,
|
|
76
77
|
create(context) {
|
|
77
|
-
const { components, polymorphicPropName } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
78
78
|
return {
|
|
79
79
|
JSXElement(node) {
|
|
80
|
-
const
|
|
81
|
-
const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
|
|
82
|
-
const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(openingElementNameExpression);
|
|
80
|
+
const elementType = core.getElementType(node.openingElement, context);
|
|
83
81
|
if (!elementType || !voidElements.has(elementType)) return;
|
|
84
82
|
if (node.children.length > 0) {
|
|
85
83
|
context.report({
|
|
@@ -221,11 +219,9 @@ var no_missing_button_type_default = createRule({
|
|
|
221
219
|
},
|
|
222
220
|
name: RULE_NAME5,
|
|
223
221
|
create(context) {
|
|
224
|
-
const { components, polymorphicPropName } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
225
222
|
return {
|
|
226
223
|
JSXElement(node) {
|
|
227
|
-
const
|
|
228
|
-
const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
224
|
+
const elementType = core.getElementType(node.openingElement, context);
|
|
229
225
|
if (elementType !== "button") return;
|
|
230
226
|
const { attributes } = node.openingElement;
|
|
231
227
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -272,11 +268,9 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
272
268
|
},
|
|
273
269
|
name: RULE_NAME6,
|
|
274
270
|
create(context) {
|
|
275
|
-
const { components, polymorphicPropName } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
276
271
|
return {
|
|
277
272
|
JSXElement(node) {
|
|
278
|
-
const
|
|
279
|
-
const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
273
|
+
const elementType = core.getElementType(node.openingElement, context);
|
|
280
274
|
if (elementType !== "iframe") return;
|
|
281
275
|
const { attributes } = node.openingElement;
|
|
282
276
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1486,11 +1480,9 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1486
1480
|
},
|
|
1487
1481
|
name: RULE_NAME11,
|
|
1488
1482
|
create(context) {
|
|
1489
|
-
const { components, polymorphicPropName } = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
1490
1483
|
return {
|
|
1491
1484
|
JSXElement(node) {
|
|
1492
|
-
const
|
|
1493
|
-
const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
1485
|
+
const elementType = core.getElementType(node.openingElement, context);
|
|
1494
1486
|
if (elementType !== "iframe") return;
|
|
1495
1487
|
const { attributes } = node.openingElement;
|
|
1496
1488
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1538,13 +1530,10 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1538
1530
|
name: RULE_NAME12,
|
|
1539
1531
|
create(context) {
|
|
1540
1532
|
const settings = shared.normalizeSettings(shared.decodeSettings(context.settings));
|
|
1541
|
-
const polymorphicPropName = settings.polymorphicPropName;
|
|
1542
|
-
const components = settings.components;
|
|
1543
1533
|
const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
|
|
1544
1534
|
function getReportDescriptor(node) {
|
|
1545
1535
|
const name2 = JSX9__namespace.getElementName(node.openingElement);
|
|
1546
|
-
const
|
|
1547
|
-
const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
1536
|
+
const elementType = core.getElementType(node.openingElement, context);
|
|
1548
1537
|
if (elementType !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return tools.O.none();
|
|
1549
1538
|
const { attributes } = node.openingElement;
|
|
1550
1539
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1556,7 +1545,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1556
1545
|
const targetProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(targetPropName);
|
|
1557
1546
|
const targetPropValue = tools.O.isNone(targetProp) ? tools.O.fromNullable(targetPropDefaultValue) : tools.F.pipe(
|
|
1558
1547
|
targetProp,
|
|
1559
|
-
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr,
|
|
1548
|
+
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1560
1549
|
tools.O.flatMapNullable(
|
|
1561
1550
|
(v) => tsPattern.match(v).with(tsPattern.P.string, tools.F.identity).with({ [targetPropName]: tsPattern.P.string }, (v2) => v2[targetPropName]).otherwise(tools.F.constNull)
|
|
1562
1551
|
),
|
|
@@ -1570,7 +1559,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1570
1559
|
const hrefProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(hrefPropName);
|
|
1571
1560
|
const hrefPropValue = tools.O.isNone(hrefProp) ? tools.O.fromNullable(hrefPropDefaultValue) : tools.F.pipe(
|
|
1572
1561
|
hrefProp,
|
|
1573
|
-
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr,
|
|
1562
|
+
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1574
1563
|
tools.O.flatMapNullable(
|
|
1575
1564
|
(v) => tsPattern.match(v).with(tsPattern.P.string, tools.F.identity).with(tsPattern.P.shape({ [hrefPropName]: tsPattern.P.string }), (v2) => v2[hrefPropName]).otherwise(tools.F.constNull)
|
|
1576
1565
|
),
|
|
@@ -1584,7 +1573,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1584
1573
|
const relProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(relPropName);
|
|
1585
1574
|
const relPropValue = tools.O.isNone(relProp) ? tools.O.fromNullable(relPropDefaultValue) : tools.F.pipe(
|
|
1586
1575
|
relProp,
|
|
1587
|
-
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr,
|
|
1576
|
+
tools.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1588
1577
|
tools.O.flatMapNullable(
|
|
1589
1578
|
(v) => tsPattern.match(v).with(tsPattern.P.string, tools.F.identity).with(tsPattern.P.shape({ [relPropName]: tsPattern.P.string }), (v2) => v2[relPropName]).otherwise(tools.F.constNull)
|
|
1590
1579
|
),
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getElementType } from '@eslint-react/core';
|
|
1
2
|
import * as JSX9 from '@eslint-react/jsx';
|
|
2
|
-
import { createRuleForPlugin, normalizeSettings, decodeSettings, RE_JAVASCRIPT_PROTOCOL } from '@eslint-react/shared';
|
|
3
3
|
import { O, F, isString, isNullable } from '@eslint-react/tools';
|
|
4
|
+
import { createRuleForPlugin, RE_JAVASCRIPT_PROTOCOL, normalizeSettings, decodeSettings } from '@eslint-react/shared';
|
|
4
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
6
|
import * as AST from '@eslint-react/ast';
|
|
6
7
|
import { compare } from 'compare-versions';
|
|
@@ -8,7 +9,7 @@ import { match, P } from 'ts-pattern';
|
|
|
8
9
|
|
|
9
10
|
// package.json
|
|
10
11
|
var name = "eslint-plugin-react-dom";
|
|
11
|
-
var version = "1.17.4-next.
|
|
12
|
+
var version = "1.17.4-next.9";
|
|
12
13
|
var createRule = createRuleForPlugin("dom");
|
|
13
14
|
function findAttrInCustomAttributes(name2, attributes) {
|
|
14
15
|
return F.pipe(
|
|
@@ -51,12 +52,9 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
51
52
|
},
|
|
52
53
|
name: RULE_NAME,
|
|
53
54
|
create(context) {
|
|
54
|
-
const { components, polymorphicPropName } = normalizeSettings(decodeSettings(context.settings));
|
|
55
55
|
return {
|
|
56
56
|
JSXElement(node) {
|
|
57
|
-
const
|
|
58
|
-
const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
|
|
59
|
-
const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(openingElementNameExpression);
|
|
57
|
+
const elementType = getElementType(node.openingElement, context);
|
|
60
58
|
if (!elementType || !voidElements.has(elementType)) return;
|
|
61
59
|
if (node.children.length > 0) {
|
|
62
60
|
context.report({
|
|
@@ -198,11 +196,9 @@ var no_missing_button_type_default = createRule({
|
|
|
198
196
|
},
|
|
199
197
|
name: RULE_NAME5,
|
|
200
198
|
create(context) {
|
|
201
|
-
const { components, polymorphicPropName } = normalizeSettings(decodeSettings(context.settings));
|
|
202
199
|
return {
|
|
203
200
|
JSXElement(node) {
|
|
204
|
-
const
|
|
205
|
-
const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
201
|
+
const elementType = getElementType(node.openingElement, context);
|
|
206
202
|
if (elementType !== "button") return;
|
|
207
203
|
const { attributes } = node.openingElement;
|
|
208
204
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -249,11 +245,9 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
249
245
|
},
|
|
250
246
|
name: RULE_NAME6,
|
|
251
247
|
create(context) {
|
|
252
|
-
const { components, polymorphicPropName } = normalizeSettings(decodeSettings(context.settings));
|
|
253
248
|
return {
|
|
254
249
|
JSXElement(node) {
|
|
255
|
-
const
|
|
256
|
-
const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
250
|
+
const elementType = getElementType(node.openingElement, context);
|
|
257
251
|
if (elementType !== "iframe") return;
|
|
258
252
|
const { attributes } = node.openingElement;
|
|
259
253
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1463,11 +1457,9 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1463
1457
|
},
|
|
1464
1458
|
name: RULE_NAME11,
|
|
1465
1459
|
create(context) {
|
|
1466
|
-
const { components, polymorphicPropName } = normalizeSettings(decodeSettings(context.settings));
|
|
1467
1460
|
return {
|
|
1468
1461
|
JSXElement(node) {
|
|
1469
|
-
const
|
|
1470
|
-
const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
1462
|
+
const elementType = getElementType(node.openingElement, context);
|
|
1471
1463
|
if (elementType !== "iframe") return;
|
|
1472
1464
|
const { attributes } = node.openingElement;
|
|
1473
1465
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1515,13 +1507,10 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1515
1507
|
name: RULE_NAME12,
|
|
1516
1508
|
create(context) {
|
|
1517
1509
|
const settings = normalizeSettings(decodeSettings(context.settings));
|
|
1518
|
-
const polymorphicPropName = settings.polymorphicPropName;
|
|
1519
|
-
const components = settings.components;
|
|
1520
1510
|
const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
|
|
1521
1511
|
function getReportDescriptor(node) {
|
|
1522
1512
|
const name2 = JSX9.getElementName(node.openingElement);
|
|
1523
|
-
const
|
|
1524
|
-
const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
|
|
1513
|
+
const elementType = getElementType(node.openingElement, context);
|
|
1525
1514
|
if (elementType !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return O.none();
|
|
1526
1515
|
const { attributes } = node.openingElement;
|
|
1527
1516
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -1533,7 +1522,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1533
1522
|
const targetProp = JSX9.findPropInAttributes(attributes, initialScope)(targetPropName);
|
|
1534
1523
|
const targetPropValue = O.isNone(targetProp) ? O.fromNullable(targetPropDefaultValue) : F.pipe(
|
|
1535
1524
|
targetProp,
|
|
1536
|
-
O.flatMap((attr) => JSX9.getPropValue(attr,
|
|
1525
|
+
O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1537
1526
|
O.flatMapNullable(
|
|
1538
1527
|
(v) => match(v).with(P.string, F.identity).with({ [targetPropName]: P.string }, (v2) => v2[targetPropName]).otherwise(F.constNull)
|
|
1539
1528
|
),
|
|
@@ -1547,7 +1536,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1547
1536
|
const hrefProp = JSX9.findPropInAttributes(attributes, initialScope)(hrefPropName);
|
|
1548
1537
|
const hrefPropValue = O.isNone(hrefProp) ? O.fromNullable(hrefPropDefaultValue) : F.pipe(
|
|
1549
1538
|
hrefProp,
|
|
1550
|
-
O.flatMap((attr) => JSX9.getPropValue(attr,
|
|
1539
|
+
O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1551
1540
|
O.flatMapNullable(
|
|
1552
1541
|
(v) => match(v).with(P.string, F.identity).with(P.shape({ [hrefPropName]: P.string }), (v2) => v2[hrefPropName]).otherwise(F.constNull)
|
|
1553
1542
|
),
|
|
@@ -1561,7 +1550,7 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1561
1550
|
const relProp = JSX9.findPropInAttributes(attributes, initialScope)(relPropName);
|
|
1562
1551
|
const relPropValue = O.isNone(relProp) ? O.fromNullable(relPropDefaultValue) : F.pipe(
|
|
1563
1552
|
relProp,
|
|
1564
|
-
O.flatMap((attr) => JSX9.getPropValue(attr,
|
|
1553
|
+
O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
|
|
1565
1554
|
O.flatMapNullable(
|
|
1566
1555
|
(v) => match(v).with(P.string, F.identity).with(P.shape({ [relPropName]: P.string }), (v2) => v2[relPropName]).otherwise(F.constNull)
|
|
1567
1556
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "1.17.4-next.
|
|
3
|
+
"version": "1.17.4-next.9",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"@typescript-eslint/utils": "^8.17.0",
|
|
48
48
|
"compare-versions": "^6.1.1",
|
|
49
49
|
"ts-pattern": "^5.5.0",
|
|
50
|
-
"@eslint-react/ast": "1.17.4-next.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/tools": "1.17.4-next.
|
|
55
|
-
"@eslint-react/types": "1.17.4-next.
|
|
56
|
-
"@eslint-react/var": "1.17.4-next.
|
|
50
|
+
"@eslint-react/ast": "1.17.4-next.9",
|
|
51
|
+
"@eslint-react/jsx": "1.17.4-next.9",
|
|
52
|
+
"@eslint-react/core": "1.17.4-next.9",
|
|
53
|
+
"@eslint-react/shared": "1.17.4-next.9",
|
|
54
|
+
"@eslint-react/tools": "1.17.4-next.9",
|
|
55
|
+
"@eslint-react/types": "1.17.4-next.9",
|
|
56
|
+
"@eslint-react/var": "1.17.4-next.9"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@types/react": "^
|
|
60
|
-
"@types/react-dom": "^
|
|
59
|
+
"@types/react": "^19.0.1",
|
|
60
|
+
"@types/react-dom": "^19.0.1",
|
|
61
61
|
"string-ts": "^2.2.0",
|
|
62
62
|
"tsup": "^8.3.5"
|
|
63
63
|
},
|