eslint-plugin-react-dom 2.0.2 → 2.0.3-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +153 -116
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
47
47
  //#endregion
48
48
  //#region package.json
49
49
  var name = "eslint-plugin-react-dom";
50
- var version = "2.0.2";
50
+ var version = "2.0.3-beta.0";
51
51
 
52
52
  //#endregion
53
53
  //#region src/utils/create-jsx-element-resolver.ts
@@ -89,24 +89,24 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl("dom"));
89
89
 
90
90
  //#endregion
91
91
  //#region src/rules/no-dangerously-set-innerhtml.ts
92
- const RULE_NAME$16 = "no-dangerously-set-innerhtml";
93
- const RULE_FEATURES$15 = [];
92
+ const RULE_NAME$17 = "no-dangerously-set-innerhtml";
93
+ const RULE_FEATURES$16 = [];
94
94
  var no_dangerously_set_innerhtml_default = createRule({
95
95
  meta: {
96
96
  type: "problem",
97
97
  docs: {
98
98
  description: "Disallow `dangerouslySetInnerHTML`.",
99
- [Symbol.for("rule_features")]: RULE_FEATURES$15
99
+ [Symbol.for("rule_features")]: RULE_FEATURES$16
100
100
  },
101
101
  messages: { noDangerouslySetInnerhtml: "Using 'dangerouslySetInnerHTML' may have security implications." },
102
102
  schema: []
103
103
  },
104
- name: RULE_NAME$16,
105
- create: create$16,
104
+ name: RULE_NAME$17,
105
+ create: create$17,
106
106
  defaultOptions: []
107
107
  });
108
108
  const dangerouslySetInnerHTML$1 = "dangerouslySetInnerHTML";
