eslint-plugin-react-dom 1.47.0-next.2 → 1.47.1-next.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
@@ -67,7 +67,7 @@ var settings = {
67
67
 
68
68
  // package.json
69
69
  var name2 = "eslint-plugin-react-dom";
70
- var version = "1.47.0-next.2";
70
+ var version = "1.47.1-next.0";
71
71
  function createJsxElementResolver(context) {
72
72
  const {
73
73
  additionalComponents,
@@ -135,15 +135,15 @@ var no_dangerously_set_innerhtml_default = createRule({
135
135
  create,
136
136
  defaultOptions: []
137
137
  });
138
+ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
138
139
  function create(context) {
139
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
140
+ if (!context.sourceCode.text.includes(dangerouslySetInnerHTML)) return {};
140
141
  return {
141
142
  JSXElement(node) {
142
- const attributes = node.openingElement.attributes;
143
143
  const attribute = ER__namespace.getAttribute(
144
144
  context,
145
- "dangerouslySetInnerHTML",
146
- attributes,
145
+ dangerouslySetInnerHTML,
146
+ node.openingElement.attributes,
147
147
  context.sourceCode.getScope(node)
148
148
  );
149
149
  if (attribute == null) return;
@@ -172,14 +172,15 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
172
172
  create: create2,
173
173
  defaultOptions: []
174
174
  });
175
+ var dangerouslySetInnerHTML2 = "dangerouslySetInnerHTML";
175
176
  function create2(context) {
176
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
177
+ if (!context.sourceCode.text.includes(dangerouslySetInnerHTML2)) return {};
177
178
  return {
178
179
  JSXElement(node) {
179
180
  const attributes = node.openingElement.attributes;
180
181
  const initialScope = context.sourceCode.getScope(node);
181
182
  const hasChildren = hasChildrenWithin(node) || ER__namespace.hasAttribute(context, "children", attributes, initialScope);
182
- if (hasChildren && ER__namespace.hasAttribute(context, "dangerouslySetInnerHTML", attributes, initialScope)) {
183
+ if (hasChildren && ER__namespace.hasAttribute(context, dangerouslySetInnerHTML2, attributes, initialScope)) {
183
184
  context.report({
184
185
  messageId: "noDangerouslySetInnerhtmlWithChildren",
185
186
  node
@@ -209,19 +210,20 @@ var no_find_dom_node_default = createRule({
209
210
  create: create3,
210
211
  defaultOptions: []
211
212
  });
213
+ var findDOMNode = "findDOMNode";
212
214
  function create3(context) {
213
- if (!context.sourceCode.text.includes("findDOMNode")) return {};
215
+ if (!context.sourceCode.text.includes(findDOMNode)) return {};
214
216
  return {
215
217
  CallExpression(node) {
216
218
  const { callee } = node;
217
219
  switch (callee.type) {
218
220
  case types.AST_NODE_TYPES.Identifier:
219
- if (callee.name === "findDOMNode") {
221
+ if (callee.name === findDOMNode) {
220
222
  context.report({ messageId: "noFindDomNode", node });
221
223
  }
222
224
  return;
223
225
  case types.AST_NODE_TYPES.MemberExpression:
224
- if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
226
+ if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === findDOMNode) {
225
227
  context.report({ messageId: "noFindDomNode", node });
226
228
  }
227
229
  return;
@@ -247,19 +249,20 @@ var no_flush_sync_default = createRule({
247
249
  create: create4,
248
250
  defaultOptions: []
249
251
  });
252
+ var flushSync = "flushSync";
250
253
  function create4(context) {
251
- if (!context.sourceCode.text.includes("flushSync")) return {};
254
+ if (!context.sourceCode.text.includes(flushSync)) return {};
252
255
  return {
253
256
  CallExpression(node) {
254
257
  const { callee } = node;
255
258
  switch (callee.type) {
256
259
  case types.AST_NODE_TYPES.Identifier:
257
- if (callee.name === "flushSync") {
260
+ if (callee.name === flushSync) {
258
261
  context.report({ messageId: "noFlushSync", node });
259
262
  }
260
263
  return;
261
264
  case types.AST_NODE_TYPES.MemberExpression:
262
- if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
265
+ if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === flushSync) {
263
266
  context.report({ messageId: "noFlushSync", node });
264
267
  }
265
268
  return;
@@ -288,8 +291,9 @@ var no_hydrate_default = createRule({
288
291
  create: create5,
289
292
  defaultOptions: []
290
293
  });
294
+ var hydrate = "hydrate";
291
295
  function create5(context) {
292
- if (!context.sourceCode.text.includes("hydrate")) return {};
296
+ if (!context.sourceCode.text.includes(hydrate)) return {};
293
297
  const settings2 = shared.getSettingsFromContext(context);
294
298
  if (compareVersions.compare(settings2.version, "18.0.0", "<")) return {};
295
299
  const reactDomNames = /* @__PURE__ */ new Set();
@@ -304,7 +308,7 @@ function create5(context) {
304
308
  fix: getFix(context, node)
305
309
  });
306
310
  return;
307
- case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.object.type === types.AST_NODE_TYPES.Identifier && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "hydrate" && reactDomNames.has(node.callee.object.name)):
311
+ case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.object.type === types.AST_NODE_TYPES.Identifier && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === hydrate && reactDomNames.has(node.callee.object.name)):
308
312
  context.report({
309
313
  messageId: "noHydrate",
310
314
  node,
@@ -320,7 +324,7 @@ function create5(context) {
320
324
  switch (specifier.type) {
321
325
  case types.AST_NODE_TYPES.ImportSpecifier:
322
326
  if (specifier.imported.type !== types.AST_NODE_TYPES.Identifier) continue;
323
- if (specifier.imported.name === "hydrate") {
327
+ if (specifier.imported.name === hydrate) {
324
328
  hydrateNames.add(specifier.local.name);
325
329
  }
326
330
  continue;
@@ -534,7 +538,7 @@ function create9(context) {
534
538
  if (!context.sourceCode.text.includes("render")) return {};
535
539
  const settings2 = shared.getSettingsFromContext(context);
536
540
  if (compareVersions.compare(settings2.version, "18.0.0", "<")) return {};
537
- const reactDomNames = /* @__PURE__ */ new Set();
541
+ const reactDomNames = /* @__PURE__ */ new Set(["ReactDOM", "ReactDom"]);
538
542
  const renderNames = /* @__PURE__ */ new Set();
539
543
  return {
540
544
  CallExpression(node) {
@@ -603,7 +607,7 @@ var no_render_return_value_default = createRule({
603
607
  [Symbol.for("rule_features")]: RULE_FEATURES10
604
608
  },
605
609
  messages: {
606
- noRenderReturnValue: "Do not depend on the return value from '{{objectName}}.render'."
610
+ noRenderReturnValue: "Do not depend on the return value from 'ReactDOM.render'."
607
611
  },
608
612
  schema: []
609
613
  },
@@ -612,29 +616,42 @@ var no_render_return_value_default = createRule({
612
616
  defaultOptions: []
613
617
  });
614
618
  function create10(context) {
619
+ const reactDomNames = /* @__PURE__ */ new Set(["ReactDOM", "ReactDom"]);
620
+ const renderNames = /* @__PURE__ */ new Set();
615
621
  return {
616
622
  CallExpression(node) {
617
- const { callee, parent } = node;
618
- if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
619
- return;
620
- }
621
- if (callee.object.type !== types.AST_NODE_TYPES.Identifier) {
622
- return;
623
- }
624
- if (!("name" in callee.object)) {
625
- return;
626
- }
627
- const objectName = callee.object.name;
628
- if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== types.AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST__namespace.isOneOf(banParentTypes)(parent)) {
629
- return;
623
+ switch (true) {
624
+ case (node.callee.type === types.AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name) && banParentTypes.includes(node.parent.type)):
625
+ context.report({
626
+ messageId: "noRenderReturnValue",
627
+ node
628
+ });
629
+ return;
630
+ case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.object.type === types.AST_NODE_TYPES.Identifier && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name) && banParentTypes.includes(node.parent.type)):
631
+ context.report({
632
+ messageId: "noRenderReturnValue",
633
+ node
634
+ });
635
+ return;
630
636
  }
631
- context.report({
632
- messageId: "noRenderReturnValue",
633
- node,
634
- data: {
635
- objectName
637
+ },
638
+ ImportDeclaration(node) {
639
+ const [baseSource] = node.source.value.split("/");
640
+ if (baseSource !== "react-dom") return;
641
+ for (const specifier of node.specifiers) {
642
+ switch (specifier.type) {
643
+ case types.AST_NODE_TYPES.ImportSpecifier:
644
+ if (specifier.imported.type !== types.AST_NODE_TYPES.Identifier) continue;
645
+ if (specifier.imported.name === "render") {
646
+ renderNames.add(specifier.local.name);
647
+ }
648
+ continue;
649
+ case types.AST_NODE_TYPES.ImportDefaultSpecifier:
650
+ case types.AST_NODE_TYPES.ImportNamespaceSpecifier:
651
+ reactDomNames.add(specifier.local.name);
652
+ continue;
636
653
  }
637
- });
654
+ }
638
655
  }
639
656
  };
640
657
  }
@@ -662,8 +679,7 @@ function create11(context) {
662
679
  if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier || node.value == null) {
663
680
  return;
664
681
  }
665
- const attributeName = ER__namespace.getAttributeName(context, node);
666
- const attributeValue = ER__namespace.getAttributeValue(context, node, attributeName);
682
+ const attributeValue = ER__namespace.getAttributeValue(context, node, ER__namespace.getAttributeName(context, node));
667
683
  if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
668
684
  if (kit.RE.JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
669
685
  context.report({
package/dist/index.mjs CHANGED
@@ -44,7 +44,7 @@ var settings = {
44
44
 
45
45
  // package.json
46
46
  var name2 = "eslint-plugin-react-dom";
47
- var version = "1.47.0-next.2";
47
+ var version = "1.47.1-next.0";
48
48
  function createJsxElementResolver(context) {
49
49
  const {
50
50
  additionalComponents,
@@ -112,15 +112,15 @@ var no_dangerously_set_innerhtml_default = createRule({
112
112
  create,
113
113
  defaultOptions: []
114
114
  });
115
+ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
115
116
  function create(context) {
116
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
117
+ if (!context.sourceCode.text.includes(dangerouslySetInnerHTML)) return {};
117
118
  return {
118
119
  JSXElement(node) {
119
- const attributes = node.openingElement.attributes;
120
120
  const attribute = ER.getAttribute(
121
121
  context,
122
- "dangerouslySetInnerHTML",
123
- attributes,
122
+ dangerouslySetInnerHTML,
123
+ node.openingElement.attributes,
124
124
  context.sourceCode.getScope(node)
125
125
  );
126
126
  if (attribute == null) return;
@@ -149,14 +149,15 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
149
149
  create: create2,
150
150
  defaultOptions: []
151
151
  });
152
+ var dangerouslySetInnerHTML2 = "dangerouslySetInnerHTML";
152
153
  function create2(context) {
153
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
154
+ if (!context.sourceCode.text.includes(dangerouslySetInnerHTML2)) return {};
154
155
  return {
155
156
  JSXElement(node) {
156
157
  const attributes = node.openingElement.attributes;
157
158
  const initialScope = context.sourceCode.getScope(node);
158
159
  const hasChildren = hasChildrenWithin(node) || ER.hasAttribute(context, "children", attributes, initialScope);
159
- if (hasChildren && ER.hasAttribute(context, "dangerouslySetInnerHTML", attributes, initialScope)) {
160
+ if (hasChildren && ER.hasAttribute(context, dangerouslySetInnerHTML2, attributes, initialScope)) {
160
161
  context.report({
161
162
  messageId: "noDangerouslySetInnerhtmlWithChildren",
162
163
  node
@@ -186,19 +187,20 @@ var no_find_dom_node_default = createRule({
186
187
  create: create3,
187
188
  defaultOptions: []
188
189
  });
190
+ var findDOMNode = "findDOMNode";
189
191
  function create3(context) {
190
- if (!context.sourceCode.text.includes("findDOMNode")) return {};
192
+ if (!context.sourceCode.text.includes(findDOMNode)) return {};
191
193
  return {
192
194
  CallExpression(node) {
193
195
  const { callee } = node;
194
196
  switch (callee.type) {
195
197
  case AST_NODE_TYPES.Identifier:
196
- if (callee.name === "findDOMNode") {
198
+ if (callee.name === findDOMNode) {
197
199
  context.report({ messageId: "noFindDomNode", node });
198
200
  }
199
201
  return;
200
202
  case AST_NODE_TYPES.MemberExpression:
201
- if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
203
+ if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === findDOMNode) {
202
204
  context.report({ messageId: "noFindDomNode", node });
203
205
  }
204
206
  return;
@@ -224,19 +226,20 @@ var no_flush_sync_default = createRule({
224
226
  create: create4,
225
227
  defaultOptions: []
226
228
  });
229
+ var flushSync = "flushSync";
227
230
  function create4(context) {
228
- if (!context.sourceCode.text.includes("flushSync")) return {};
231
+ if (!context.sourceCode.text.includes(flushSync)) return {};
229
232
  return {
230
233
  CallExpression(node) {
231
234
  const { callee } = node;
232
235
  switch (callee.type) {
233
236
  case AST_NODE_TYPES.Identifier:
234
- if (callee.name === "flushSync") {
237
+ if (callee.name === flushSync) {
235
238
  context.report({ messageId: "noFlushSync", node });
236
239
  }
237
240
  return;
238
241
  case AST_NODE_TYPES.MemberExpression:
239
- if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
242
+ if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === flushSync) {
240
243
  context.report({ messageId: "noFlushSync", node });
241
244
  }
242
245
  return;
@@ -265,8 +268,9 @@ var no_hydrate_default = createRule({
265
268
  create: create5,
266
269
  defaultOptions: []
267
270
  });
271
+ var hydrate = "hydrate";
268
272
  function create5(context) {
269
- if (!context.sourceCode.text.includes("hydrate")) return {};
273
+ if (!context.sourceCode.text.includes(hydrate)) return {};
270
274
  const settings2 = getSettingsFromContext(context);
271
275
  if (compare(settings2.version, "18.0.0", "<")) return {};
272
276
  const reactDomNames = /* @__PURE__ */ new Set();
@@ -281,7 +285,7 @@ function create5(context) {
281
285
  fix: getFix(context, node)
282
286
  });
283
287
  return;
284
- case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "hydrate" && reactDomNames.has(node.callee.object.name)):
288
+ case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === hydrate && reactDomNames.has(node.callee.object.name)):
285
289
  context.report({
286
290
  messageId: "noHydrate",
287
291
  node,
@@ -297,7 +301,7 @@ function create5(context) {
297
301
  switch (specifier.type) {
298
302
  case AST_NODE_TYPES.ImportSpecifier:
299
303
  if (specifier.imported.type !== AST_NODE_TYPES.Identifier) continue;
300
- if (specifier.imported.name === "hydrate") {
304
+ if (specifier.imported.name === hydrate) {
301
305
  hydrateNames.add(specifier.local.name);
302
306
  }
303
307
  continue;
@@ -511,7 +515,7 @@ function create9(context) {
511
515
  if (!context.sourceCode.text.includes("render")) return {};
512
516
  const settings2 = getSettingsFromContext(context);
513
517
  if (compare(settings2.version, "18.0.0", "<")) return {};
514
- const reactDomNames = /* @__PURE__ */ new Set();
518
+ const reactDomNames = /* @__PURE__ */ new Set(["ReactDOM", "ReactDom"]);
515
519
  const renderNames = /* @__PURE__ */ new Set();
516
520
  return {
517
521
  CallExpression(node) {
@@ -580,7 +584,7 @@ var no_render_return_value_default = createRule({
580
584
  [Symbol.for("rule_features")]: RULE_FEATURES10
581
585
  },
582
586
  messages: {
583
- noRenderReturnValue: "Do not depend on the return value from '{{objectName}}.render'."
587
+ noRenderReturnValue: "Do not depend on the return value from 'ReactDOM.render'."
584
588
  },
585
589
  schema: []
586
590
  },
@@ -589,29 +593,42 @@ var no_render_return_value_default = createRule({
589
593
  defaultOptions: []
590
594
  });
591
595
  function create10(context) {
596
+ const reactDomNames = /* @__PURE__ */ new Set(["ReactDOM", "ReactDom"]);
597
+ const renderNames = /* @__PURE__ */ new Set();
592
598
  return {
593
599
  CallExpression(node) {
594
- const { callee, parent } = node;
595
- if (callee.type !== AST_NODE_TYPES.MemberExpression) {
596
- return;
597
- }
598
- if (callee.object.type !== AST_NODE_TYPES.Identifier) {
599
- return;
600
- }
601
- if (!("name" in callee.object)) {
602
- return;
603
- }
604
- const objectName = callee.object.name;
605
- if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST.isOneOf(banParentTypes)(parent)) {
606
- return;
600
+ switch (true) {
601
+ case (node.callee.type === AST_NODE_TYPES.Identifier && renderNames.has(node.callee.name) && banParentTypes.includes(node.parent.type)):
602
+ context.report({
603
+ messageId: "noRenderReturnValue",
604
+ node
605
+ });
606
+ return;
607
+ case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "render" && reactDomNames.has(node.callee.object.name) && banParentTypes.includes(node.parent.type)):
608
+ context.report({
609
+ messageId: "noRenderReturnValue",
610
+ node
611
+ });
612
+ return;
607
613
  }
608
- context.report({
609
- messageId: "noRenderReturnValue",
610
- node,
611
- data: {
612
- objectName
614
+ },
615
+ ImportDeclaration(node) {
616
+ const [baseSource] = node.source.value.split("/");
617
+ if (baseSource !== "react-dom") return;
618
+ for (const specifier of node.specifiers) {
619
+ switch (specifier.type) {
620
+ case AST_NODE_TYPES.ImportSpecifier:
621
+ if (specifier.imported.type !== AST_NODE_TYPES.Identifier) continue;
622
+ if (specifier.imported.name === "render") {
623
+ renderNames.add(specifier.local.name);
624
+ }
625
+ continue;
626
+ case AST_NODE_TYPES.ImportDefaultSpecifier:
627
+ case AST_NODE_TYPES.ImportNamespaceSpecifier:
628
+ reactDomNames.add(specifier.local.name);
629
+ continue;
613
630
  }
614
- });
631
+ }
615
632
  }
616
633
  };
617
634
  }
@@ -639,8 +656,7 @@ function create11(context) {
639
656
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) {
640
657
  return;
641
658
  }
642
- const attributeName = ER.getAttributeName(context, node);
643
- const attributeValue = ER.getAttributeValue(context, node, attributeName);
659
+ const attributeValue = ER.getAttributeValue(context, node, ER.getAttributeName(context, node));
644
660
  if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
645
661
  if (RE.JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
646
662
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "1.47.0-next.2",
3
+ "version": "1.47.1-next.0",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -49,12 +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.47.0-next.2",
53
- "@eslint-react/eff": "1.47.0-next.2",
54
- "@eslint-react/shared": "1.47.0-next.2",
55
- "@eslint-react/var": "1.47.0-next.2",
56
- "@eslint-react/core": "1.47.0-next.2",
57
- "@eslint-react/kit": "1.47.0-next.2"
52
+ "@eslint-react/ast": "1.47.1-next.0",
53
+ "@eslint-react/eff": "1.47.1-next.0",
54
+ "@eslint-react/kit": "1.47.1-next.0",
55
+ "@eslint-react/shared": "1.47.1-next.0",
56
+ "@eslint-react/core": "1.47.1-next.0",
57
+ "@eslint-react/var": "1.47.1-next.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/react": "^19.1.1",