eslint-plugin-react-dom 1.21.1-next.1 → 1.22.0-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/README.md CHANGED
@@ -29,7 +29,6 @@ export default [
29
29
  },
30
30
  rules: {
31
31
  // react-dom recommended rules
32
- "react-dom/no-children-in-void-dom-elements": "warn",
33
32
  "react-dom/no-dangerously-set-innerhtml-with-children": "error",
34
33
  "react-dom/no-dangerously-set-innerhtml": "warn",
35
34
  "react-dom/no-find-dom-node": "error",
@@ -41,6 +40,7 @@ export default [
41
40
  "react-dom/no-unknown-property": "warn",
42
41
  "react-dom/no-unsafe-iframe-sandbox": "warn",
43
42
  "react-dom/no-unsafe-target-blank": "warn",
43
+ "react-dom/no-void-elements-with-children": "warn",
44
44
  },
45
45
  },
46
46
  ];
package/dist/index.d.mts CHANGED
@@ -6,7 +6,6 @@ declare const _default: {
6
6
  readonly version: string;
7
7
  };
8
8
  readonly rules: {
9
- readonly "no-children-in-void-dom-elements": _typescript_eslint_utils_ts_eslint.RuleModule<"noChildrenInVoidDomElements", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
10
9
  readonly "no-dangerously-set-innerhtml": _typescript_eslint_utils_ts_eslint.RuleModule<"noDangerouslySetInnerhtml", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
11
10
  readonly "no-dangerously-set-innerhtml-with-children": _typescript_eslint_utils_ts_eslint.RuleModule<"noDangerouslySetInnerhtmlWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
12
11
  readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
@@ -18,6 +17,9 @@ declare const _default: {
18
17
  readonly "no-unknown-property": _typescript_eslint_utils_ts_eslint.RuleModule<string, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
19
18
  readonly "no-unsafe-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
19
  readonly "no-unsafe-target-blank": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeTargetBlank", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
+ readonly "no-void-elements-with-children": _typescript_eslint_utils_ts_eslint.RuleModule<"noVoidElementsWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
21
+ /** @deprecated Use `no-void-elements-with-children` instead */
22
+ readonly "no-children-in-void-dom-elements": _typescript_eslint_utils_ts_eslint.RuleModule<"noVoidElementsWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
21
23
  };
22
24
  };
23
25
 
package/dist/index.d.ts CHANGED
@@ -6,7 +6,6 @@ declare const _default: {
6
6
  readonly version: string;
7
7
  };
8
8
  readonly rules: {
9
- readonly "no-children-in-void-dom-elements": _typescript_eslint_utils_ts_eslint.RuleModule<"noChildrenInVoidDomElements", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
10
9
  readonly "no-dangerously-set-innerhtml": _typescript_eslint_utils_ts_eslint.RuleModule<"noDangerouslySetInnerhtml", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
11
10
  readonly "no-dangerously-set-innerhtml-with-children": _typescript_eslint_utils_ts_eslint.RuleModule<"noDangerouslySetInnerhtmlWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
12
11
  readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
@@ -18,6 +17,9 @@ declare const _default: {
18
17
  readonly "no-unknown-property": _typescript_eslint_utils_ts_eslint.RuleModule<string, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
19
18
  readonly "no-unsafe-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
19
  readonly "no-unsafe-target-blank": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeTargetBlank", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
+ readonly "no-void-elements-with-children": _typescript_eslint_utils_ts_eslint.RuleModule<"noVoidElementsWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
21
+ /** @deprecated Use `no-void-elements-with-children` instead */
22
+ readonly "no-children-in-void-dom-elements": _typescript_eslint_utils_ts_eslint.RuleModule<"noVoidElementsWithChildren", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
21
23
  };
22
24
  };
23
25
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var eff = require('@eslint-react/eff');
4
- var JSX9 = require('@eslint-react/jsx');
4
+ var JSX8 = require('@eslint-react/jsx');
5
5
  var shared = require('@eslint-react/shared');
6
6
  var types = require('@typescript-eslint/types');
7
7
  var core = require('@eslint-react/core');
@@ -27,12 +27,12 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var JSX9__namespace = /*#__PURE__*/_interopNamespace(JSX9);
30
+ var JSX8__namespace = /*#__PURE__*/_interopNamespace(JSX8);
31
31
  var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
32
32
 
33
33
  // package.json
34
34
  var name = "eslint-plugin-react-dom";
35
- var version = "1.21.1-next.1";
35
+ var version = "1.22.0-next.0";
36
36
  var createRule = shared.createRuleForPlugin("dom");