109
- function create$16(context) {
109
+ function create$17(context) {
110
110
  if (!context.sourceCode.text.includes(dangerouslySetInnerHTML$1)) return {};
111
111
  return { JSXElement(node) {
112
112
  const attribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))(dangerouslySetInnerHTML$1);
@@ -120,24 +120,24 @@ function create$16(context) {
120
120
 
121
121
  //#endregion
122
122
  //#region src/rules/no-dangerously-set-innerhtml-with-children.ts
123
- const RULE_NAME$15 = "no-dangerously-set-innerhtml-with-children";
124
- const RULE_FEATURES$14 = [];
123
+ const RULE_NAME$16 = "no-dangerously-set-innerhtml-with-children";
124
+ const RULE_FEATURES$15 = [];
125
125
  var no_dangerously_set_innerhtml_with_children_default = createRule({
126
126
  meta: {
127
127
  type: "problem",
128
128
  docs: {
129
129
  description: "Disallow `dangerouslySetInnerHTML` and `children` at the same time.",
130
- [Symbol.for("rule_features")]: RULE_FEATURES$14
130
+ [Symbol.for("rule_features")]: RULE_FEATURES$15
131
131
  },
132
132
  messages: { noDangerouslySetInnerhtmlWithChildren: "A DOM component cannot use both 'children' and 'dangerouslySetInnerHTML'." },
133
133
  schema: []
134
134
  },
135
- name: RULE_NAME$15,
136
- create: create$15,
135
+ name: RULE_NAME$16,
136
+ create: create$16,
137
137
  defaultOptions: []
138
138
  });
139
139
  const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
140
- function create$15(context) {
140
+ function create$16(context) {
141
141
  if (!context.sourceCode.text.includes(dangerouslySetInnerHTML)) return {};
142
142
  return { JSXElement(node) {
143
143
  const attributes = node.openingElement.attributes;
@@ -170,24 +170,24 @@ function isSignificantChildren(node) {
170
170
 
171
171
  //#endregion
172
172
  //#region src/rules/no-find-dom-node.ts
173
- const RULE_NAME$14 = "no-find-dom-node";
174
- const RULE_FEATURES$13 = [];
173
+ const RULE_NAME$15 = "no-find-dom-node";
174
+ const RULE_FEATURES$14 = [];
175
175
  var no_find_dom_node_default = createRule({
176
176
  meta: {
177
177
  type: "problem",
178
178
  docs: {
179
179
  description: "Disallow `findDOMNode`.",
180
- [Symbol.for("rule_features")]: RULE_FEATURES$13
180
+ [Symbol.for("rule_features")]: RULE_FEATURES$14
181
181
  },
182
182
  messages: { noFindDomNode: "[Deprecated] Use alternatives instead." },
183
183
  schema: []
184
184
  },
185
- name: RULE_NAME$14,
186
- create: create$14,
185
+ name: RULE_NAME$15,
186
+ create: create$15,
187
187
  defaultOptions: []
188
188
  });
189
189
  const findDOMNode = "findDOMNode";
190
- function create$14(context) {
190
+ function create$15(context) {
191
191
  if (!context.sourceCode.text.includes(findDOMNode)) return {};
192
192
  return { CallExpression(node) {
193
193
  const { callee } = node;
@@ -210,24 +210,24 @@ function create$14(context) {
210
210
 
211
211
  //#endregion
212
212
  //#region src/rules/no-flush-sync.ts
213
- const RULE_NAME$13 = "no-flush-sync";
214
- const RULE_FEATURES$12 = [];
213
+ const RULE_NAME$14 = "no-flush-sync";
214
+ const RULE_FEATURES$13 = [];
215
215
  var no_flush_sync_default = createRule({
216
216
  meta: {
217
217
  type: "problem",
218
218
  docs: {
219
219
  description: "Disallow `flushSync`.",
220
- [Symbol.for("rule_features")]: RULE_FEATURES$12
220
+ [Symbol.for("rule_features")]: RULE_FEATURES$13
221
221
  },
222
222
  messages: { noFlushSync: "Using 'flushSync' is uncommon and can hurt the performance of your app." },
223
223
  schema: []
224
224
  },
225
- name: RULE_NAME$13,
226
- create: create$13,
225
+ name: RULE_NAME$14,
226
+ create: create$14,
227
227
  defaultOptions: []
228
228
  });
229
229
  const flushSync = "flushSync";
230
- function create$13(context) {
230
+ function create$14(context) {
231
231
  if (!context.sourceCode.text.includes(flushSync)) return {};
232
232
  return { CallExpression(node) {
233
233
  const { callee } = node;
@@ -250,25 +250,25 @@ function create$13(context) {
250
250
 
251
251
  //#endregion
252
252
  //#region src/rules/no-hydrate.ts
253
- const RULE_NAME$12 = "no-hydrate";
254
- const RULE_FEATURES$11 = ["MOD"];
253
+ const RULE_NAME$13 = "no-hydrate";
254
+ const RULE_FEATURES$12 = ["MOD"];
255
255
  var no_hydrate_default = createRule({
256
256
  meta: {
257
257
  type: "problem",
258
258
  docs: {
259
259
  description: "Replaces usages of `ReactDom.hydrate()` with `hydrateRoot()`.",
260
- [Symbol.for("rule_features")]: RULE_FEATURES$11
260
+ [Symbol.for("rule_features")]: RULE_FEATURES$12
261
261
  },
262
262
  fixable: "code",
263
263
  messages: { noHydrate: "[Deprecated] Use 'hydrateRoot()' instead." },
264
264
  schema: []
265
265
  },
266
- name: RULE_NAME$12,
267
- create: create$12,
266
+ name: RULE_NAME$13,
267
+ create: create$13,
268
268
  defaultOptions: []
269
269
  });
270
270
  const hydrate = "hydrate";
271
- function create$12(context) {
271
+ function create$13(context) {
272
272
  if (!context.sourceCode.text.includes(hydrate)) return {};
273
273
  const settings$1 = getSettingsFromContext(context);
274
274
  if (compare(settings$1.version, "18.0.0", "<")) return {};
@@ -320,8 +320,8 @@ function getFix$2(context, node) {
320
320
 
321
321
  //#endregion
322
322
  //#region src/rules/no-missing-button-type.ts
323
- const RULE_NAME$11 = "no-missing-button-type";
324
- const RULE_FEATURES$10 = ["FIX"];
323
+ const RULE_NAME$12 = "no-missing-button-type";
324
+ const RULE_FEATURES$11 = ["FIX"];
325
325
  const BUTTON_TYPES = [
326
326
  "button",
327
327
  "submit",
@@ -332,7 +332,7 @@ var no_missing_button_type_default = createRule({
332
332
  type: "problem",
333
333
  docs: {
334
334
  description: "Enforces explicit `type` attribute for `button` elements.",
335
- [Symbol.for("rule_features")]: RULE_FEATURES$10
335
+ [Symbol.for("rule_features")]: RULE_FEATURES$11
336
336
  },
337
337
  hasSuggestions: true,
338
338
  messages: {
@@ -341,32 +341,21 @@ var no_missing_button_type_default = createRule({
341
341
  },
342
342
  schema: []
343
343
  },
344
- name: RULE_NAME$11,
345
- create: create$11,
344
+ name: RULE_NAME$12,
345
+ create: create$12,
346
346
  defaultOptions: []
347
347
  });
348
- function create$11(context) {
348
+ function create$12(context) {
349
349
  const resolver = createJsxElementResolver(context);
350
350
  return { JSXElement(node) {
351
351
  const { domElementType } = resolver.resolve(node);
352
352
  if (domElementType !== "button") return;
353
- const typeAttribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("type");
354
- if (typeAttribute == null) {
355
- context.report({
356
- messageId: "noMissingButtonType",
357
- node: node.openingElement,
358
- suggest: getSuggest((type) => (fixer) => {
359
- return fixer.insertTextAfter(node.openingElement.name, ` type="${type}"`);
360
- })
361
- });
362
- return;
363
- }
364
- if (typeof resolveAttributeValue(context, typeAttribute).toStatic("type") === "string") return;
353
+ if (getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("type") != null) return;
365
354
  context.report({
366
355
  messageId: "noMissingButtonType",
367
- node: typeAttribute,
356
+ node: node.openingElement,
368
357
  suggest: getSuggest((type) => (fixer) => {
369
- return fixer.replaceText(typeAttribute, `type="${type}"`);
358
+ return fixer.insertTextAfter(node.openingElement.name, ` type="${type}"`);
370
359
  })
371
360
  });
372
361
  } };
@@ -381,14 +370,14 @@ function getSuggest(getFix$3) {
381
370
 
382
371
  //#endregion
383
372
  //#region src/rules/no-missing-iframe-sandbox.ts
384
- const RULE_NAME$10 = "no-missing-iframe-sandbox";
385
- const RULE_FEATURES$9 = ["FIX"];
373
+ const RULE_NAME$11 = "no-missing-iframe-sandbox";
374
+ const RULE_FEATURES$10 = ["FIX"];
386
375
  var no_missing_iframe_sandbox_default = createRule({
387
376
  meta: {
388
377
  type: "problem",
389
378
  docs: {
390
379
  description: "Enforces explicit `sandbox` attribute for `iframe` elements.",
391
- [Symbol.for("rule_features")]: RULE_FEATURES$9
380
+ [Symbol.for("rule_features")]: RULE_FEATURES$10
392
381
  },
393
382
  fixable: "code",
394
383
  hasSuggestions: true,
@@ -398,11 +387,11 @@ var no_missing_iframe_sandbox_default = createRule({
398
387
  },
399
388
  schema: []
400
389
  },
401
- name: RULE_NAME$10,
402
- create: create$10,
390
+ name: RULE_NAME$11,
391
+ create: create$11,
403
392
  defaultOptions: []
404
393
  });
405
- function create$10(context) {
394
+ function create$11(context) {
406
395
  const resolver = createJsxElementResolver(context);
407
396
  return { JSXElement(node) {
408
397
  const { domElementType } = resolver.resolve(node);
@@ -441,23 +430,23 @@ function create$10(context) {
441
430
 
442
431
  //#endregion
443
432
  //#region src/rules/no-namespace.ts
444
- const RULE_NAME$9 = "no-namespace";
445
- const RULE_FEATURES$8 = [];
433
+ const RULE_NAME$10 = "no-namespace";
434
+ const RULE_FEATURES$9 = [];
446
435
  var no_namespace_default = createRule({
447
436
  meta: {
448
437
  type: "problem",
449
438
  docs: {
450
439
  description: "Enforces the absence of a `namespace` in React elements.",
451
- [Symbol.for("rule_features")]: RULE_FEATURES$8
440
+ [Symbol.for("rule_features")]: RULE_FEATURES$9
452
441
  },
453
442
  messages: { noNamespace: "A React component '{{name}}' must not be in a namespace, as React does not support them." },
454
443
  schema: []
455
444
  },
456
- name: RULE_NAME$9,
457
- create: create$9,
445
+ name: RULE_NAME$10,
446
+ create: create$10,
458
447
  defaultOptions: []
459
448
  });
460
- function create$9(context) {
449
+ function create$10(context) {
461
450
  return { JSXElement(node) {
462
451
  const name$2 = getElementType(context, node);
463
452
  if (typeof name$2 !== "string" || !name$2.includes(":")) return;
@@ -471,24 +460,24 @@ function create$9(context) {
471
460
 
472
461
  //#endregion
473
462
  //#region src/rules/no-render.ts
474
- const RULE_NAME$8 = "no-render";
475
- const RULE_FEATURES$7 = ["MOD"];
463
+ const RULE_NAME$9 = "no-render";
464
+ const RULE_FEATURES$8 = ["MOD"];
476
465
  var no_render_default = createRule({
477
466
  meta: {
478
467
  type: "problem",
479
468
  docs: {
480
469
  description: "Replaces usages of `ReactDom.render()` with `createRoot(node).render()`.",
481
- [Symbol.for("rule_features")]: RULE_FEATURES$7
470
+ [Symbol.for("rule_features")]: RULE_FEATURES$8
482
471
  },
483
472
  fixable: "code",
484
473
  messages: { noRender: "[Deprecated] Use 'createRoot(node).render()' instead." },
485
474
  schema: []
486
475
  },
487
- name: RULE_NAME$8,
488
- create: create$8,
476
+ name: RULE_NAME$9,
477
+ create: create$9,
489
478
  defaultOptions: []
490
479
  });
491
- function create$8(context) {
480
+ function create$9(context) {
492
481
  if (!context.sourceCode.text.includes("render")) return {};
493
482
  const settings$1 = getSettingsFromContext(context);
494
483
  if (compare(settings$1.version, "18.0.0", "<")) return {};
@@ -540,8 +529,8 @@ function getFix$1(context, node) {
540
529
 
541
530
  //#endregion
542
531
  //#region src/rules/no-render-return-value.ts
543
- const RULE_NAME$7 = "no-render-return-value";
544
- const RULE_FEATURES$6 = [];
532
+ const RULE_NAME$8 = "no-render-return-value";
533
+ const RULE_FEATURES$7 = [];
545
534
  const banParentTypes = [
546
535
  AST_NODE_TYPES.VariableDeclarator,
547
536
  AST_NODE_TYPES.Property,
@@ -554,16 +543,16 @@ var no_render_return_value_default = createRule({
554
543
  type: "problem",
555
544
  docs: {
556
545
  description: "Disallow the return value of `ReactDOM.render`.",
557
- [Symbol.for("rule_features")]: RULE_FEATURES$6
546
+ [Symbol.for("rule_features")]: RULE_FEATURES$7
558
547
  },
559
548
  messages: { noRenderReturnValue: "Do not depend on the return value from 'ReactDOM.render'." },
560
549
  schema: []
561
550
  },
562
- name: RULE_NAME$7,
563
- create: create$7,
551
+ name: RULE_NAME$8,
552
+ create: create$8,
564
553
  defaultOptions: []
565
554
  });
566
- function create$7(context) {
555
+ function create$8(context) {
567
556
  const reactDomNames = new Set(["ReactDOM", "ReactDom"]);
568
557
  const renderNames = /* @__PURE__ */ new Set();
569
558
  return {
@@ -602,23 +591,23 @@ function create$7(context) {
602
591
 
603
592
  //#endregion
604
593
  //#region src/rules/no-script-url.ts
605
- const RULE_NAME$6 = "no-script-url";
606
- const RULE_FEATURES$5 = [];
594
+ const RULE_NAME$7 = "no-script-url";
595
+ const RULE_FEATURES$6 = [];
607
596
  var no_script_url_default = createRule({
608
597
  meta: {
609
598
  type: "problem",
610
599
  docs: {
611
600
  description: "Disallow `javascript:` URLs as attribute values.",
612
- [Symbol.for("rule_features")]: RULE_FEATURES$5
601
+ [Symbol.for("rule_features")]: RULE_FEATURES$6
613
602
  },
614
603
  messages: { noScriptUrl: "Using a `javascript:` URL is a security risk and should be avoided." },
615
604
  schema: []
616
605
  },
617
- name: RULE_NAME$6,
618
- create: create$6,
606
+ name: RULE_NAME$7,
607
+ create: create$7,
619
608
  defaultOptions: []
620
609
  });
621
- function create$6(context) {
610
+ function create$7(context) {
622
611
  return { JSXAttribute(node) {
623
612
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) return;
624
613
  const value = resolveAttributeValue(context, node).toStatic();
@@ -631,23 +620,23 @@ function create$6(context) {
631
620
 
632
621
  //#endregion
633
622
  //#region src/rules/no-string-style-prop.ts
634
- const RULE_NAME$5 = "no-string-style-prop";
635
- const RULE_FEATURES$4 = [];
623
+ const RULE_NAME$6 = "no-string-style-prop";
624
+ const RULE_FEATURES$5 = [];
636
625
  var no_string_style_prop_default = createRule({
637
626
  meta: {
638
627
  type: "problem",
639
628
  docs: {
640
629
  description: "Disallows the use of string style prop.",
641
- [Symbol.for("rule_features")]: RULE_FEATURES$4
630
+ [Symbol.for("rule_features")]: RULE_FEATURES$5
642
631
  },
643
632
  messages: { noStringStyleProp: "Do not use string style prop. Use an object instead." },
644
633
  schema: []
645
634
  },
646
- name: RULE_NAME$5,
647
- create: create$5,
635
+ name: RULE_NAME$6,
636
+ create: create$6,
648
637
  defaultOptions: []
649
638
  });
650
- function create$5(context) {
639
+ function create$6(context) {
651
640
  return { JSXElement(node) {
652
641
  if (!isHostElement(context, node)) return;
653
642
  const attribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("style");
@@ -662,7 +651,7 @@ function create$5(context) {
662
651
 
663
652
  //#endregion
664
653
  //#region src/rules/no-unknown-property.ts
665
- const RULE_NAME$4 = "no-unknown-property";
654
+ const RULE_NAME$5 = "no-unknown-property";
666
655
  const DEFAULTS = {
667
656
  ignore: [],
668
657
  requireDataLowercase: false
@@ -1711,8 +1700,8 @@ var no_unknown_property_default = createRule({
1711
1700
  }
1712
1701
  }]
1713
1702
  },
1714
- name: RULE_NAME$4,
1715
- create: create$4,
1703
+ name: RULE_NAME$5,
1704
+ create: create$5,
1716
1705
  defaultOptions: []
1717
1706
  });
1718
1707
  /**
@@ -1720,7 +1709,7 @@ var no_unknown_property_default = createRule({
1720
1709
  * @param context - ESLint rule context
1721
1710
  * @returns Rule listener
1722
1711
  */
1723
- function create$4(context) {
1712
+ function create$5(context) {
1724
1713
  /**
1725
1714
  * Gets the ignore configuration from rule options
1726
1715
  * @returns Array of attribute names to ignore
@@ -1796,8 +1785,8 @@ function create$4(context) {
1796
1785
 
1797
1786
  //#endregion
1798
1787
  //#region src/rules/no-unsafe-iframe-sandbox.ts
1799
- const RULE_NAME$3 = "no-unsafe-iframe-sandbox";
1800
- const RULE_FEATURES$3 = [];
1788
+ const RULE_NAME$4 = "no-unsafe-iframe-sandbox";
1789
+ const RULE_FEATURES$4 = [];
1801
1790
  const unsafeSandboxValues = [["allow-scripts", "allow-same-origin"]];
1802
1791
  function isSafeSandbox(value) {
1803
1792
  if (typeof value !== "string") return false;
@@ -1810,16 +1799,16 @@ var no_unsafe_iframe_sandbox_default = createRule({
1810
1799
  type: "problem",
1811
1800
  docs: {
1812
1801
  description: "Enforces `sandbox` attribute for `iframe` elements is not set to unsafe combinations.",
1813
- [Symbol.for("rule_features")]: RULE_FEATURES$3
1802
+ [Symbol.for("rule_features")]: RULE_FEATURES$4
1814
1803
  },
1815
1804
  messages: { noUnsafeIframeSandbox: "Unsafe 'sandbox' attribute value on 'iframe' component." },
1816
1805
  schema: []
1817
1806
  },
1818
- name: RULE_NAME$3,
1819
- create: create$3,
1807
+ name: RULE_NAME$4,
1808
+ create: create$4,
1820
1809
  defaultOptions: []
1821
1810
  });
1822
- function create$3(context) {
1811
+ function create$4(context) {
1823
1812
  const resolver = createJsxElementResolver(context);
1824
1813
  return { JSXElement(node) {
1825
1814
  const { domElementType } = resolver.resolve(node);
@@ -1837,8 +1826,8 @@ function create$3(context) {
1837
1826
 
1838
1827
  //#endregion
1839
1828
  //#region src/rules/no-unsafe-target-blank.ts
1840
- const RULE_NAME$2 = "no-unsafe-target-blank";
1841
- const RULE_FEATURES$2 = ["FIX"];
1829
+ const RULE_NAME$3 = "no-unsafe-target-blank";
1830
+ const RULE_FEATURES$3 = ["FIX"];
1842
1831
  /**
1843
1832
  * Checks if a value appears to be an external link.
1844
1833
  * External links typically start with http(s):// or have protocol-relative format.
@@ -1864,7 +1853,7 @@ var no_unsafe_target_blank_default = createRule({
1864
1853
  type: "problem",
1865
1854
  docs: {
1866
1855
  description: "Disallow `target=\"_blank\"` without `rel=\"noreferrer noopener\"`.",
1867
- [Symbol.for("rule_features")]: RULE_FEATURES$2
1856
+ [Symbol.for("rule_features")]: RULE_FEATURES$3
1868
1857
  },
1869
1858
  fixable: "code",
1870
1859
  hasSuggestions: true,
@@ -1874,11 +1863,11 @@ var no_unsafe_target_blank_default = createRule({
1874
1863
  },
1875
1864
  schema: []
1876
1865
  },
1877
- name: RULE_NAME$2,
1878
- create: create$2,
1866
+ name: RULE_NAME$3,
1867
+ create: create$3,
1879
1868
  defaultOptions: []
1880
1869
  });
1881
- function create$2(context) {
1870
+ function create$3(context) {
1882
1871
  const resolver = createJsxElementResolver(context);
1883
1872
  return { JSXElement(node) {
1884
1873
  const { domElementType } = resolver.resolve(node);
@@ -1922,24 +1911,24 @@ function create$2(context) {
1922
1911
 
1923
1912
  //#endregion
1924
1913
  //#region src/rules/no-use-form-state.ts
1925
- const RULE_NAME$1 = "no-use-form-state";
1926
- const RULE_FEATURES$1 = ["MOD"];
1914
+ const RULE_NAME$2 = "no-use-form-state";
1915
+ const RULE_FEATURES$2 = ["MOD"];
1927
1916
  var no_use_form_state_default = createRule({
1928
1917
  meta: {
1929
1918
  type: "problem",
1930
1919
  docs: {
1931
1920
  description: "Replaces usages of `useFormState` with `useActionState`.",
1932
- [Symbol.for("rule_features")]: RULE_FEATURES$1
1921
+ [Symbol.for("rule_features")]: RULE_FEATURES$2
1933
1922
  },
1934
1923
  fixable: "code",
1935
1924
  messages: { noUseFormState: "[Deprecated] Use 'useActionState' from 'react' package instead." },
1936
1925
  schema: []
1937
1926
  },
1938
- name: RULE_NAME$1,
1939
- create: create$1,
1927
+ name: RULE_NAME$2,
1928
+ create: create$2,
1940
1929
  defaultOptions: []
1941
1930
  });
1942
- function create$1(context) {
1931
+ function create$2(context) {
1943
1932
  if (!context.sourceCode.text.includes("useFormState")) return {};
1944
1933
  const settings$1 = getSettingsFromContext(context);
1945
1934
  if (compare(settings$1.version, "19.0.0", "<")) return {};
@@ -1989,8 +1978,8 @@ function getFix(context, node) {
1989
1978
 
1990
1979
  //#endregion
1991
1980
  //#region src/rules/no-void-elements-with-children.ts
1992
- const RULE_NAME = "no-void-elements-with-children";
1993
- const RULE_FEATURES = [];
1981
+ const RULE_NAME$1 = "no-void-elements-with-children";
1982
+ const RULE_FEATURES$1 = [];
1994
1983
  const voidElements = new Set([
1995
1984
  "area",
1996
1985
  "base",
@@ -2014,16 +2003,16 @@ var no_void_elements_with_children_default = createRule({
2014
2003
  type: "problem",
2015
2004
  docs: {
2016
2005
  description: "Disallow `children` in void DOM elements.",
2017
- [Symbol.for("rule_features")]: RULE_FEATURES
2006
+ [Symbol.for("rule_features")]: RULE_FEATURES$1
2018
2007
  },
2019
2008
  messages: { noVoidElementsWithChildren: "'{{element}}' is a void element tag and must not have children." },
2020
2009
  schema: []
2021
2010
  },
2022
- name: RULE_NAME,
2023
- create,
2011
+ name: RULE_NAME$1,
2012
+ create: create$1,
2024
2013
  defaultOptions: []
2025
2014
  });
2026
- function create(context) {
2015
+ function create$1(context) {
2027
2016
  const resolver = createJsxElementResolver(context);
2028
2017
  return { JSXElement(node) {
2029
2018
  const { domElementType: elementName } = resolver.resolve(node);
@@ -2044,6 +2033,53 @@ function create(context) {
2044
2033
  } };
2045
2034
  }
2046
2035
 
2036
+ //#endregion
2037
+ //#region src/rules/prefer-namespace-import.ts
2038
+ const RULE_NAME = "prefer-namespace-import";
2039
+ const RULE_FEATURES = ["FIX"];
2040
+ var prefer_namespace_import_default = createRule({
2041
+ meta: {
2042
+ type: "problem",
2043
+ docs: {
2044
+ description: "Enforces React Dom is imported via a namespace import.",
2045
+ [Symbol.for("rule_features")]: RULE_FEATURES
2046
+ },
2047
+ fixable: "code",
2048
+ messages: { preferNamespaceImport: "Prefer importing React DOM via a namespace import." },
2049
+ schema: []
2050
+ },
2051
+ name: RULE_NAME,
2052
+ create,
2053
+ defaultOptions: []
2054
+ });
2055
+ const importSources = [
2056
+ "react-dom",
2057
+ "react-dom/client",
2058
+ "react-dom/server"
2059
+ ];
2060
+ function create(context) {
2061
+ return { [`ImportDeclaration ImportDefaultSpecifier`](node) {
2062
+ const importSource = node.parent.source.value;
2063
+ if (!importSources.includes(importSource)) return;
2064
+ const hasOtherSpecifiers = node.parent.specifiers.length > 1;
2065
+ context.report({
2066
+ messageId: "preferNamespaceImport",
2067
+ node: hasOtherSpecifiers ? node : node.parent,
2068
+ data: { importSource },
2069
+ fix(fixer) {
2070
+ const importDeclarationText = context.sourceCode.getText(node.parent);
2071
+ const semi = importDeclarationText.endsWith(";") ? ";" : "";
2072
+ const quote = node.parent.source.raw.at(0) ?? "'";
2073
+ const importStringPrefix = `import${node.parent.importKind === "type" ? " type" : ""}`;
2074
+ const importSourceQuoted = `${quote}${importSource}${quote}`;
2075
+ if (!hasOtherSpecifiers) return fixer.replaceText(node.parent, `${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`);
2076
+ const specifiers = importDeclarationText.slice(importDeclarationText.indexOf("{"), importDeclarationText.indexOf("}") + 1);
2077
+ return fixer.replaceText(node.parent, [`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`, `${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semi}`].join("\n"));
2078
+ }
2079
+ });
2080
+ } };
2081
+ }
2082
+
2047
2083
  //#endregion
2048
2084
  //#region src/plugin.ts
2049
2085
  const plugin = {
@@ -2068,7 +2104,8 @@ const plugin = {
2068
2104
  "no-unsafe-iframe-sandbox": no_unsafe_iframe_sandbox_default,
2069
2105
  "no-unsafe-target-blank": no_unsafe_target_blank_default,
2070
2106
  "no-use-form-state": no_use_form_state_default,
2071
- "no-void-elements-with-children": no_void_elements_with_children_default
2107
+ "no-void-elements-with-children": no_void_elements_with_children_default,
2108
+ "prefer-namespace-import": prefer_namespace_import_default
2072
2109
  }
2073
2110
  };
2074
2111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "2.0.2",
3
+ "version": "2.0.3-beta.0",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -35,18 +35,18 @@
35
35
  "./package.json"
36
36
  ],
37
37
  "dependencies": {
38
- "@typescript-eslint/scope-manager": "^8.44.1",
39
- "@typescript-eslint/types": "^8.44.1",
40
- "@typescript-eslint/utils": "^8.44.1",
38
+ "@typescript-eslint/scope-manager": "^8.45.0",
39
+ "@typescript-eslint/types": "^8.45.0",
40
+ "@typescript-eslint/utils": "^8.45.0",
41
41
  "compare-versions": "^6.1.1",
42
42
  "string-ts": "^2.2.1",
43
43
  "ts-pattern": "^5.8.0",
44
- "@eslint-react/ast": "2.0.2",
45
- "@eslint-react/core": "2.0.2",
46
- "@eslint-react/eff": "2.0.2",
47
- "@eslint-react/kit": "2.0.2",
48
- "@eslint-react/shared": "2.0.2",
49
- "@eslint-react/var": "2.0.2"
44
+ "@eslint-react/core": "2.0.3-beta.0",
45
+ "@eslint-react/ast": "2.0.3-beta.0",
46
+ "@eslint-react/kit": "2.0.3-beta.0",
47
+ "@eslint-react/var": "2.0.3-beta.0",
48
+ "@eslint-react/eff": "2.0.3-beta.0",
49
+ "@eslint-react/shared": "2.0.3-beta.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/react": "^19.1.15",