eslint-plugin-react-dom 1.17.4-next.8 → 1.18.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 CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var JSX9 = require('@eslint-react/jsx');
4
- var shared = require('@eslint-react/shared');
5
4
  var tools = require('@eslint-react/tools');
5
+ var shared = require('@eslint-react/shared');
6
6
  var types = require('@typescript-eslint/types');
7
+ var core = require('@eslint-react/core');
7
8
  var AST = require('@eslint-react/ast');
8
9
  var compareVersions = require('compare-versions');
9
10
  var tsPattern = require('ts-pattern');
@@ -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.8";
35
+ var version = "1.18.0";
35
36
  var createRule = shared.createRuleForPlugin("dom");
36
37
  function findAttrInCustomAttributes(name2, attributes) {
37
38
  return tools.F.pipe(
@@ -43,7 +44,7 @@ function findAttrInCustomAttributes(name2, attributes) {
43
44
 
44
45
  // src/rules/no-children-in-void-dom-elements.ts
45
46
  var RULE_NAME = "no-children-in-void-dom-elements";
46
- var voidElements = /* @__PURE__ */ new Set([
47
+ var voidElements = [
47
48
  "area",
48
49
  "base",
49
50
  "br",
@@ -60,7 +61,7 @@ var voidElements = /* @__PURE__ */ new Set([
60
61
  "source",
61
62
  "track",
62
63
  "wbr"
63
- ]);
64
+ ];
64
65
  var no_children_in_void_dom_elements_default = createRule({
65
66
  meta: {
66
67
  type: "problem",
@@ -74,19 +75,16 @@ 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 openingElementNameExpression = node.openingElement;
81
- const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
82
- const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(openingElementNameExpression);
83
- if (!elementType || !voidElements.has(elementType)) return;
80
+ const elementName = JSX9__namespace.getElementName(node.openingElement);
81
+ if (!elementName || !voidElements.includes(elementName)) return;
84
82
  if (node.children.length > 0) {
85
83
  context.report({
86
84
  messageId: "noChildrenInVoidDomElements",
87
85
  node,
88
86
  data: {
89
- element: elementType
87
+ element: elementName
90
88
  }
91
89
  });
92
90
  }
@@ -99,7 +97,7 @@ var no_children_in_void_dom_elements_default = createRule({
99
97
  messageId: "noChildrenInVoidDomElements",
100
98
  node,
101
99
  data: {
102
- element: elementType
100
+ element: elementName
103
101
  }
104
102
  });
105
103
  }
@@ -221,12 +219,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
228
- const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
229
- if (elementType !== "button") return;
224
+ const elementName = core.getElementRepresentName(node.openingElement, context);
225
+ if (elementName !== "button") return;
230
226
  const { attributes } = node.openingElement;
231
227
  const initialScope = context.sourceCode.getScope(node);
232
228
  const maybeTypeAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("type");
@@ -272,12 +268,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
279
- const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
280
- if (elementType !== "iframe") return;
273
+ const elementName = core.getElementRepresentName(node.openingElement, context);
274
+ if (elementName !== "iframe") return;
281
275
  const { attributes } = node.openingElement;
282
276
  const initialScope = context.sourceCode.getScope(node);
283
277
  const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
@@ -1486,12 +1480,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
1493
- const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
1494
- if (elementType !== "iframe") return;
1485
+ const elementName = core.getElementRepresentName(node.openingElement, context);
1486
+ if (elementName !== "iframe") return;
1495
1487
  const { attributes } = node.openingElement;
1496
1488
  const initialScope = context.sourceCode.getScope(node);
1497
1489
  const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
@@ -1538,14 +1530,11 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
1547
- const elementType = JSX9__namespace.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
1548
- if (elementType !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return tools.O.none();
1536
+ const elementName = core.getElementRepresentName(node.openingElement, context);
1537
+ if (elementName !== "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);
1551
1540
  const additionalAttributes = additionalComponents.findLast((c) => c.re.test(name2))?.attributes ?? [];
@@ -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, jsxCtx.getScope(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, jsxCtx.getScope(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, jsxCtx.getScope(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,14 +1,15 @@
1
1
  import * as JSX9 from '@eslint-react/jsx';
2
- import { createRuleForPlugin, normalizeSettings, decodeSettings, RE_JAVASCRIPT_PROTOCOL } from '@eslint-react/shared';
3
2
  import { O, F, isString, isNullable } from '@eslint-react/tools';
3
+ import { createRuleForPlugin, RE_JAVASCRIPT_PROTOCOL, normalizeSettings, decodeSettings } from '@eslint-react/shared';
4
4
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
5
+ import { getElementRepresentName } from '@eslint-react/core';
5
6
  import * as AST from '@eslint-react/ast';
6
7
  import { compare } from 'compare-versions';
7
8
  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.8";
12
+ var version = "1.18.0";
12
13
  var createRule = createRuleForPlugin("dom");
13
14
  function findAttrInCustomAttributes(name2, attributes) {
14
15
  return F.pipe(
@@ -20,7 +21,7 @@ function findAttrInCustomAttributes(name2, attributes) {
20
21
 
21
22
  // src/rules/no-children-in-void-dom-elements.ts
22
23
  var RULE_NAME = "no-children-in-void-dom-elements";
23
- var voidElements = /* @__PURE__ */ new Set([
24
+ var voidElements = [
24
25
  "area",
25
26
  "base",
26
27
  "br",
@@ -37,7 +38,7 @@ var voidElements = /* @__PURE__ */ new Set([
37
38
  "source",
38
39
  "track",
39
40
  "wbr"
40
- ]);
41
+ ];
41
42
  var no_children_in_void_dom_elements_default = createRule({
42
43
  meta: {
43
44
  type: "problem",
@@ -51,19 +52,16 @@ 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 openingElementNameExpression = node.openingElement;
58
- const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
59
- const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(openingElementNameExpression);
60
- if (!elementType || !voidElements.has(elementType)) return;
57
+ const elementName = JSX9.getElementName(node.openingElement);
58
+ if (!elementName || !voidElements.includes(elementName)) return;
61
59
  if (node.children.length > 0) {
62
60
  context.report({
63
61
  messageId: "noChildrenInVoidDomElements",
64
62
  node,
65
63
  data: {
66
- element: elementType
64
+ element: elementName
67
65
  }
68
66
  });
69
67
  }
@@ -76,7 +74,7 @@ var no_children_in_void_dom_elements_default = createRule({
76
74
  messageId: "noChildrenInVoidDomElements",
77
75
  node,
78
76
  data: {
79
- element: elementType
77
+ element: elementName
80
78
  }
81
79
  });
82
80
  }
@@ -198,12 +196,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
205
- const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
206
- if (elementType !== "button") return;
201
+ const elementName = getElementRepresentName(node.openingElement, context);
202
+ if (elementName !== "button") return;
207
203
  const { attributes } = node.openingElement;
208
204
  const initialScope = context.sourceCode.getScope(node);
209
205
  const maybeTypeAttribute = JSX9.findPropInAttributes(attributes, initialScope)("type");
@@ -249,12 +245,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
256
- const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
257
- if (elementType !== "iframe") return;
250
+ const elementName = getElementRepresentName(node.openingElement, context);
251
+ if (elementName !== "iframe") return;
258
252
  const { attributes } = node.openingElement;
259
253
  const initialScope = context.sourceCode.getScope(node);
260
254
  const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
@@ -1463,12 +1457,10 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
1470
- const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
1471
- if (elementType !== "iframe") return;
1462
+ const elementName = getElementRepresentName(node.openingElement, context);
1463
+ if (elementName !== "iframe") return;
1472
1464
  const { attributes } = node.openingElement;
1473
1465
  const initialScope = context.sourceCode.getScope(node);
1474
1466
  const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
@@ -1515,14 +1507,11 @@ 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 jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
1524
- const elementType = JSX9.getElementType(jsxCtx, components, polymorphicPropName)(node.openingElement);
1525
- if (elementType !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return O.none();
1513
+ const elementName = getElementRepresentName(node.openingElement, context);
1514
+ if (elementName !== "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);
1528
1517
  const additionalAttributes = additionalComponents.findLast((c) => c.re.test(name2))?.attributes ?? [];
@@ -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, jsxCtx.getScope(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, jsxCtx.getScope(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, jsxCtx.getScope(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.8",
3
+ "version": "1.18.0",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -47,13 +47,13 @@
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.8",
51
- "@eslint-react/core": "1.17.4-next.8",
52
- "@eslint-react/shared": "1.17.4-next.8",
53
- "@eslint-react/tools": "1.17.4-next.8",
54
- "@eslint-react/jsx": "1.17.4-next.8",
55
- "@eslint-react/types": "1.17.4-next.8",
56
- "@eslint-react/var": "1.17.4-next.8"
50
+ "@eslint-react/ast": "1.18.0",
51
+ "@eslint-react/jsx": "1.18.0",
52
+ "@eslint-react/core": "1.18.0",
53
+ "@eslint-react/types": "1.18.0",
54
+ "@eslint-react/tools": "1.18.0",
55
+ "@eslint-react/var": "1.18.0",
56
+ "@eslint-react/shared": "1.18.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "^19.0.1",