37
37
  function findAttrInCustomAttributes(name2, attributes) {
38
38
  return eff.F.pipe(
@@ -42,96 +42,29 @@ function findAttrInCustomAttributes(name2, attributes) {
42
42
  );
43
43
  }
44
44
 
45
- // src/rules/no-children-in-void-dom-elements.ts
46
- var RULE_NAME = "no-children-in-void-dom-elements";
45
+ // src/rules/no-dangerously-set-innerhtml.ts
46
+ var RULE_NAME = "no-dangerously-set-innerhtml";
47
47
  var RULE_FEATURES = [
48
48
  "CHK"
49
49
  ];
50
- var voidElements = [
51
- "area",
52
- "base",
53
- "br",
54
- "col",
55
- "embed",
56
- "hr",
57
- "img",
58
- "input",
59
- "keygen",
60
- "link",
61
- "menuitem",
62
- "meta",
63
- "param",
64
- "source",
65
- "track",
66
- "wbr"
67
- ];
68
- var no_children_in_void_dom_elements_default = createRule({
69
- meta: {
70
- type: "problem",
71
- docs: {
72
- description: "disallow passing 'children' to void DOM elements",
73
- [Symbol.for("rule_features")]: RULE_FEATURES
74
- },
75
- messages: {
76
- noChildrenInVoidDomElements: "A void DOM element '<{{element}} />' cannot have children."
77
- },
78
- schema: []
79
- },
80
- name: RULE_NAME,
81
- create(context) {
82
- return {
83
- JSXElement(node) {
84
- const elementName = JSX9__namespace.getElementName(node.openingElement);
85
- if (!elementName || !voidElements.includes(elementName)) return;
86
- if (node.children.length > 0) {
87
- context.report({
88
- messageId: "noChildrenInVoidDomElements",
89
- node,
90
- data: {
91
- element: elementName
92
- }
93
- });
94
- }
95
- const { attributes } = node.openingElement;
96
- const initialScope = context.sourceCode.getScope(node);
97
- const hasAttr = (name2) => eff.O.isSome(JSX9__namespace.findPropInAttributes(attributes, initialScope)(name2));
98
- const hasChildrenOrDangerAttr = hasAttr("children") || hasAttr("dangerouslySetInnerHTML");
99
- if (hasChildrenOrDangerAttr) {
100
- context.report({
101
- messageId: "noChildrenInVoidDomElements",
102
- node,
103
- data: {
104
- element: elementName
105
- }
106
- });
107
- }
108
- }
109
- };
110
- },
111
- defaultOptions: []
112
- });
113
- var RULE_NAME2 = "no-dangerously-set-innerhtml";
114
- var RULE_FEATURES2 = [
115
- "CHK"
116
- ];
117
50
  var no_dangerously_set_innerhtml_default = createRule({
118
51
  meta: {
119
52
  type: "problem",
120
53
  docs: {
121
54
  description: "disallow when a DOM component is using 'dangerouslySetInnerHTML'",
122
- [Symbol.for("rule_features")]: RULE_FEATURES2
55
+ [Symbol.for("rule_features")]: RULE_FEATURES
123
56
  },
124
57
  messages: {
125
58
  noDangerouslySetInnerhtml: "Using 'dangerouslySetInnerHTML' may have security implications."
126
59
  },
127
60
  schema: []
128
61
  },
129
- name: RULE_NAME2,
62
+ name: RULE_NAME,
130
63
  create(context) {
131
64
  return {
132
65
  JSXElement(node) {
133
66
  const initialScope = context.sourceCode.getScope(node);
134
- const maybeDanger = JSX9__namespace.findPropInAttributes(node.openingElement.attributes, initialScope)(
67
+ const maybeDanger = JSX8__namespace.findPropInAttributes(node.openingElement.attributes, initialScope)(
135
68
  "dangerouslySetInnerHTML"
136
69
  );
137
70
  if (eff.O.isSome(maybeDanger)) {
@@ -145,34 +78,34 @@ var no_dangerously_set_innerhtml_default = createRule({
145
78
  },
146
79
  defaultOptions: []
147
80
  });
148
- var RULE_NAME3 = "no-dangerously-set-innerhtml-with-children";
149
- var RULE_FEATURES3 = [
81
+ var RULE_NAME2 = "no-dangerously-set-innerhtml-with-children";
82
+ var RULE_FEATURES2 = [
150
83
  "CHK"
151
84
  ];
152
85
  function firstChildIsText(node) {
153
86
  const [firstChild] = node.children;
154
- return node.children.length > 0 && !eff.isNullable(firstChild) && !JSX9__namespace.isLineBreak(firstChild);
87
+ return node.children.length > 0 && !eff.isNullable(firstChild) && !JSX8__namespace.isLineBreak(firstChild);
155
88
  }
156
89
  var no_dangerously_set_innerhtml_with_children_default = createRule({
157
90
  meta: {
158
91
  type: "problem",
159
92
  docs: {
160
93
  description: "disallow when a DOM component is using both 'children' and 'dangerouslySetInnerHTML'",
161
- [Symbol.for("rule_features")]: RULE_FEATURES3
94
+ [Symbol.for("rule_features")]: RULE_FEATURES2
162
95
  },
163
96
  messages: {
164
97
  noDangerouslySetInnerhtmlWithChildren: "A DOM component cannot use both 'children' and 'dangerouslySetInnerHTML'."
165
98
  },
166
99
  schema: []
167
100
  },
168
- name: RULE_NAME3,
101
+ name: RULE_NAME2,
169
102
  create(context) {
170
103
  return {
171
104
  JSXElement(node) {
172
105
  const initialScope = context.sourceCode.getScope(node);
173
106
  const hasChildrenWithIn = () => node.children.length > 0 && firstChildIsText(node);
174
- const hasChildrenProp = () => JSX9__namespace.hasProp(node.openingElement.attributes, "children", initialScope);
175
- const hasDanger = () => JSX9__namespace.hasProp(node.openingElement.attributes, "dangerouslySetInnerHTML", initialScope);
107
+ const hasChildrenProp = () => JSX8__namespace.hasProp(node.openingElement.attributes, "children", initialScope);
108
+ const hasDanger = () => JSX8__namespace.hasProp(node.openingElement.attributes, "dangerouslySetInnerHTML", initialScope);
176
109
  if (!(hasChildrenWithIn() || hasChildrenProp()) || !hasDanger()) return;
177
110
  context.report({
178
111
  messageId: "noDangerouslySetInnerhtmlWithChildren",
@@ -183,8 +116,8 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
183
116
  },
184
117
  defaultOptions: []
185
118
  });
186
- var RULE_NAME4 = "no-find-dom-node";
187
- var RULE_FEATURES4 = [
119
+ var RULE_NAME3 = "no-find-dom-node";
120
+ var RULE_FEATURES3 = [
188
121
  "CHK"
189
122
  ];
190
123
  var no_find_dom_node_default = createRule({
@@ -192,14 +125,14 @@ var no_find_dom_node_default = createRule({
192
125
  type: "problem",
193
126
  docs: {
194
127
  description: "disallow 'findDOMNode'",
195
- [Symbol.for("rule_features")]: RULE_FEATURES4
128
+ [Symbol.for("rule_features")]: RULE_FEATURES3
196
129
  },
197
130
  messages: {
198
131
  noFindDomNode: "[Deprecated] Use alternatives instead."
199
132
  },
200
133
  schema: []
201
134
  },
202
- name: RULE_NAME4,
135
+ name: RULE_NAME3,
203
136
  create(context) {
204
137
  return {
205
138
  CallExpression(node) {
@@ -221,8 +154,8 @@ var no_find_dom_node_default = createRule({
221
154
  },
222
155
  defaultOptions: []
223
156
  });
224
- var RULE_NAME5 = "no-missing-button-type";
225
- var RULE_FEATURES5 = [
157
+ var RULE_NAME4 = "no-missing-button-type";
158
+ var RULE_FEATURES4 = [
226
159
  "CHK"
227
160
  ];
228
161
  var no_missing_button_type_default = createRule({
@@ -230,14 +163,14 @@ var no_missing_button_type_default = createRule({
230
163
  type: "problem",
231
164
  docs: {
232
165
  description: "enforce that button component have an explicit 'type' attribute",
233
- [Symbol.for("rule_features")]: RULE_FEATURES5
166
+ [Symbol.for("rule_features")]: RULE_FEATURES4
234
167
  },
235
168
  messages: {
236
169
  noMissingButtonType: "Add missing 'type' attribute on 'button' component."
237
170
  },
238
171
  schema: []
239
172
  },
240
- name: RULE_NAME5,
173
+ name: RULE_NAME4,
241
174
  create(context) {
242
175
  return {
243
176
  JSXElement(node) {
@@ -245,7 +178,7 @@ var no_missing_button_type_default = createRule({
245
178
  if (elementName !== "button") return;
246
179
  const { attributes } = node.openingElement;
247
180
  const initialScope = context.sourceCode.getScope(node);
248
- const maybeTypeAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("type");
181
+ const maybeTypeAttribute = JSX8__namespace.findPropInAttributes(attributes, initialScope)("type");
249
182
  if (eff.O.isSome(maybeTypeAttribute)) return;
250
183
  context.report({
251
184
  messageId: "noMissingButtonType",
@@ -256,8 +189,8 @@ var no_missing_button_type_default = createRule({
256
189
  },
257
190
  defaultOptions: []
258
191
  });
259
- var RULE_NAME6 = "no-missing-iframe-sandbox";
260
- var RULE_FEATURES6 = [
192
+ var RULE_NAME5 = "no-missing-iframe-sandbox";
193
+ var RULE_FEATURES5 = [
261
194
  "CHK"
262
195
  ];
263
196
  var validTypes = [
@@ -283,14 +216,14 @@ var no_missing_iframe_sandbox_default = createRule({
283
216
  type: "problem",
284
217
  docs: {
285
218
  description: "enforce that 'iframe' component have an explicit 'sandbox' attribute",
286
- [Symbol.for("rule_features")]: RULE_FEATURES6
219
+ [Symbol.for("rule_features")]: RULE_FEATURES5
287
220
  },
288
221
  messages: {
289
222
  noMissingIframeSandbox: "Add missing 'sandbox' attribute on 'iframe' component."
290
223
  },
291
224
  schema: []
292
225
  },
293
- name: RULE_NAME6,
226
+ name: RULE_NAME5,
294
227
  create(context) {
295
228
  return {
296
229
  JSXElement(node) {
@@ -298,7 +231,7 @@ var no_missing_iframe_sandbox_default = createRule({
298
231
  if (elementName !== "iframe") return;
299
232
  const { attributes } = node.openingElement;
300
233
  const initialScope = context.sourceCode.getScope(node);
301
- const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
234
+ const maybeSandboxAttribute = JSX8__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
302
235
  if (eff.O.isNone(maybeSandboxAttribute)) {
303
236
  context.report({
304
237
  messageId: "noMissingIframeSandbox",
@@ -308,7 +241,7 @@ var no_missing_iframe_sandbox_default = createRule({
308
241
  }
309
242
  const sandboxAttribute = maybeSandboxAttribute.value;
310
243
  const hasValidSandbox = eff.F.pipe(
311
- JSX9__namespace.getPropValue(sandboxAttribute, context.sourceCode.getScope(sandboxAttribute)),
244
+ JSX8__namespace.getPropValue(sandboxAttribute, context.sourceCode.getScope(sandboxAttribute)),
312
245
  eff.O.filter(eff.isString),
313
246
  eff.O.map((value) => value.split(" ")),
314
247
  eff.O.exists((values) => values.every((value) => validTypes.some((validType) => validType === value)))
@@ -323,8 +256,8 @@ var no_missing_iframe_sandbox_default = createRule({
323
256
  },
324
257
  defaultOptions: []
325
258
  });
326
- var RULE_NAME7 = "no-namespace";
327
- var RULE_FEATURES7 = [
259
+ var RULE_NAME6 = "no-namespace";
260
+ var RULE_FEATURES6 = [
328
261
  "CHK"
329
262
  ];
330
263
  var no_namespace_default = createRule({
@@ -332,18 +265,18 @@ var no_namespace_default = createRule({
332
265
  type: "problem",
333
266
  docs: {
334
267
  description: "enforce that namespaces are not used in React elements",
335
- [Symbol.for("rule_features")]: RULE_FEATURES7
268
+ [Symbol.for("rule_features")]: RULE_FEATURES6
336
269
  },
337
270
  messages: {
338
271
  noNamespace: "A React component '{{name}}' must not be in a namespace, as React does not support them."
339
272
  },
340
273
  schema: []
341
274
  },
342
- name: RULE_NAME7,
275
+ name: RULE_NAME6,
343
276
  create(context) {
344
277
  return {
345
278
  JSXOpeningElement(node) {
346
- const name2 = JSX9__namespace.getElementName(node);
279
+ const name2 = JSX8__namespace.getElementName(node);
347
280
  if (!eff.isString(name2) || !name2.includes(":")) return;
348
281
  context.report({
349
282
  messageId: "noNamespace",
@@ -357,8 +290,8 @@ var no_namespace_default = createRule({
357
290
  },
358
291
  defaultOptions: []
359
292
  });
360
- var RULE_NAME8 = "no-render-return-value";
361
- var RULE_FEATURES8 = [
293
+ var RULE_NAME7 = "no-render-return-value";
294
+ var RULE_FEATURES7 = [
362
295
  "CHK"
363
296
  ];
364
297
  var banParentTypes = [
@@ -373,14 +306,14 @@ var no_render_return_value_default = createRule({
373
306
  type: "problem",
374
307
  docs: {
375
308
  description: "disallow usage of the return value of 'ReactDOM.render'",
376
- [Symbol.for("rule_features")]: RULE_FEATURES8
309
+ [Symbol.for("rule_features")]: RULE_FEATURES7
377
310
  },
378
311
  messages: {
379
312
  noRenderReturnValue: "Do not depend on the return value from '{{objectName}}.render'."
380
313
  },
381
314
  schema: []
382
315
  },
383
- name: RULE_NAME8,
316
+ name: RULE_NAME7,
384
317
  create(context) {
385
318
  return {
386
319
  CallExpression(node) {
@@ -404,8 +337,8 @@ var no_render_return_value_default = createRule({
404
337
  },
405
338
  defaultOptions: []
406
339
  });
407
- var RULE_NAME9 = "no-script-url";
408
- var RULE_FEATURES9 = [
340
+ var RULE_NAME8 = "no-script-url";
341
+ var RULE_FEATURES8 = [
409
342
  "CHK"
410
343
  ];
411
344
  var no_script_url_default = createRule({
@@ -413,20 +346,20 @@ var no_script_url_default = createRule({
413
346
  type: "problem",
414
347
  docs: {
415
348
  description: "disallow 'javascript:' URLs as JSX event handler prop's value",
416
- [Symbol.for("rule_features")]: RULE_FEATURES9
349
+ [Symbol.for("rule_features")]: RULE_FEATURES8
417
350
  },
418
351
  messages: {
419
352
  noScriptUrl: "Using a `javascript:` URL is a security risk and should be avoided."
420
353
  },
421
354
  schema: []
422
355
  },
423
- name: RULE_NAME9,
356
+ name: RULE_NAME8,
424
357
  create(context) {
425
358
  return {
426
359
  JSXAttribute(node) {
427
360
  if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier || !node.value) return;
428
361
  const isJavaScript = eff.F.pipe(
429
- JSX9__namespace.getPropValue(node, context.sourceCode.getScope(node)),
362
+ JSX8__namespace.getPropValue(node, context.sourceCode.getScope(node)),
430
363
  eff.O.filter(eff.isString),
431
364
  eff.O.exists((v) => shared.RE_JAVASCRIPT_PROTOCOL.test(v))
432
365
  );
@@ -441,7 +374,7 @@ var no_script_url_default = createRule({
441
374
  },
442
375
  defaultOptions: []
443
376
  });
444
- var RULE_NAME10 = "no-unknown-property";
377
+ var RULE_NAME9 = "no-unknown-property";
445
378
  var DEFAULTS = {
446
379
  ignore: [],
447
380
  requireDataLowercase: false
@@ -1403,7 +1336,7 @@ var no_unknown_property_default = createRule({
1403
1336
  }
1404
1337
  }]
1405
1338
  },
1406
- name: RULE_NAME10,
1339
+ name: RULE_NAME9,
1407
1340
  create(context) {
1408
1341
  function getIgnoreConfig() {
1409
1342
  return context.options[0]?.ignore || DEFAULTS.ignore;
@@ -1498,8 +1431,8 @@ function testReactVersion(context, comparator, version2) {
1498
1431
  const { version: localVersion } = shared.normalizeSettings(shared.decodeSettings(context.settings));
1499
1432
  return compareVersions.compare(localVersion, version2, comparator);
1500
1433
  }
1501
- var RULE_NAME11 = "no-unsafe-iframe-sandbox";
1502
- var RULE_FEATURES10 = [
1434
+ var RULE_NAME10 = "no-unsafe-iframe-sandbox";
1435
+ var RULE_FEATURES9 = [
1503
1436
  "CHK"
1504
1437
  ];
1505
1438
  var unsafeCombinations = [
@@ -1511,14 +1444,14 @@ var no_unsafe_iframe_sandbox_default = createRule({
1511
1444
  type: "problem",
1512
1445
  docs: {
1513
1446
  description: "disallow unsafe iframe 'sandbox' attribute combinations",
1514
- [Symbol.for("rule_features")]: RULE_FEATURES10
1447
+ [Symbol.for("rule_features")]: RULE_FEATURES9
1515
1448
  },
1516
1449
  messages: {
1517
1450
  noUnsafeIframeSandbox: "Unsafe 'sandbox' attribute value on 'iframe' component."
1518
1451
  },
1519
1452
  schema: []
1520
1453
  },
1521
- name: RULE_NAME11,
1454
+ name: RULE_NAME10,
1522
1455
  create(context) {
1523
1456
  return {
1524
1457
  JSXElement(node) {
@@ -1526,10 +1459,10 @@ var no_unsafe_iframe_sandbox_default = createRule({
1526
1459
  if (elementName !== "iframe") return;
1527
1460
  const { attributes } = node.openingElement;
1528
1461
  const initialScope = context.sourceCode.getScope(node);
1529
- const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
1462
+ const maybeSandboxAttribute = JSX8__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
1530
1463
  if (eff.O.isNone(maybeSandboxAttribute)) return;
1531
1464
  const isSafeSandboxValue = !eff.F.pipe(
1532
- JSX9__namespace.getPropValue(maybeSandboxAttribute.value, context.sourceCode.getScope(maybeSandboxAttribute.value)),
1465
+ JSX8__namespace.getPropValue(maybeSandboxAttribute.value, context.sourceCode.getScope(maybeSandboxAttribute.value)),
1533
1466
  eff.O.flatMapNullable(
1534
1467
  (v) => tsPattern.match(v).with(tsPattern.P.string, eff.F.identity).with({ sandbox: tsPattern.P.string }, ({ sandbox }) => sandbox).otherwise(eff.F.constNull)
1535
1468
  ),
@@ -1549,8 +1482,8 @@ var no_unsafe_iframe_sandbox_default = createRule({
1549
1482
  },
1550
1483
  defaultOptions: []
1551
1484
  });
1552
- var RULE_NAME12 = "no-unsafe-target-blank";
1553
- var RULE_FEATURES11 = [
1485
+ var RULE_NAME11 = "no-unsafe-target-blank";
1486
+ var RULE_FEATURES10 = [
1554
1487
  "CHK"
1555
1488
  ];
1556
1489
  function isExternalLinkLike(value) {
@@ -1564,19 +1497,19 @@ var no_unsafe_target_blank_default = createRule({
1564
1497
  type: "problem",
1565
1498
  docs: {
1566
1499
  description: `disallow 'target="_blank"' on an external link without 'rel="noreferrer noopener"'`,
1567
- [Symbol.for("rule_features")]: RULE_FEATURES11
1500
+ [Symbol.for("rule_features")]: RULE_FEATURES10
1568
1501
  },
1569
1502
  messages: {
1570
1503
  noUnsafeTargetBlank: `Using 'target="_blank"' on an external link without 'rel="noreferrer noopener"' is a security risk.`
1571
1504
  },
1572
1505
  schema: []
1573
1506
  },
1574
- name: RULE_NAME12,
1507
+ name: RULE_NAME11,
1575
1508
  create(context) {
1576
1509
  const settings = shared.normalizeSettings(shared.decodeSettings(context.settings));
1577
1510
  const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
1578
1511
  function getReportDescriptor(node) {
1579
- const name2 = JSX9__namespace.getElementName(node.openingElement);
1512
+ const name2 = JSX8__namespace.getElementName(node.openingElement);
1580
1513
  const elementName = core.getElementRepresentName(node.openingElement, context);
1581
1514
  if (elementName !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return eff.O.none();
1582
1515
  const { attributes } = node.openingElement;
@@ -1586,10 +1519,10 @@ var no_unsafe_target_blank_default = createRule({
1586
1519
  targetPropName,
1587
1520
  targetPropDefaultValue
1588
1521
  ] = findAttrInCustomAttributes("target", additionalAttributes);
1589
- const targetProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(targetPropName);
1522
+ const targetProp = JSX8__namespace.findPropInAttributes(attributes, initialScope)(targetPropName);
1590
1523
  const targetPropValue = eff.O.isNone(targetProp) ? eff.O.fromNullable(targetPropDefaultValue) : eff.F.pipe(
1591
1524
  targetProp,
1592
- eff.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1525
+ eff.O.flatMap((attr) => JSX8__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1593
1526
  eff.O.flatMapNullable(
1594
1527
  (v) => tsPattern.match(v).with(tsPattern.P.string, eff.F.identity).with({ [targetPropName]: tsPattern.P.string }, (v2) => v2[targetPropName]).otherwise(eff.F.constNull)
1595
1528
  ),
@@ -1600,10 +1533,10 @@ var no_unsafe_target_blank_default = createRule({
1600
1533
  hrefPropName,
1601
1534
  hrefPropDefaultValue
1602
1535
  ] = findAttrInCustomAttributes("href", additionalAttributes);
1603
- const hrefProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(hrefPropName);
1536
+ const hrefProp = JSX8__namespace.findPropInAttributes(attributes, initialScope)(hrefPropName);
1604
1537
  const hrefPropValue = eff.O.isNone(hrefProp) ? eff.O.fromNullable(hrefPropDefaultValue) : eff.F.pipe(
1605
1538
  hrefProp,
1606
- eff.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1539
+ eff.O.flatMap((attr) => JSX8__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1607
1540
  eff.O.flatMapNullable(
1608
1541
  (v) => tsPattern.match(v).with(tsPattern.P.string, eff.F.identity).with({ [hrefPropName]: tsPattern.P.string }, (v2) => v2[hrefPropName]).otherwise(eff.F.constNull)
1609
1542
  ),
@@ -1614,10 +1547,10 @@ var no_unsafe_target_blank_default = createRule({
1614
1547
  relPropName,
1615
1548
  relPropDefaultValue
1616
1549
  ] = findAttrInCustomAttributes("rel", additionalAttributes);
1617
- const relProp = JSX9__namespace.findPropInAttributes(attributes, initialScope)(relPropName);
1550
+ const relProp = JSX8__namespace.findPropInAttributes(attributes, initialScope)(relPropName);
1618
1551
  const relPropValue = eff.O.isNone(relProp) ? eff.O.fromNullable(relPropDefaultValue) : eff.F.pipe(
1619
1552
  relProp,
1620
- eff.O.flatMap((attr) => JSX9__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1553
+ eff.O.flatMap((attr) => JSX8__namespace.getPropValue(attr, context.sourceCode.getScope(attr))),
1621
1554
  eff.O.flatMapNullable(
1622
1555
  (v) => tsPattern.match(v).with(tsPattern.P.string, eff.F.identity).with({ [relPropName]: tsPattern.P.string }, (v2) => v2[relPropName]).otherwise(eff.F.constNull)
1623
1556
  ),
@@ -1635,15 +1568,81 @@ var no_unsafe_target_blank_default = createRule({
1635
1568
  },
1636
1569
  defaultOptions: []
1637
1570
  });
1571
+ var RULE_NAME12 = "no-void-elements-with-children";
1572
+ var RULE_FEATURES11 = [
1573
+ "CHK"
1574
+ ];
1575
+ var voidElements = /* @__PURE__ */ new Set([
1576
+ "area",
1577
+ "base",
1578
+ "br",
1579
+ "col",
1580
+ "embed",
1581
+ "hr",
1582
+ "img",
1583
+ "input",
1584
+ "keygen",
1585
+ "link",
1586
+ "menuitem",
1587
+ "meta",
1588
+ "param",
1589
+ "source",
1590
+ "track",
1591
+ "wbr"
1592
+ ]);
1593
+ var no_void_elements_with_children_default = createRule({
1594
+ meta: {
1595
+ type: "problem",
1596
+ docs: {
1597
+ description: "disallow void elements (AKA self-closing elements) from having children",
1598
+ [Symbol.for("rule_features")]: RULE_FEATURES11
1599
+ },
1600
+ messages: {
1601
+ noVoidElementsWithChildren: "'{{element}}' is a void element tag and must not have children."
1602
+ },
1603
+ schema: []
1604
+ },
1605
+ name: RULE_NAME12,
1606
+ create(context) {
1607
+ return {
1608
+ JSXElement(node) {
1609
+ const elementName = JSX8__namespace.getElementName(node.openingElement);
1610
+ if (!elementName || !voidElements.has(elementName)) return;
1611
+ if (node.children.length > 0) {
1612
+ context.report({
1613
+ messageId: "noVoidElementsWithChildren",
1614
+ node,
1615
+ data: {
1616
+ element: elementName
1617
+ }
1618
+ });
1619
+ }
1620
+ const { attributes } = node.openingElement;
1621
+ const initialScope = context.sourceCode.getScope(node);
1622
+ const hasAttr = (name2) => eff.O.isSome(JSX8__namespace.findPropInAttributes(attributes, initialScope)(name2));
1623
+ const hasChildrenOrDangerAttr = hasAttr("children") || hasAttr("dangerouslySetInnerHTML");
1624
+ if (hasChildrenOrDangerAttr) {
1625
+ context.report({
1626
+ messageId: "noVoidElementsWithChildren",
1627
+ node,
1628
+ data: {
1629
+ element: elementName
1630
+ }
1631
+ });
1632
+ }
1633
+ }
1634
+ };
1635
+ },
1636
+ defaultOptions: []
1637
+ });
1638
1638
 
1639
1639
  // src/index.ts
1640
- var src_default = {
1640
+ var index_default = {
1641
1641
  meta: {
1642
1642
  name,
1643
1643
  version
1644
1644
  },
1645
1645
  rules: {
1646
- "no-children-in-void-dom-elements": no_children_in_void_dom_elements_default,
1647
1646
  "no-dangerously-set-innerhtml": no_dangerously_set_innerhtml_default,
1648
1647
  "no-dangerously-set-innerhtml-with-children": no_dangerously_set_innerhtml_with_children_default,
1649
1648
  "no-find-dom-node": no_find_dom_node_default,
@@ -1654,8 +1653,12 @@ var src_default = {
1654
1653
  "no-script-url": no_script_url_default,
1655
1654
  "no-unknown-property": no_unknown_property_default,
1656
1655
  "no-unsafe-iframe-sandbox": no_unsafe_iframe_sandbox_default,
1657
- "no-unsafe-target-blank": no_unsafe_target_blank_default
1656
+ "no-unsafe-target-blank": no_unsafe_target_blank_default,
1657
+ "no-void-elements-with-children": no_void_elements_with_children_default,
1658
+ // Part: deprecated rules
1659
+ /** @deprecated Use `no-void-elements-with-children` instead */
1660
+ "no-children-in-void-dom-elements": no_void_elements_with_children_default
1658
1661
  }
1659
1662
  };
1660
1663
 
1661
- module.exports = src_default;
1664
+ module.exports = index_default;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { O, F, isString, isNullable } from '@eslint-react/eff';
2
- import * as JSX9 from '@eslint-react/jsx';
2
+ import * as JSX8 from '@eslint-react/jsx';
3
3
  import { createRuleForPlugin, RE_JAVASCRIPT_PROTOCOL, normalizeSettings, decodeSettings } from '@eslint-react/shared';
4
4
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
5
5
  import { getElementRepresentName } from '@eslint-react/core';
@@ -9,7 +9,7 @@ import { match, P } from 'ts-pattern';
9
9
 
10
10
  // package.json
11
11
  var name = "eslint-plugin-react-dom";
12
- var version = "1.21.1-next.1";
12
+ var version = "1.22.0-next.0";
13
13
  var createRule = createRuleForPlugin("dom");
14
14
  function findAttrInCustomAttributes(name2, attributes) {
15
15
  return F.pipe(
@@ -19,96 +19,29 @@ function findAttrInCustomAttributes(name2, attributes) {
19
19
  );
20
20
  }
21
21
 
22
- // src/rules/no-children-in-void-dom-elements.ts
23
- var RULE_NAME = "no-children-in-void-dom-elements";
22
+ // src/rules/no-dangerously-set-innerhtml.ts
23
+ var RULE_NAME = "no-dangerously-set-innerhtml";
24
24
  var RULE_FEATURES = [
25
25
  "CHK"
26
26
  ];
27
- var voidElements = [
28
- "area",
29
- "base",
30
- "br",
31
- "col",
32
- "embed",
33
- "hr",
34
- "img",
35
- "input",
36
- "keygen",
37
- "link",
38
- "menuitem",
39
- "meta",
40
- "param",
41
- "source",
42
- "track",
43
- "wbr"
44
- ];
45
- var no_children_in_void_dom_elements_default = createRule({
46
- meta: {
47
- type: "problem",
48
- docs: {
49
- description: "disallow passing 'children' to void DOM elements",
50
- [Symbol.for("rule_features")]: RULE_FEATURES
51
- },
52
- messages: {
53
- noChildrenInVoidDomElements: "A void DOM element '<{{element}} />' cannot have children."
54
- },
55
- schema: []
56
- },
57
- name: RULE_NAME,
58
- create(context) {
59
- return {
60
- JSXElement(node) {
61
- const elementName = JSX9.getElementName(node.openingElement);
62
- if (!elementName || !voidElements.includes(elementName)) return;
63
- if (node.children.length > 0) {
64
- context.report({
65
- messageId: "noChildrenInVoidDomElements",
66
- node,
67
- data: {
68
- element: elementName
69
- }
70
- });
71
- }
72
- const { attributes } = node.openingElement;
73
- const initialScope = context.sourceCode.getScope(node);
74
- const hasAttr = (name2) => O.isSome(JSX9.findPropInAttributes(attributes, initialScope)(name2));
75
- const hasChildrenOrDangerAttr = hasAttr("children") || hasAttr("dangerouslySetInnerHTML");
76
- if (hasChildrenOrDangerAttr) {
77
- context.report({
78
- messageId: "noChildrenInVoidDomElements",
79
- node,
80
- data: {
81
- element: elementName
82
- }
83
- });
84
- }
85
- }
86
- };
87
- },
88
- defaultOptions: []
89
- });
90
- var RULE_NAME2 = "no-dangerously-set-innerhtml";
91
- var RULE_FEATURES2 = [
92
- "CHK"
93
- ];
94
27
  var no_dangerously_set_innerhtml_default = createRule({
95
28
  meta: {
96
29
  type: "problem",
97
30
  docs: {
98
31
  description: "disallow when a DOM component is using 'dangerouslySetInnerHTML'",
99
- [Symbol.for("rule_features")]: RULE_FEATURES2
32
+ [Symbol.for("rule_features")]: RULE_FEATURES
100
33
  },
101
34
  messages: {
102
35
  noDangerouslySetInnerhtml: "Using 'dangerouslySetInnerHTML' may have security implications."
103
36
  },
104
37
  schema: []
105
38
  },
106
- name: RULE_NAME2,
39
+ name: RULE_NAME,
107
40
  create(context) {
108
41
  return {
109
42
  JSXElement(node) {
110
43
  const initialScope = context.sourceCode.getScope(node);
111
- const maybeDanger = JSX9.findPropInAttributes(node.openingElement.attributes, initialScope)(
44
+ const maybeDanger = JSX8.findPropInAttributes(node.openingElement.attributes, initialScope)(
112
45
  "dangerouslySetInnerHTML"
113
46
  );
114
47
  if (O.isSome(maybeDanger)) {
@@ -122,34 +55,34 @@ var no_dangerously_set_innerhtml_default = createRule({
122
55
  },
123
56
  defaultOptions: []
124
57
  });
125
- var RULE_NAME3 = "no-dangerously-set-innerhtml-with-children";
126
- var RULE_FEATURES3 = [
58
+ var RULE_NAME2 = "no-dangerously-set-innerhtml-with-children";
59
+ var RULE_FEATURES2 = [
127
60
  "CHK"
128
61
  ];
129
62
  function firstChildIsText(node) {
130
63
  const [firstChild] = node.children;
131
- return node.children.length > 0 && !isNullable(firstChild) && !JSX9.isLineBreak(firstChild);
64
+ return node.children.length > 0 && !isNullable(firstChild) && !JSX8.isLineBreak(firstChild);
132
65
  }
133
66
  var no_dangerously_set_innerhtml_with_children_default = createRule({
134
67
  meta: {
135
68
  type: "problem",
136
69
  docs: {
137
70
  description: "disallow when a DOM component is using both 'children' and 'dangerouslySetInnerHTML'",
138
- [Symbol.for("rule_features")]: RULE_FEATURES3
71
+ [Symbol.for("rule_features")]: RULE_FEATURES2
139
72
  },
140
73
  messages: {
141
74
  noDangerouslySetInnerhtmlWithChildren: "A DOM component cannot use both 'children' and 'dangerouslySetInnerHTML'."
142
75
  },
143
76
  schema: []
144
77
  },
145
- name: RULE_NAME3,
78
+ name: RULE_NAME2,
146
79
  create(context) {
147
80
  return {
148
81
  JSXElement(node) {
149
82
  const initialScope = context.sourceCode.getScope(node);
150
83
  const hasChildrenWithIn = () => node.children.length > 0 && firstChildIsText(node);
151
- const hasChildrenProp = () => JSX9.hasProp(node.openingElement.attributes, "children", initialScope);
152
- const hasDanger = () => JSX9.hasProp(node.openingElement.attributes, "dangerouslySetInnerHTML", initialScope);
84
+ const hasChildrenProp = () => JSX8.hasProp(node.openingElement.attributes, "children", initialScope);
85
+ const hasDanger = () => JSX8.hasProp(node.openingElement.attributes, "dangerouslySetInnerHTML", initialScope);
153
86
  if (!(hasChildrenWithIn() || hasChildrenProp()) || !hasDanger()) return;
154
87
  context.report({
155
88
  messageId: "noDangerouslySetInnerhtmlWithChildren",
@@ -160,8 +93,8 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
160
93
  },
161
94
  defaultOptions: []
162
95
  });
163
- var RULE_NAME4 = "no-find-dom-node";
164
- var RULE_FEATURES4 = [
96
+ var RULE_NAME3 = "no-find-dom-node";
97
+ var RULE_FEATURES3 = [
165
98
  "CHK"
166
99
  ];
167
100
  var no_find_dom_node_default = createRule({
@@ -169,14 +102,14 @@ var no_find_dom_node_default = createRule({
169
102
  type: "problem",
170
103
  docs: {
171
104
  description: "disallow 'findDOMNode'",
172
- [Symbol.for("rule_features")]: RULE_FEATURES4
105
+ [Symbol.for("rule_features")]: RULE_FEATURES3
173
106
  },
174
107
  messages: {
175
108
  noFindDomNode: "[Deprecated] Use alternatives instead."
176
109
  },
177
110
  schema: []
178
111
  },
179
- name: RULE_NAME4,
112
+ name: RULE_NAME3,
180
113
  create(context) {
181
114
  return {
182
115
  CallExpression(node) {
@@ -198,8 +131,8 @@ var no_find_dom_node_default = createRule({
198
131
  },
199
132
  defaultOptions: []
200
133
  });
201
- var RULE_NAME5 = "no-missing-button-type";
202
- var RULE_FEATURES5 = [
134
+ var RULE_NAME4 = "no-missing-button-type";
135
+ var RULE_FEATURES4 = [
203
136
  "CHK"
204
137
  ];
205
138
  var no_missing_button_type_default = createRule({
@@ -207,14 +140,14 @@ var no_missing_button_type_default = createRule({
207
140
  type: "problem",
208
141
  docs: {
209
142
  description: "enforce that button component have an explicit 'type' attribute",
210
- [Symbol.for("rule_features")]: RULE_FEATURES5
143
+ [Symbol.for("rule_features")]: RULE_FEATURES4
211
144
  },
212
145
  messages: {
213
146
  noMissingButtonType: "Add missing 'type' attribute on 'button' component."
214
147
  },
215
148
  schema: []
216
149
  },
217
- name: RULE_NAME5,
150
+ name: RULE_NAME4,
218
151
  create(context) {
219
152
  return {
220
153
  JSXElement(node) {
@@ -222,7 +155,7 @@ var no_missing_button_type_default = createRule({
222
155
  if (elementName !== "button") return;
223
156
  const { attributes } = node.openingElement;
224
157
  const initialScope = context.sourceCode.getScope(node);
225
- const maybeTypeAttribute = JSX9.findPropInAttributes(attributes, initialScope)("type");
158
+ const maybeTypeAttribute = JSX8.findPropInAttributes(attributes, initialScope)("type");
226
159
  if (O.isSome(maybeTypeAttribute)) return;
227
160
  context.report({
228
161
  messageId: "noMissingButtonType",
@@ -233,8 +166,8 @@ var no_missing_button_type_default = createRule({
233
166
  },
234
167
  defaultOptions: []
235
168
  });
236
- var RULE_NAME6 = "no-missing-iframe-sandbox";
237
- var RULE_FEATURES6 = [
169
+ var RULE_NAME5 = "no-missing-iframe-sandbox";
170
+ var RULE_FEATURES5 = [
238
171
  "CHK"
239
172
  ];
240
173
  var validTypes = [
@@ -260,14 +193,14 @@ var no_missing_iframe_sandbox_default = createRule({
260
193
  type: "problem",
261
194
  docs: {
262
195
  description: "enforce that 'iframe' component have an explicit 'sandbox' attribute",
263
- [Symbol.for("rule_features")]: RULE_FEATURES6
196
+ [Symbol.for("rule_features")]: RULE_FEATURES5
264
197
  },
265
198
  messages: {
266
199
  noMissingIframeSandbox: "Add missing 'sandbox' attribute on 'iframe' component."
267
200
  },
268
201
  schema: []
269
202
  },
270
- name: RULE_NAME6,
203
+ name: RULE_NAME5,
271
204
  create(context) {
272
205
  return {
273
206
  JSXElement(node) {
@@ -275,7 +208,7 @@ var no_missing_iframe_sandbox_default = createRule({
275
208
  if (elementName !== "iframe") return;
276
209
  const { attributes } = node.openingElement;
277
210
  const initialScope = context.sourceCode.getScope(node);
278
- const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
211
+ const maybeSandboxAttribute = JSX8.findPropInAttributes(attributes, initialScope)("sandbox");
279
212
  if (O.isNone(maybeSandboxAttribute)) {
280
213
  context.report({
281
214
  messageId: "noMissingIframeSandbox",
@@ -285,7 +218,7 @@ var no_missing_iframe_sandbox_default = createRule({
285
218
  }
286
219
  const sandboxAttribute = maybeSandboxAttribute.value;
287
220
  const hasValidSandbox = F.pipe(
288
- JSX9.getPropValue(sandboxAttribute, context.sourceCode.getScope(sandboxAttribute)),
221
+ JSX8.getPropValue(sandboxAttribute, context.sourceCode.getScope(sandboxAttribute)),
289
222
  O.filter(isString),
290
223
  O.map((value) => value.split(" ")),
291
224
  O.exists((values) => values.every((value) => validTypes.some((validType) => validType === value)))
@@ -300,8 +233,8 @@ var no_missing_iframe_sandbox_default = createRule({
300
233
  },
301
234
  defaultOptions: []
302
235
  });
303
- var RULE_NAME7 = "no-namespace";
304
- var RULE_FEATURES7 = [
236
+ var RULE_NAME6 = "no-namespace";
237
+ var RULE_FEATURES6 = [
305
238
  "CHK"
306
239
  ];
307
240
  var no_namespace_default = createRule({
@@ -309,18 +242,18 @@ var no_namespace_default = createRule({
309
242
  type: "problem",
310
243
  docs: {
311
244
  description: "enforce that namespaces are not used in React elements",
312
- [Symbol.for("rule_features")]: RULE_FEATURES7
245
+ [Symbol.for("rule_features")]: RULE_FEATURES6
313
246
  },
314
247
  messages: {
315
248
  noNamespace: "A React component '{{name}}' must not be in a namespace, as React does not support them."
316
249
  },
317
250
  schema: []
318
251
  },
319
- name: RULE_NAME7,
252
+ name: RULE_NAME6,
320
253
  create(context) {
321
254
  return {
322
255
  JSXOpeningElement(node) {
323
- const name2 = JSX9.getElementName(node);
256
+ const name2 = JSX8.getElementName(node);
324
257
  if (!isString(name2) || !name2.includes(":")) return;
325
258
  context.report({
326
259
  messageId: "noNamespace",
@@ -334,8 +267,8 @@ var no_namespace_default = createRule({
334
267
  },
335
268
  defaultOptions: []
336
269
  });
337
- var RULE_NAME8 = "no-render-return-value";
338
- var RULE_FEATURES8 = [
270
+ var RULE_NAME7 = "no-render-return-value";
271
+ var RULE_FEATURES7 = [
339
272
  "CHK"
340
273
  ];
341
274
  var banParentTypes = [
@@ -350,14 +283,14 @@ var no_render_return_value_default = createRule({
350
283
  type: "problem",
351
284
  docs: {
352
285
  description: "disallow usage of the return value of 'ReactDOM.render'",
353
- [Symbol.for("rule_features")]: RULE_FEATURES8
286
+ [Symbol.for("rule_features")]: RULE_FEATURES7
354
287
  },
355
288
  messages: {
356
289
  noRenderReturnValue: "Do not depend on the return value from '{{objectName}}.render'."
357
290
  },
358
291
  schema: []
359
292
  },
360
- name: RULE_NAME8,
293
+ name: RULE_NAME7,
361
294
  create(context) {
362
295
  return {
363
296
  CallExpression(node) {
@@ -381,8 +314,8 @@ var no_render_return_value_default = createRule({
381
314
  },
382
315
  defaultOptions: []
383
316
  });
384
- var RULE_NAME9 = "no-script-url";
385
- var RULE_FEATURES9 = [
317
+ var RULE_NAME8 = "no-script-url";
318
+ var RULE_FEATURES8 = [
386
319
  "CHK"
387
320
  ];
388
321
  var no_script_url_default = createRule({
@@ -390,20 +323,20 @@ var no_script_url_default = createRule({
390
323
  type: "problem",
391
324
  docs: {
392
325
  description: "disallow 'javascript:' URLs as JSX event handler prop's value",
393
- [Symbol.for("rule_features")]: RULE_FEATURES9
326
+ [Symbol.for("rule_features")]: RULE_FEATURES8
394
327
  },
395
328
  messages: {
396
329
  noScriptUrl: "Using a `javascript:` URL is a security risk and should be avoided."
397
330
  },
398
331
  schema: []
399
332
  },
400
- name: RULE_NAME9,
333
+ name: RULE_NAME8,
401
334
  create(context) {
402
335
  return {
403
336
  JSXAttribute(node) {
404
337
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || !node.value) return;
405
338
  const isJavaScript = F.pipe(
406
- JSX9.getPropValue(node, context.sourceCode.getScope(node)),
339
+ JSX8.getPropValue(node, context.sourceCode.getScope(node)),
407
340
  O.filter(isString),
408
341
  O.exists((v) => RE_JAVASCRIPT_PROTOCOL.test(v))
409
342
  );
@@ -418,7 +351,7 @@ var no_script_url_default = createRule({
418
351
  },
419
352
  defaultOptions: []
420
353
  });
421
- var RULE_NAME10 = "no-unknown-property";
354
+ var RULE_NAME9 = "no-unknown-property";
422
355
  var DEFAULTS = {
423
356
  ignore: [],
424
357
  requireDataLowercase: false
@@ -1380,7 +1313,7 @@ var no_unknown_property_default = createRule({
1380
1313
  }
1381
1314
  }]
1382
1315
  },
1383
- name: RULE_NAME10,
1316
+ name: RULE_NAME9,
1384
1317
  create(context) {
1385
1318
  function getIgnoreConfig() {
1386
1319
  return context.options[0]?.ignore || DEFAULTS.ignore;
@@ -1475,8 +1408,8 @@ function testReactVersion(context, comparator, version2) {
1475
1408
  const { version: localVersion } = normalizeSettings(decodeSettings(context.settings));
1476
1409
  return compare(localVersion, version2, comparator);
1477
1410
  }
1478
- var RULE_NAME11 = "no-unsafe-iframe-sandbox";
1479
- var RULE_FEATURES10 = [
1411
+ var RULE_NAME10 = "no-unsafe-iframe-sandbox";
1412
+ var RULE_FEATURES9 = [
1480
1413
  "CHK"
1481
1414
  ];
1482
1415
  var unsafeCombinations = [
@@ -1488,14 +1421,14 @@ var no_unsafe_iframe_sandbox_default = createRule({
1488
1421
  type: "problem",
1489
1422
  docs: {
1490
1423
  description: "disallow unsafe iframe 'sandbox' attribute combinations",
1491
- [Symbol.for("rule_features")]: RULE_FEATURES10
1424
+ [Symbol.for("rule_features")]: RULE_FEATURES9
1492
1425
  },
1493
1426
  messages: {
1494
1427
  noUnsafeIframeSandbox: "Unsafe 'sandbox' attribute value on 'iframe' component."
1495
1428
  },
1496
1429
  schema: []
1497
1430
  },
1498
- name: RULE_NAME11,
1431
+ name: RULE_NAME10,
1499
1432
  create(context) {
1500
1433
  return {
1501
1434
  JSXElement(node) {
@@ -1503,10 +1436,10 @@ var no_unsafe_iframe_sandbox_default = createRule({
1503
1436
  if (elementName !== "iframe") return;
1504
1437
  const { attributes } = node.openingElement;
1505
1438
  const initialScope = context.sourceCode.getScope(node);
1506
- const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
1439
+ const maybeSandboxAttribute = JSX8.findPropInAttributes(attributes, initialScope)("sandbox");
1507
1440
  if (O.isNone(maybeSandboxAttribute)) return;
1508
1441
  const isSafeSandboxValue = !F.pipe(
1509
- JSX9.getPropValue(maybeSandboxAttribute.value, context.sourceCode.getScope(maybeSandboxAttribute.value)),
1442
+ JSX8.getPropValue(maybeSandboxAttribute.value, context.sourceCode.getScope(maybeSandboxAttribute.value)),
1510
1443
  O.flatMapNullable(
1511
1444
  (v) => match(v).with(P.string, F.identity).with({ sandbox: P.string }, ({ sandbox }) => sandbox).otherwise(F.constNull)
1512
1445
  ),
@@ -1526,8 +1459,8 @@ var no_unsafe_iframe_sandbox_default = createRule({
1526
1459
  },
1527
1460
  defaultOptions: []
1528
1461
  });
1529
- var RULE_NAME12 = "no-unsafe-target-blank";
1530
- var RULE_FEATURES11 = [
1462
+ var RULE_NAME11 = "no-unsafe-target-blank";
1463
+ var RULE_FEATURES10 = [
1531
1464
  "CHK"
1532
1465
  ];
1533
1466
  function isExternalLinkLike(value) {
@@ -1541,19 +1474,19 @@ var no_unsafe_target_blank_default = createRule({
1541
1474
  type: "problem",
1542
1475
  docs: {
1543
1476
  description: `disallow 'target="_blank"' on an external link without 'rel="noreferrer noopener"'`,
1544
- [Symbol.for("rule_features")]: RULE_FEATURES11
1477
+ [Symbol.for("rule_features")]: RULE_FEATURES10
1545
1478
  },
1546
1479
  messages: {
1547
1480
  noUnsafeTargetBlank: `Using 'target="_blank"' on an external link without 'rel="noreferrer noopener"' is a security risk.`
1548
1481
  },
1549
1482
  schema: []
1550
1483
  },
1551
- name: RULE_NAME12,
1484
+ name: RULE_NAME11,
1552
1485
  create(context) {
1553
1486
  const settings = normalizeSettings(decodeSettings(context.settings));
1554
1487
  const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
1555
1488
  function getReportDescriptor(node) {
1556
- const name2 = JSX9.getElementName(node.openingElement);
1489
+ const name2 = JSX8.getElementName(node.openingElement);
1557
1490
  const elementName = getElementRepresentName(node.openingElement, context);
1558
1491
  if (elementName !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return O.none();
1559
1492
  const { attributes } = node.openingElement;
@@ -1563,10 +1496,10 @@ var no_unsafe_target_blank_default = createRule({
1563
1496
  targetPropName,
1564
1497
  targetPropDefaultValue
1565
1498
  ] = findAttrInCustomAttributes("target", additionalAttributes);
1566
- const targetProp = JSX9.findPropInAttributes(attributes, initialScope)(targetPropName);
1499
+ const targetProp = JSX8.findPropInAttributes(attributes, initialScope)(targetPropName);
1567
1500
  const targetPropValue = O.isNone(targetProp) ? O.fromNullable(targetPropDefaultValue) : F.pipe(
1568
1501
  targetProp,
1569
- O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
1502
+ O.flatMap((attr) => JSX8.getPropValue(attr, context.sourceCode.getScope(attr))),
1570
1503
  O.flatMapNullable(
1571
1504
  (v) => match(v).with(P.string, F.identity).with({ [targetPropName]: P.string }, (v2) => v2[targetPropName]).otherwise(F.constNull)
1572
1505
  ),
@@ -1577,10 +1510,10 @@ var no_unsafe_target_blank_default = createRule({
1577
1510
  hrefPropName,
1578
1511
  hrefPropDefaultValue
1579
1512
  ] = findAttrInCustomAttributes("href", additionalAttributes);
1580
- const hrefProp = JSX9.findPropInAttributes(attributes, initialScope)(hrefPropName);
1513
+ const hrefProp = JSX8.findPropInAttributes(attributes, initialScope)(hrefPropName);
1581
1514
  const hrefPropValue = O.isNone(hrefProp) ? O.fromNullable(hrefPropDefaultValue) : F.pipe(
1582
1515
  hrefProp,
1583
- O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
1516
+ O.flatMap((attr) => JSX8.getPropValue(attr, context.sourceCode.getScope(attr))),
1584
1517
  O.flatMapNullable(
1585
1518
  (v) => match(v).with(P.string, F.identity).with({ [hrefPropName]: P.string }, (v2) => v2[hrefPropName]).otherwise(F.constNull)
1586
1519
  ),
@@ -1591,10 +1524,10 @@ var no_unsafe_target_blank_default = createRule({
1591
1524
  relPropName,
1592
1525
  relPropDefaultValue
1593
1526
  ] = findAttrInCustomAttributes("rel", additionalAttributes);
1594
- const relProp = JSX9.findPropInAttributes(attributes, initialScope)(relPropName);
1527
+ const relProp = JSX8.findPropInAttributes(attributes, initialScope)(relPropName);
1595
1528
  const relPropValue = O.isNone(relProp) ? O.fromNullable(relPropDefaultValue) : F.pipe(
1596
1529
  relProp,
1597
- O.flatMap((attr) => JSX9.getPropValue(attr, context.sourceCode.getScope(attr))),
1530
+ O.flatMap((attr) => JSX8.getPropValue(attr, context.sourceCode.getScope(attr))),
1598
1531
  O.flatMapNullable(
1599
1532
  (v) => match(v).with(P.string, F.identity).with({ [relPropName]: P.string }, (v2) => v2[relPropName]).otherwise(F.constNull)
1600
1533
  ),
@@ -1612,15 +1545,81 @@ var no_unsafe_target_blank_default = createRule({
1612
1545
  },
1613
1546
  defaultOptions: []
1614
1547
  });
1548
+ var RULE_NAME12 = "no-void-elements-with-children";
1549
+ var RULE_FEATURES11 = [
1550
+ "CHK"
1551
+ ];
1552
+ var voidElements = /* @__PURE__ */ new Set([
1553
+ "area",
1554
+ "base",
1555
+ "br",
1556
+ "col",
1557
+ "embed",
1558
+ "hr",
1559
+ "img",
1560
+ "input",
1561
+ "keygen",
1562
+ "link",
1563
+ "menuitem",
1564
+ "meta",
1565
+ "param",
1566
+ "source",
1567
+ "track",
1568
+ "wbr"
1569
+ ]);
1570
+ var no_void_elements_with_children_default = createRule({
1571
+ meta: {
1572
+ type: "problem",
1573
+ docs: {
1574
+ description: "disallow void elements (AKA self-closing elements) from having children",
1575
+ [Symbol.for("rule_features")]: RULE_FEATURES11
1576
+ },
1577
+ messages: {
1578
+ noVoidElementsWithChildren: "'{{element}}' is a void element tag and must not have children."
1579
+ },
1580
+ schema: []
1581
+ },
1582
+ name: RULE_NAME12,
1583
+ create(context) {
1584
+ return {
1585
+ JSXElement(node) {
1586
+ const elementName = JSX8.getElementName(node.openingElement);
1587
+ if (!elementName || !voidElements.has(elementName)) return;
1588
+ if (node.children.length > 0) {
1589
+ context.report({
1590
+ messageId: "noVoidElementsWithChildren",
1591
+ node,
1592
+ data: {
1593
+ element: elementName
1594
+ }
1595
+ });
1596
+ }
1597
+ const { attributes } = node.openingElement;
1598
+ const initialScope = context.sourceCode.getScope(node);
1599
+ const hasAttr = (name2) => O.isSome(JSX8.findPropInAttributes(attributes, initialScope)(name2));
1600
+ const hasChildrenOrDangerAttr = hasAttr("children") || hasAttr("dangerouslySetInnerHTML");
1601
+ if (hasChildrenOrDangerAttr) {
1602
+ context.report({
1603
+ messageId: "noVoidElementsWithChildren",
1604
+ node,
1605
+ data: {
1606
+ element: elementName
1607
+ }
1608
+ });
1609
+ }
1610
+ }
1611
+ };
1612
+ },
1613
+ defaultOptions: []
1614
+ });
1615
1615
 
1616
1616
  // src/index.ts
1617
- var src_default = {
1617
+ var index_default = {
1618
1618
  meta: {
1619
1619
  name,
1620
1620
  version
1621
1621
  },
1622
1622
  rules: {
1623
- "no-children-in-void-dom-elements": no_children_in_void_dom_elements_default,
1624
1623
  "no-dangerously-set-innerhtml": no_dangerously_set_innerhtml_default,
1625
1624
  "no-dangerously-set-innerhtml-with-children": no_dangerously_set_innerhtml_with_children_default,
1626
1625
  "no-find-dom-node": no_find_dom_node_default,
@@ -1631,8 +1630,12 @@ var src_default = {
1631
1630
  "no-script-url": no_script_url_default,
1632
1631
  "no-unknown-property": no_unknown_property_default,
1633
1632
  "no-unsafe-iframe-sandbox": no_unsafe_iframe_sandbox_default,
1634
- "no-unsafe-target-blank": no_unsafe_target_blank_default
1633
+ "no-unsafe-target-blank": no_unsafe_target_blank_default,
1634
+ "no-void-elements-with-children": no_void_elements_with_children_default,
1635
+ // Part: deprecated rules
1636
+ /** @deprecated Use `no-void-elements-with-children` instead */
1637
+ "no-children-in-void-dom-elements": no_void_elements_with_children_default
1635
1638
  }
1636
1639
  };
1637
1640
 
1638
- export { src_default as default };
1641
+ export { index_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "1.21.1-next.1",
3
+ "version": "1.22.0-next.0",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -39,7 +39,7 @@
39
39
  "module": "dist/index.mjs",
40
40
  "types": "dist/index.d.ts",
41
41
  "files": [
42
- "./dist",
42
+ "dist",
43
43
  "./package.json"
44
44
  ],
45
45
  "dependencies": {
@@ -48,13 +48,13 @@
48
48
  "@typescript-eslint/utils": "^8.18.1",
49
49
  "compare-versions": "^6.1.1",
50
50
  "ts-pattern": "^5.6.0",
51
- "@eslint-react/ast": "1.21.1-next.1",
52
- "@eslint-react/core": "1.21.1-next.1",
53
- "@eslint-react/eff": "1.21.1-next.1",
54
- "@eslint-react/jsx": "1.21.1-next.1",
55
- "@eslint-react/shared": "1.21.1-next.1",
56
- "@eslint-react/types": "1.21.1-next.1",
57
- "@eslint-react/var": "1.21.1-next.1"
51
+ "@eslint-react/ast": "1.22.0-next.0",
52
+ "@eslint-react/jsx": "1.22.0-next.0",
53
+ "@eslint-react/core": "1.22.0-next.0",
54
+ "@eslint-react/eff": "1.22.0-next.0",
55
+ "@eslint-react/shared": "1.22.0-next.0",
56
+ "@eslint-react/types": "1.22.0-next.0",
57
+ "@eslint-react/var": "1.22.0-next.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/react": "^19.0.2",