eslint-plugin-react-dom 1.46.1-next.0 → 1.47.0-beta.2

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var shared = require('@eslint-react/shared');
4
- var JSX = require('@eslint-react/jsx');
4
+ var ER = require('@eslint-react/core');
5
5
  var utils = require('@typescript-eslint/utils');
6
6
  var AST = require('@eslint-react/ast');
7
7
  var types = require('@typescript-eslint/types');
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var JSX__namespace = /*#__PURE__*/_interopNamespace(JSX);
30
+ var ER__namespace = /*#__PURE__*/_interopNamespace(ER);
31
31
  var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
32
32
 
33
33
  var __defProp = Object.defineProperty;
@@ -67,7 +67,7 @@ var settings = {
67
67
 
68
68
  // package.json
69
69
  var name2 = "eslint-plugin-react-dom";
70
- var version = "1.46.1-next.0";
70
+ var version = "1.47.0-beta.2";
71
71
  function createJsxElementResolver(context) {
72
72
  const {
73
73
  additionalComponents,
@@ -75,7 +75,7 @@ function createJsxElementResolver(context) {
75
75
  } = shared.getSettingsFromContext(context);
76
76
  return {
77
77
  resolve(node) {
78
- const name3 = JSX__namespace.getElementType(node);
78
+ const name3 = ER__namespace.getElementType(context, node);
79
79
  const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
80
80
  const result = {
81
81
  attributes: component?.attributes ?? [],
@@ -86,16 +86,17 @@ function createJsxElementResolver(context) {
86
86
  return result;
87
87
  }
88
88
  const initialScope = context.sourceCode.getScope(node);
89
- const polymorphicPropAttr = JSX__namespace.getAttribute(
89
+ const polymorphicPropAttr = ER__namespace.getAttribute(
90
+ context,
90
91
  polymorphicPropName,
91
92
  node.openingElement.attributes,
92
93
  initialScope
93
94
  );
94
95
  if (polymorphicPropAttr != null) {
95
- const polymorphicPropValue = JSX__namespace.getAttributeValue(
96
+ const polymorphicPropValue = ER__namespace.getAttributeValue(
97
+ context,
96
98
  polymorphicPropAttr,
97
- polymorphicPropName,
98
- initialScope
99
+ polymorphicPropName
99
100
  );
100
101
  if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
101
102
  return {
@@ -139,7 +140,8 @@ function create(context) {
139
140
  return {
140
141
  JSXElement(node) {
141
142
  const attributes = node.openingElement.attributes;
142
- const attribute = JSX__namespace.getAttribute(
143
+ const attribute = ER__namespace.getAttribute(
144
+ context,
143
145
  "dangerouslySetInnerHTML",
144
146
  attributes,
145
147
  context.sourceCode.getScope(node)
@@ -176,8 +178,8 @@ function create2(context) {
176
178
  JSXElement(node) {
177
179
  const attributes = node.openingElement.attributes;
178
180
  const initialScope = context.sourceCode.getScope(node);
179
- const hasChildren = hasChildrenWithin(node) || JSX__namespace.hasAttribute("children", attributes, initialScope);
180
- if (hasChildren && JSX__namespace.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
181
+ const hasChildren = hasChildrenWithin(node) || ER__namespace.hasAttribute(context, "children", attributes, initialScope);
182
+ if (hasChildren && ER__namespace.hasAttribute(context, "dangerouslySetInnerHTML", attributes, initialScope)) {
181
183
  context.report({
182
184
  messageId: "noDangerouslySetInnerhtmlWithChildren",
183
185
  node
@@ -366,17 +368,20 @@ function create6(context) {
366
368
  JSXElement(node) {
367
369
  const { attributes, domElementType } = resolver.resolve(node);
368
370
  if (domElementType !== "button") return;
369
- const elementScope = context.sourceCode.getScope(node);
370
371
  const customComponentProp = findCustomComponentProp("type", attributes);
371
372
  const propNameOnJsx = customComponentProp?.name ?? "type";
372
- const attributeNode = JSX__namespace.getAttribute(
373
+ const attributeNode = ER__namespace.getAttribute(
374
+ context,
373
375
  propNameOnJsx,
374
376
  node.openingElement.attributes,
375
- elementScope
377
+ context.sourceCode.getScope(node)
376
378
  );
377
379
  if (attributeNode != null) {
378
- const attributeScope = context.sourceCode.getScope(attributeNode);
379
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
380
+ const attributeValue = ER__namespace.getAttributeValue(
381
+ context,
382
+ attributeNode,
383
+ propNameOnJsx
384
+ );
380
385
  if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
381
386
  context.report({
382
387
  messageId: "noMissingButtonType",
@@ -439,17 +444,20 @@ function create7(context) {
439
444
  JSXElement(node) {
440
445
  const { attributes, domElementType } = resolver.resolve(node);
441
446
  if (domElementType !== "iframe") return;
442
- const elementScope = context.sourceCode.getScope(node);
443
447
  const customComponentProp = findCustomComponentProp("sandbox", attributes);
444
448
  const propNameOnJsx = customComponentProp?.name ?? "sandbox";
445
- const attributeNode = JSX__namespace.getAttribute(
449
+ const attributeNode = ER__namespace.getAttribute(
450
+ context,
446
451
  propNameOnJsx,
447
452
  node.openingElement.attributes,
448
- elementScope
453
+ context.sourceCode.getScope(node)
449
454
  );
450
455
  if (attributeNode != null) {
451
- const attributeScope = context.sourceCode.getScope(attributeNode);
452
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
456
+ const attributeValue = ER__namespace.getAttributeValue(
457
+ context,
458
+ attributeNode,
459
+ propNameOnJsx
460
+ );
453
461
  if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
454
462
  context.report({
455
463
  messageId: "noMissingIframeSandbox",
@@ -487,7 +495,7 @@ var no_namespace_default = createRule({
487
495
  function create8(context) {
488
496
  return {
489
497
  JSXElement(node) {
490
- const name3 = JSX__namespace.getElementType(node);
498
+ const name3 = ER__namespace.getElementType(context, node);
491
499
  if (typeof name3 !== "string" || !name3.includes(":")) {
492
500
  return;
493
501
  }
@@ -654,9 +662,8 @@ function create11(context) {
654
662
  if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier || node.value == null) {
655
663
  return;
656
664
  }
657
- const attributeScope = context.sourceCode.getScope(node);
658
- const attributeName = JSX__namespace.getAttributeName(node);
659
- const attributeValue = JSX__namespace.getAttributeValue(node, attributeName, attributeScope);
665
+ const attributeName = ER__namespace.getAttributeName(context, node);
666
+ const attributeValue = ER__namespace.getAttributeValue(context, node, attributeName);
660
667
  if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
661
668
  if (kit.RE.JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
662
669
  context.report({
@@ -1758,17 +1765,20 @@ function create13(context) {
1758
1765
  JSXElement(node) {
1759
1766
  const { attributes, domElementType } = resolver.resolve(node);
1760
1767
  if (domElementType !== "iframe") return;
1761
- const elementScope = context.sourceCode.getScope(node);
1762
1768
  const customComponentProp = findCustomComponentProp("sandbox", attributes);
1763
1769
  const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1764
- const attributeNode = JSX__namespace.getAttribute(
1770
+ const attributeNode = ER__namespace.getAttribute(
1771
+ context,
1765
1772
  propNameOnJsx,
1766
1773
  node.openingElement.attributes,
1767
- elementScope
1774
+ context.sourceCode.getScope(node)
1768
1775
  );
1769
1776
  if (attributeNode != null) {
1770
- const attributeScope = context.sourceCode.getScope(attributeNode);
1771
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1777
+ const attributeValue = ER__namespace.getAttributeValue(
1778
+ context,
1779
+ attributeNode,
1780
+ propNameOnJsx
1781
+ );
1772
1782
  if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1773
1783
  context.report({
1774
1784
  messageId: "noUnsafeIframeSandbox",
@@ -1823,14 +1833,14 @@ function create14(context) {
1823
1833
  const getAttributeStringValue = (name3) => {
1824
1834
  const customComponentProp = findCustomComponentProp(name3, attributes);
1825
1835
  const propNameOnJsx = customComponentProp?.name ?? name3;
1826
- const attributeNode = JSX__namespace.getAttribute(
1836
+ const attributeNode = ER__namespace.getAttribute(
1837
+ context,
1827
1838
  propNameOnJsx,
1828
1839
  node.openingElement.attributes,
1829
1840
  elementScope
1830
1841
  );
1831
1842
  if (attributeNode == null) return customComponentProp?.defaultValue;
1832
- const attributeScope = context.sourceCode.getScope(attributeNode);
1833
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1843
+ const attributeValue = ER__namespace.getAttributeValue(context, attributeNode, propNameOnJsx);
1834
1844
  if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1835
1845
  return attributeValue.value;
1836
1846
  }
@@ -1967,7 +1977,7 @@ var no_void_elements_with_children_default = createRule({
1967
1977
  function create16(context) {
1968
1978
  return {
1969
1979
  JSXElement(node) {
1970
- const elementName = JSX__namespace.getElementType(node);
1980
+ const elementName = ER__namespace.getElementType(context, node);
1971
1981
  if (elementName.length === 0 || !voidElements.has(elementName)) {
1972
1982
  return;
1973
1983
  }
@@ -1982,7 +1992,7 @@ function create16(context) {
1982
1992
  }
1983
1993
  const { attributes } = node.openingElement;
1984
1994
  const initialScope = context.sourceCode.getScope(node);
1985
- const hasAttribute3 = (name3) => JSX__namespace.hasAttribute(name3, attributes, initialScope);
1995
+ const hasAttribute3 = (name3) => ER__namespace.hasAttribute(context, name3, attributes, initialScope);
1986
1996
  if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1987
1997
  context.report({
1988
1998
  messageId: "noVoidElementsWithChildren",
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getDocsUrl, getSettingsFromContext, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
2
- import * as JSX from '@eslint-react/jsx';
2
+ import * as ER from '@eslint-react/core';
3
3
  import { ESLintUtils } from '@typescript-eslint/utils';
4
4
  import * as AST from '@eslint-react/ast';
5
5
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
@@ -44,7 +44,7 @@ var settings = {
44
44
 
45
45
  // package.json
46
46
  var name2 = "eslint-plugin-react-dom";
47
- var version = "1.46.1-next.0";
47
+ var version = "1.47.0-beta.2";
48
48
  function createJsxElementResolver(context) {
49
49
  const {
50
50
  additionalComponents,
@@ -52,7 +52,7 @@ function createJsxElementResolver(context) {
52
52
  } = getSettingsFromContext(context);
53
53
  return {
54
54
  resolve(node) {
55
- const name3 = JSX.getElementType(node);
55
+ const name3 = ER.getElementType(context, node);
56
56
  const component = additionalComponents.findLast((c) => c.name === name3 || c.re.test(name3));
57
57
  const result = {
58
58
  attributes: component?.attributes ?? [],
@@ -63,16 +63,17 @@ function createJsxElementResolver(context) {
63
63
  return result;
64
64
  }
65
65
  const initialScope = context.sourceCode.getScope(node);
66
- const polymorphicPropAttr = JSX.getAttribute(
66
+ const polymorphicPropAttr = ER.getAttribute(
67
+ context,
67
68
  polymorphicPropName,
68
69
  node.openingElement.attributes,
69
70
  initialScope
70
71
  );
71
72
  if (polymorphicPropAttr != null) {
72
- const polymorphicPropValue = JSX.getAttributeValue(
73
+ const polymorphicPropValue = ER.getAttributeValue(
74
+ context,
73
75
  polymorphicPropAttr,
74
- polymorphicPropName,
75
- initialScope
76
+ polymorphicPropName
76
77
  );
77
78
  if (polymorphicPropValue.kind === "some" && typeof polymorphicPropValue.value === "string") {
78
79
  return {
@@ -116,7 +117,8 @@ function create(context) {
116
117
  return {
117
118
  JSXElement(node) {
118
119
  const attributes = node.openingElement.attributes;
119
- const attribute = JSX.getAttribute(
120
+ const attribute = ER.getAttribute(
121
+ context,
120
122
  "dangerouslySetInnerHTML",
121
123
  attributes,
122
124
  context.sourceCode.getScope(node)
@@ -153,8 +155,8 @@ function create2(context) {
153
155
  JSXElement(node) {
154
156
  const attributes = node.openingElement.attributes;
155
157
  const initialScope = context.sourceCode.getScope(node);
156
- const hasChildren = hasChildrenWithin(node) || JSX.hasAttribute("children", attributes, initialScope);
157
- if (hasChildren && JSX.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
158
+ const hasChildren = hasChildrenWithin(node) || ER.hasAttribute(context, "children", attributes, initialScope);
159
+ if (hasChildren && ER.hasAttribute(context, "dangerouslySetInnerHTML", attributes, initialScope)) {
158
160
  context.report({
159
161
  messageId: "noDangerouslySetInnerhtmlWithChildren",
160
162
  node
@@ -343,17 +345,20 @@ function create6(context) {
343
345
  JSXElement(node) {
344
346
  const { attributes, domElementType } = resolver.resolve(node);
345
347
  if (domElementType !== "button") return;
346
- const elementScope = context.sourceCode.getScope(node);
347
348
  const customComponentProp = findCustomComponentProp("type", attributes);
348
349
  const propNameOnJsx = customComponentProp?.name ?? "type";
349
- const attributeNode = JSX.getAttribute(
350
+ const attributeNode = ER.getAttribute(
351
+ context,
350
352
  propNameOnJsx,
351
353
  node.openingElement.attributes,
352
- elementScope
354
+ context.sourceCode.getScope(node)
353
355
  );
354
356
  if (attributeNode != null) {
355
- const attributeScope = context.sourceCode.getScope(attributeNode);
356
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
357
+ const attributeValue = ER.getAttributeValue(
358
+ context,
359
+ attributeNode,
360
+ propNameOnJsx
361
+ );
357
362
  if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
358
363
  context.report({
359
364
  messageId: "noMissingButtonType",
@@ -416,17 +421,20 @@ function create7(context) {
416
421
  JSXElement(node) {
417
422
  const { attributes, domElementType } = resolver.resolve(node);
418
423
  if (domElementType !== "iframe") return;
419
- const elementScope = context.sourceCode.getScope(node);
420
424
  const customComponentProp = findCustomComponentProp("sandbox", attributes);
421
425
  const propNameOnJsx = customComponentProp?.name ?? "sandbox";
422
- const attributeNode = JSX.getAttribute(
426
+ const attributeNode = ER.getAttribute(
427
+ context,
423
428
  propNameOnJsx,
424
429
  node.openingElement.attributes,
425
- elementScope
430
+ context.sourceCode.getScope(node)
426
431
  );
427
432
  if (attributeNode != null) {
428
- const attributeScope = context.sourceCode.getScope(attributeNode);
429
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
433
+ const attributeValue = ER.getAttributeValue(
434
+ context,
435
+ attributeNode,
436
+ propNameOnJsx
437
+ );
430
438
  if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
431
439
  context.report({
432
440
  messageId: "noMissingIframeSandbox",
@@ -464,7 +472,7 @@ var no_namespace_default = createRule({
464
472
  function create8(context) {
465
473
  return {
466
474
  JSXElement(node) {
467
- const name3 = JSX.getElementType(node);
475
+ const name3 = ER.getElementType(context, node);
468
476
  if (typeof name3 !== "string" || !name3.includes(":")) {
469
477
  return;
470
478
  }
@@ -631,9 +639,8 @@ function create11(context) {
631
639
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) {
632
640
  return;
633
641
  }
634
- const attributeScope = context.sourceCode.getScope(node);
635
- const attributeName = JSX.getAttributeName(node);
636
- const attributeValue = JSX.getAttributeValue(node, attributeName, attributeScope);
642
+ const attributeName = ER.getAttributeName(context, node);
643
+ const attributeValue = ER.getAttributeValue(context, node, attributeName);
637
644
  if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
638
645
  if (RE.JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
639
646
  context.report({
@@ -1735,17 +1742,20 @@ function create13(context) {
1735
1742
  JSXElement(node) {
1736
1743
  const { attributes, domElementType } = resolver.resolve(node);
1737
1744
  if (domElementType !== "iframe") return;
1738
- const elementScope = context.sourceCode.getScope(node);
1739
1745
  const customComponentProp = findCustomComponentProp("sandbox", attributes);
1740
1746
  const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1741
- const attributeNode = JSX.getAttribute(
1747
+ const attributeNode = ER.getAttribute(
1748
+ context,
1742
1749
  propNameOnJsx,
1743
1750
  node.openingElement.attributes,
1744
- elementScope
1751
+ context.sourceCode.getScope(node)
1745
1752
  );
1746
1753
  if (attributeNode != null) {
1747
- const attributeScope = context.sourceCode.getScope(attributeNode);
1748
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1754
+ const attributeValue = ER.getAttributeValue(
1755
+ context,
1756
+ attributeNode,
1757
+ propNameOnJsx
1758
+ );
1749
1759
  if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1750
1760
  context.report({
1751
1761
  messageId: "noUnsafeIframeSandbox",
@@ -1800,14 +1810,14 @@ function create14(context) {
1800
1810
  const getAttributeStringValue = (name3) => {
1801
1811
  const customComponentProp = findCustomComponentProp(name3, attributes);
1802
1812
  const propNameOnJsx = customComponentProp?.name ?? name3;
1803
- const attributeNode = JSX.getAttribute(
1813
+ const attributeNode = ER.getAttribute(
1814
+ context,
1804
1815
  propNameOnJsx,
1805
1816
  node.openingElement.attributes,
1806
1817
  elementScope
1807
1818
  );
1808
1819
  if (attributeNode == null) return customComponentProp?.defaultValue;
1809
- const attributeScope = context.sourceCode.getScope(attributeNode);
1810
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1820
+ const attributeValue = ER.getAttributeValue(context, attributeNode, propNameOnJsx);
1811
1821
  if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1812
1822
  return attributeValue.value;
1813
1823
  }
@@ -1944,7 +1954,7 @@ var no_void_elements_with_children_default = createRule({
1944
1954
  function create16(context) {
1945
1955
  return {
1946
1956
  JSXElement(node) {
1947
- const elementName = JSX.getElementType(node);
1957
+ const elementName = ER.getElementType(context, node);
1948
1958
  if (elementName.length === 0 || !voidElements.has(elementName)) {
1949
1959
  return;
1950
1960
  }
@@ -1959,7 +1969,7 @@ function create16(context) {
1959
1969
  }
1960
1970
  const { attributes } = node.openingElement;
1961
1971
  const initialScope = context.sourceCode.getScope(node);
1962
- const hasAttribute3 = (name3) => JSX.hasAttribute(name3, attributes, initialScope);
1972
+ const hasAttribute3 = (name3) => ER.hasAttribute(context, name3, attributes, initialScope);
1963
1973
  if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1964
1974
  context.report({
1965
1975
  messageId: "noVoidElementsWithChildren",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "1.46.1-next.0",
3
+ "version": "1.47.0-beta.2",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -49,13 +49,12 @@
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.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"
52
+ "@eslint-react/ast": "1.47.0-beta.2",
53
+ "@eslint-react/core": "1.47.0-beta.2",
54
+ "@eslint-react/eff": "1.47.0-beta.2",
55
+ "@eslint-react/kit": "1.47.0-beta.2",
56
+ "@eslint-react/shared": "1.47.0-beta.2",
57
+ "@eslint-react/var": "1.47.0-beta.2"
59
58
  },
60
59
  "devDependencies": {
61
60
  "@types/react": "^19.1.1",