eslint-plugin-react-dom 1.34.0-beta.0 → 1.34.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -40,7 +40,7 @@ var settings = {
40
40
 
41
41
  // package.json
42
42
  var name2 = "eslint-plugin-react-dom";
43
- var version = "1.34.0-beta.0";
43
+ var version = "1.34.0-beta.2";
44
44
  var createRule = createRuleForPlugin("dom");
45
45
 
46
46
  // src/utils/find-custom-component.ts
@@ -88,26 +88,27 @@ var no_dangerously_set_innerhtml_default = createRule({
88
88
  schema: []
89
89
  },
90
90
  name: RULE_NAME,
91
- create(context) {
92
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
93
- return {
94
- JSXElement(node) {
95
- const attributes = node.openingElement.attributes;
96
- const attribute = JSX.getAttribute(
97
- "dangerouslySetInnerHTML",
98
- attributes,
99
- context.sourceCode.getScope(node)
100
- );
101
- if (attribute == null) return;
102
- context.report({
103
- messageId: "noDangerouslySetInnerhtml",
104
- node: attribute
105
- });
106
- }
107
- };
108
- },
91
+ create,
109
92
  defaultOptions: []
110
93
  });
94
+ function create(context) {
95
+ if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
96
+ return {
97
+ JSXElement(node) {
98
+ const attributes = node.openingElement.attributes;
99
+ const attribute = JSX.getAttribute(
100
+ "dangerouslySetInnerHTML",
101
+ attributes,
102
+ context.sourceCode.getScope(node)
103
+ );
104
+ if (attribute == null) return;
105
+ context.report({
106
+ messageId: "noDangerouslySetInnerhtml",
107
+ node: attribute
108
+ });
109
+ }
110
+ };
111
+ }
111
112
  var RULE_NAME2 = "no-dangerously-set-innerhtml-with-children";
112
113
  var RULE_FEATURES2 = [
113
114
  "CHK"
@@ -125,24 +126,25 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
125
126
  schema: []
126
127
  },
127
128
  name: RULE_NAME2,
128
- create(context) {
129
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
130
- return {
131
- JSXElement(node) {
132
- const attributes = node.openingElement.attributes;
133
- const initialScope = context.sourceCode.getScope(node);
134
- const hasChildren = hasChildrenWithin(node) || JSX.hasAttribute("children", attributes, initialScope);
135
- if (hasChildren && JSX.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
136
- context.report({
137
- messageId: "noDangerouslySetInnerhtmlWithChildren",
138
- node
139
- });
140
- }
141
- }
142
- };
143
- },
129
+ create: create2,
144
130
  defaultOptions: []
145
131
  });
132
+ function create2(context) {
133
+ if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
134
+ return {
135
+ JSXElement(node) {
136
+ const attributes = node.openingElement.attributes;
137
+ const initialScope = context.sourceCode.getScope(node);
138
+ const hasChildren = hasChildrenWithin(node) || JSX.hasAttribute("children", attributes, initialScope);
139
+ if (hasChildren && JSX.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
140
+ context.report({
141
+ messageId: "noDangerouslySetInnerhtmlWithChildren",
142
+ node
143
+ });
144
+ }
145
+ }
146
+ };
147
+ }
146
148
  function hasChildrenWithin(node) {
147
149
  return node.children.length > 0 && node.children[0] != null && !JSX.isLineBreak(node.children[0]);
148
150
  }
@@ -163,28 +165,29 @@ var no_find_dom_node_default = createRule({
163
165
  schema: []
164
166
  },
165
167
  name: RULE_NAME3,
166
- create(context) {
167
- if (!context.sourceCode.text.includes("findDOMNode")) return {};
168
- return {
169
- CallExpression(node) {
170
- const { callee } = node;
171
- switch (callee.type) {
172
- case AST_NODE_TYPES.Identifier:
173
- if (callee.name === "findDOMNode") {
174
- context.report({ messageId: "noFindDomNode", node });
175
- }
176
- return;
177
- case AST_NODE_TYPES.MemberExpression:
178
- if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
179
- context.report({ messageId: "noFindDomNode", node });
180
- }
181
- return;
182
- }
183
- }
184
- };
185
- },
168
+ create: create3,
186
169
  defaultOptions: []
187
170
  });
171
+ function create3(context) {
172
+ if (!context.sourceCode.text.includes("findDOMNode")) return {};
173
+ return {
174
+ CallExpression(node) {
175
+ const { callee } = node;
176
+ switch (callee.type) {
177
+ case AST_NODE_TYPES.Identifier:
178
+ if (callee.name === "findDOMNode") {
179
+ context.report({ messageId: "noFindDomNode", node });
180
+ }
181
+ return;
182
+ case AST_NODE_TYPES.MemberExpression:
183
+ if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
184
+ context.report({ messageId: "noFindDomNode", node });
185
+ }
186
+ return;
187
+ }
188
+ }
189
+ };
190
+ }
188
191
  var RULE_NAME4 = "no-flush-sync";
189
192
  var RULE_FEATURES4 = [
190
193
  "CHK"
@@ -202,28 +205,29 @@ var no_flush_sync_default = createRule({
202
205
  schema: []
203
206
  },
204
207
  name: RULE_NAME4,
205
- create(context) {
206
- if (!context.sourceCode.text.includes("flushSync")) return {};
207
- return {
208
- CallExpression(node) {
209
- const { callee } = node;
210
- switch (callee.type) {
211
- case AST_NODE_TYPES.Identifier:
212
- if (callee.name === "flushSync") {
213
- context.report({ messageId: "noFlushSync", node });
214
- }
215
- return;
216
- case AST_NODE_TYPES.MemberExpression:
217
- if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
218
- context.report({ messageId: "noFlushSync", node });
219
- }
220
- return;
221
- }
222
- }
223
- };
224
- },
208
+ create: create4,
225
209
  defaultOptions: []
226
210
  });
211
+ function create4(context) {
212
+ if (!context.sourceCode.text.includes("flushSync")) return {};
213
+ return {
214
+ CallExpression(node) {
215
+ const { callee } = node;
216
+ switch (callee.type) {
217
+ case AST_NODE_TYPES.Identifier:
218
+ if (callee.name === "flushSync") {
219
+ context.report({ messageId: "noFlushSync", node });
220
+ }
221
+ return;
222
+ case AST_NODE_TYPES.MemberExpression:
223
+ if (callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
224
+ context.report({ messageId: "noFlushSync", node });
225
+ }
226
+ return;
227
+ }
228
+ }
229
+ };
230
+ }
227
231
  var RULE_NAME5 = "no-missing-button-type";
228
232
  var RULE_FEATURES5 = [
229
233
  "CHK"
@@ -241,50 +245,51 @@ var no_missing_button_type_default = createRule({
241
245
  schema: []
242
246
  },
243
247
  name: RULE_NAME5,
244
- create(context) {
245
- const settings2 = getSettingsFromContext(context);
246
- const polymorphicPropName = settings2.polymorphicPropName;
247
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
248
- return {
249
- JSXElement(node) {
250
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
251
- context,
252
- node,
253
- polymorphicPropName,
254
- additionalComponents
255
- );
256
- if (elementNameOnDom !== "button") return;
257
- const elementScope = context.sourceCode.getScope(node);
258
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
259
- const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
260
- const propNameOnJsx = customComponentProp?.name ?? "type";
261
- const attributeNode = JSX.getAttribute(
262
- propNameOnJsx,
263
- node.openingElement.attributes,
264
- elementScope
265
- );
266
- if (attributeNode != null) {
267
- const attributeScope = context.sourceCode.getScope(attributeNode);
268
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
269
- if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
270
- context.report({
271
- messageId: "noMissingButtonType",
272
- node: attributeNode
273
- });
274
- }
275
- return;
276
- }
277
- if (typeof customComponentProp?.defaultValue !== "string") {
248
+ create: create5,
249
+ defaultOptions: []
250
+ });
251
+ function create5(context) {
252
+ const settings2 = getSettingsFromContext(context);
253
+ const polymorphicPropName = settings2.polymorphicPropName;
254
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
255
+ return {
256
+ JSXElement(node) {
257
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
258
+ context,
259
+ node,
260
+ polymorphicPropName,
261
+ additionalComponents
262
+ );
263
+ if (elementNameOnDom !== "button") return;
264
+ const elementScope = context.sourceCode.getScope(node);
265
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
266
+ const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
267
+ const propNameOnJsx = customComponentProp?.name ?? "type";
268
+ const attributeNode = JSX.getAttribute(
269
+ propNameOnJsx,
270
+ node.openingElement.attributes,
271
+ elementScope
272
+ );
273
+ if (attributeNode != null) {
274
+ const attributeScope = context.sourceCode.getScope(attributeNode);
275
+ const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
276
+ if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
278
277
  context.report({
279
278
  messageId: "noMissingButtonType",
280
- node
279
+ node: attributeNode
281
280
  });
282
281
  }
282
+ return;
283
283
  }
284
- };
285
- },
286
- defaultOptions: []
287
- });
284
+ if (typeof customComponentProp?.defaultValue !== "string") {
285
+ context.report({
286
+ messageId: "noMissingButtonType",
287
+ node
288
+ });
289
+ }
290
+ }
291
+ };
292
+ }
288
293
  var RULE_NAME6 = "no-missing-iframe-sandbox";
289
294
  var RULE_FEATURES6 = [
290
295
  "CHK"
@@ -323,49 +328,50 @@ var no_missing_iframe_sandbox_default = createRule({
323
328
  schema: []
324
329
  },
325
330
  name: RULE_NAME6,
326
- create(context) {
327
- const settings2 = getSettingsFromContext(context);
328
- const polymorphicPropName = settings2.polymorphicPropName;
329
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
330
- return {
331
- JSXElement(node) {
332
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
333
- context,
334
- node,
335
- polymorphicPropName,
336
- additionalComponents
337
- );
338
- if (elementNameOnDom !== "iframe") return;
339
- const elementScope = context.sourceCode.getScope(node);
340
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
341
- const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
342
- const propNameOnJsx = customComponentProp?.name ?? "sandbox";
343
- const attributeNode = JSX.getAttribute(
344
- propNameOnJsx,
345
- node.openingElement.attributes,
346
- elementScope
347
- );
348
- if (attributeNode != null) {
349
- const attributeScope = context.sourceCode.getScope(attributeNode);
350
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
351
- if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
352
- context.report({
353
- messageId: "noMissingIframeSandbox",
354
- node: attributeNode
355
- });
356
- return;
357
- }
358
- if (!hasValidSandBox(customComponentProp?.defaultValue)) {
359
- context.report({
360
- messageId: "noMissingIframeSandbox",
361
- node
362
- });
363
- }
364
- }
365
- };
366
- },
331
+ create: create6,
367
332
  defaultOptions: []
368
333
  });
334
+ function create6(context) {
335
+ const settings2 = getSettingsFromContext(context);
336
+ const polymorphicPropName = settings2.polymorphicPropName;
337
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
338
+ return {
339
+ JSXElement(node) {
340
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
341
+ context,
342
+ node,
343
+ polymorphicPropName,
344
+ additionalComponents
345
+ );
346
+ if (elementNameOnDom !== "iframe") return;
347
+ const elementScope = context.sourceCode.getScope(node);
348
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
349
+ const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
350
+ const propNameOnJsx = customComponentProp?.name ?? "sandbox";
351
+ const attributeNode = JSX.getAttribute(
352
+ propNameOnJsx,
353
+ node.openingElement.attributes,
354
+ elementScope
355
+ );
356
+ if (attributeNode != null) {
357
+ const attributeScope = context.sourceCode.getScope(attributeNode);
358
+ const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
359
+ if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
360
+ context.report({
361
+ messageId: "noMissingIframeSandbox",
362
+ node: attributeNode
363
+ });
364
+ return;
365
+ }
366
+ if (!hasValidSandBox(customComponentProp?.defaultValue)) {
367
+ context.report({
368
+ messageId: "noMissingIframeSandbox",
369
+ node
370
+ });
371
+ }
372
+ }
373
+ };
374
+ }
369
375
  var RULE_NAME7 = "no-namespace";
370
376
  var RULE_FEATURES7 = [
371
377
  "CHK"
@@ -383,25 +389,26 @@ var no_namespace_default = createRule({
383
389
  schema: []
384
390
  },
385
391
  name: RULE_NAME7,
386
- create(context) {
387
- return {
388
- JSXElement(node) {
389
- const name3 = JSX.getElementType(node);
390
- if (typeof name3 !== "string" || !name3.includes(":")) {
391
- return;
392
- }
393
- context.report({
394
- messageId: "noNamespace",
395
- node: node.openingElement.name,
396
- data: {
397
- name: name3
398
- }
399
- });
400
- }
401
- };
402
- },
392
+ create: create7,
403
393
  defaultOptions: []
404
394
  });
395
+ function create7(context) {
396
+ return {
397
+ JSXElement(node) {
398
+ const name3 = JSX.getElementType(node);
399
+ if (typeof name3 !== "string" || !name3.includes(":")) {
400
+ return;
401
+ }
402
+ context.report({
403
+ messageId: "noNamespace",
404
+ node: node.openingElement.name,
405
+ data: {
406
+ name: name3
407
+ }
408
+ });
409
+ }
410
+ };
411
+ }
405
412
  var RULE_NAME8 = "no-render-return-value";
406
413
  var RULE_FEATURES8 = [
407
414
  "CHK"
@@ -426,35 +433,36 @@ var no_render_return_value_default = createRule({
426
433
  schema: []
427
434
  },
428
435
  name: RULE_NAME8,
429
- create(context) {
430
- return {
431
- CallExpression(node) {
432
- const { callee, parent } = node;
433
- if (callee.type !== AST_NODE_TYPES.MemberExpression) {
434
- return;
435
- }
436
- if (callee.object.type !== AST_NODE_TYPES.Identifier) {
437
- return;
438
- }
439
- if (!("name" in callee.object)) {
440
- return;
441
- }
442
- const objectName = callee.object.name;
443
- if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST.isOneOf(banParentTypes)(parent)) {
444
- return;
445
- }
446
- context.report({
447
- messageId: "noRenderReturnValue",
448
- node,
449
- data: {
450
- objectName
451
- }
452
- });
453
- }
454
- };
455
- },
436
+ create: create8,
456
437
  defaultOptions: []
457
438
  });
439
+ function create8(context) {
440
+ return {
441
+ CallExpression(node) {
442
+ const { callee, parent } = node;
443
+ if (callee.type !== AST_NODE_TYPES.MemberExpression) {
444
+ return;
445
+ }
446
+ if (callee.object.type !== AST_NODE_TYPES.Identifier) {
447
+ return;
448
+ }
449
+ if (!("name" in callee.object)) {
450
+ return;
451
+ }
452
+ const objectName = callee.object.name;
453
+ if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST.isOneOf(banParentTypes)(parent)) {
454
+ return;
455
+ }
456
+ context.report({
457
+ messageId: "noRenderReturnValue",
458
+ node,
459
+ data: {
460
+ objectName
461
+ }
462
+ });
463
+ }
464
+ };
465
+ }
458
466
  var RULE_NAME9 = "no-script-url";
459
467
  var RULE_FEATURES9 = [
460
468
  "CHK"
@@ -472,27 +480,28 @@ var no_script_url_default = createRule({
472
480
  schema: []
473
481
  },
474
482
  name: RULE_NAME9,
475
- create(context) {
476
- return {
477
- JSXAttribute(node) {
478
- if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) {
479
- return;
480
- }
481
- const attributeScope = context.sourceCode.getScope(node);
482
- const attributeName = JSX.getAttributeName(node);
483
- const attributeValue = JSX.getAttributeValue(node, attributeName, attributeScope);
484
- if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
485
- if (RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
486
- context.report({
487
- messageId: "noScriptUrl",
488
- node: node.value
489
- });
490
- }
491
- }
492
- };
493
- },
483
+ create: create9,
494
484
  defaultOptions: []
495
485
  });
486
+ function create9(context) {
487
+ return {
488
+ JSXAttribute(node) {
489
+ if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) {
490
+ return;
491
+ }
492
+ const attributeScope = context.sourceCode.getScope(node);
493
+ const attributeName = JSX.getAttributeName(node);
494
+ const attributeValue = JSX.getAttributeValue(node, attributeName, attributeScope);
495
+ if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
496
+ if (RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
497
+ context.report({
498
+ messageId: "noScriptUrl",
499
+ node: node.value
500
+ });
501
+ }
502
+ }
503
+ };
504
+ }
496
505
  var RULE_NAME10 = "no-unknown-property";
497
506
  var DEFAULTS = {
498
507
  ignore: [],
@@ -1433,6 +1442,7 @@ var messages = {
1433
1442
  };
1434
1443
  var no_unknown_property_default = createRule({
1435
1444
  meta: {
1445
+ type: "problem",
1436
1446
  docs: {
1437
1447
  description: "disallow usage of unknown DOM property"
1438
1448
  },
@@ -1456,84 +1466,85 @@ var no_unknown_property_default = createRule({
1456
1466
  }]
1457
1467
  },
1458
1468
  name: RULE_NAME10,
1459
- create(context) {
1460
- function getIgnoreConfig() {
1461
- return context.options[0]?.ignore || DEFAULTS.ignore;
1462
- }
1463
- function getRequireDataLowercase() {
1464
- return context.options[0] && typeof context.options[0].requireDataLowercase !== "undefined" ? !!context.options[0].requireDataLowercase : DEFAULTS.requireDataLowercase;
1465
- }
1466
- return {
1467
- JSXAttribute(node) {
1468
- const ignoreNames = getIgnoreConfig();
1469
- const actualName = getText(context, node.name);
1470
- if (ignoreNames.indexOf(actualName) >= 0) {
1471
- return;
1472
- }
1473
- const name3 = normalizeAttributeCase(actualName);
1474
- if (tagNameHasDot(node)) {
1475
- return;
1476
- }
1477
- if (isValidDataAttribute(name3)) {
1478
- if (getRequireDataLowercase() && hasUpperCaseCharacter(name3)) {
1479
- report(context, messages.dataLowercaseRequired, "dataLowercaseRequired", {
1480
- node,
1481
- data: {
1482
- name: actualName,
1483
- lowerCaseName: actualName.toLowerCase()
1484
- }
1485
- });
1486
- }
1487
- return;
1488
- }
1489
- if (isValidAriaAttribute(name3)) return;
1490
- const tagName = getTagName(node);
1491
- if (tagName === "fbt" || tagName === "fbs") return;
1492
- if (!isValidHTMLTagInJSX(node)) return;
1493
- const allowedTags = has(ATTRIBUTE_TAGS_MAP, name3) ? ATTRIBUTE_TAGS_MAP[name3] : null;
1494
- if (tagName && allowedTags) {
1495
- if (allowedTags.indexOf(tagName) === -1) {
1496
- report(context, messages.invalidPropOnTag, "invalidPropOnTag", {
1497
- node,
1498
- data: {
1499
- name: actualName,
1500
- allowedTags: allowedTags.join(", "),
1501
- tagName
1502
- }
1503
- });
1504
- }
1505
- return;
1506
- }
1507
- const standardName = getStandardName(name3, context);
1508
- const hasStandardNameButIsNotUsed = standardName && standardName !== name3;
1509
- const usesStandardName = standardName && standardName === name3;
1510
- if (usesStandardName) {
1511
- return;
1469
+ create: create10,
1470
+ defaultOptions: []
1471
+ });
1472
+ function create10(context) {
1473
+ function getIgnoreConfig() {
1474
+ return context.options[0]?.ignore || DEFAULTS.ignore;
1475
+ }
1476
+ function getRequireDataLowercase() {
1477
+ return context.options[0] && typeof context.options[0].requireDataLowercase !== "undefined" ? !!context.options[0].requireDataLowercase : DEFAULTS.requireDataLowercase;
1478
+ }
1479
+ return {
1480
+ JSXAttribute(node) {
1481
+ const ignoreNames = getIgnoreConfig();
1482
+ const actualName = getText(context, node.name);
1483
+ if (ignoreNames.indexOf(actualName) >= 0) {
1484
+ return;
1485
+ }
1486
+ const name3 = normalizeAttributeCase(actualName);
1487
+ if (tagNameHasDot(node)) {
1488
+ return;
1489
+ }
1490
+ if (isValidDataAttribute(name3)) {
1491
+ if (getRequireDataLowercase() && hasUpperCaseCharacter(name3)) {
1492
+ report(context, messages.dataLowercaseRequired, "dataLowercaseRequired", {
1493
+ node,
1494
+ data: {
1495
+ name: actualName,
1496
+ lowerCaseName: actualName.toLowerCase()
1497
+ }
1498
+ });
1512
1499
  }
1513
- if (hasStandardNameButIsNotUsed) {
1514
- report(context, messages.unknownPropWithStandardName, "unknownPropWithStandardName", {
1500
+ return;
1501
+ }
1502
+ if (isValidAriaAttribute(name3)) return;
1503
+ const tagName = getTagName(node);
1504
+ if (tagName === "fbt" || tagName === "fbs") return;
1505
+ if (!isValidHTMLTagInJSX(node)) return;
1506
+ const allowedTags = has(ATTRIBUTE_TAGS_MAP, name3) ? ATTRIBUTE_TAGS_MAP[name3] : null;
1507
+ if (tagName && allowedTags) {
1508
+ if (allowedTags.indexOf(tagName) === -1) {
1509
+ report(context, messages.invalidPropOnTag, "invalidPropOnTag", {
1515
1510
  node,
1516
1511
  data: {
1517
1512
  name: actualName,
1518
- standardName
1519
- },
1520
- fix(fixer) {
1521
- return fixer.replaceText(node.name, standardName);
1513
+ allowedTags: allowedTags.join(", "),
1514
+ tagName
1522
1515
  }
1523
1516
  });
1524
- return;
1525
1517
  }
1526
- report(context, messages.unknownProp, "unknownProp", {
1518
+ return;
1519
+ }
1520
+ const standardName = getStandardName(name3, context);
1521
+ const hasStandardNameButIsNotUsed = standardName && standardName !== name3;
1522
+ const usesStandardName = standardName && standardName === name3;
1523
+ if (usesStandardName) {
1524
+ return;
1525
+ }
1526
+ if (hasStandardNameButIsNotUsed) {
1527
+ report(context, messages.unknownPropWithStandardName, "unknownPropWithStandardName", {
1527
1528
  node,
1528
1529
  data: {
1529
- name: actualName
1530
+ name: actualName,
1531
+ standardName
1532
+ },
1533
+ fix(fixer) {
1534
+ return fixer.replaceText(node.name, standardName);
1530
1535
  }
1531
1536
  });
1537
+ return;
1532
1538
  }
1533
- };
1534
- },
1535
- defaultOptions: []
1536
- });
1539
+ report(context, messages.unknownProp, "unknownProp", {
1540
+ node,
1541
+ data: {
1542
+ name: actualName
1543
+ }
1544
+ });
1545
+ }
1546
+ };
1547
+ }
1537
1548
  function has(obj, key) {
1538
1549
  return Object.hasOwn(obj, key);
1539
1550
  }
@@ -1576,51 +1587,52 @@ var no_unsafe_iframe_sandbox_default = createRule({
1576
1587
  schema: []
1577
1588
  },
1578
1589
  name: RULE_NAME11,
1579
- create(context) {
1580
- const settings2 = getSettingsFromContext(context);
1581
- const polymorphicPropName = settings2.polymorphicPropName;
1582
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
1583
- return {
1584
- JSXElement(node) {
1585
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1586
- context,
1587
- node,
1588
- polymorphicPropName,
1589
- additionalComponents
1590
- );
1591
- if (elementNameOnDom !== "iframe") return;
1592
- const elementScope = context.sourceCode.getScope(node);
1593
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1594
- const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
1595
- const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1596
- const attributeNode = JSX.getAttribute(
1597
- propNameOnJsx,
1598
- node.openingElement.attributes,
1599
- elementScope
1600
- );
1601
- if (attributeNode != null) {
1602
- const attributeScope = context.sourceCode.getScope(attributeNode);
1603
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1604
- if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1605
- context.report({
1606
- messageId: "noUnsafeIframeSandbox",
1607
- node: attributeNode
1608
- });
1609
- return;
1610
- }
1611
- }
1612
- if (customComponentProp?.defaultValue == null) return;
1613
- if (!hasSafeSandbox(customComponentProp.defaultValue)) {
1590
+ create: create11,
1591
+ defaultOptions: []
1592
+ });
1593
+ function create11(context) {
1594
+ const settings2 = getSettingsFromContext(context);
1595
+ const polymorphicPropName = settings2.polymorphicPropName;
1596
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
1597
+ return {
1598
+ JSXElement(node) {
1599
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1600
+ context,
1601
+ node,
1602
+ polymorphicPropName,
1603
+ additionalComponents
1604
+ );
1605
+ if (elementNameOnDom !== "iframe") return;
1606
+ const elementScope = context.sourceCode.getScope(node);
1607
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1608
+ const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
1609
+ const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1610
+ const attributeNode = JSX.getAttribute(
1611
+ propNameOnJsx,
1612
+ node.openingElement.attributes,
1613
+ elementScope
1614
+ );
1615
+ if (attributeNode != null) {
1616
+ const attributeScope = context.sourceCode.getScope(attributeNode);
1617
+ const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1618
+ if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1614
1619
  context.report({
1615
1620
  messageId: "noUnsafeIframeSandbox",
1616
- node
1621
+ node: attributeNode
1617
1622
  });
1623
+ return;
1618
1624
  }
1619
1625
  }
1620
- };
1621
- },
1622
- defaultOptions: []
1623
- });
1626
+ if (customComponentProp?.defaultValue == null) return;
1627
+ if (!hasSafeSandbox(customComponentProp.defaultValue)) {
1628
+ context.report({
1629
+ messageId: "noUnsafeIframeSandbox",
1630
+ node
1631
+ });
1632
+ }
1633
+ }
1634
+ };
1635
+ }
1624
1636
  var RULE_NAME12 = "no-unsafe-target-blank";
1625
1637
  var RULE_FEATURES11 = [
1626
1638
  "CHK"
@@ -1646,55 +1658,56 @@ var no_unsafe_target_blank_default = createRule({
1646
1658
  schema: []
1647
1659
  },
1648
1660
  name: RULE_NAME12,
1649
- create(context) {
1650
- const settings2 = getSettingsFromContext(context);
1651
- const polymorphicPropName = settings2.polymorphicPropName;
1652
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
1653
- return {
1654
- JSXElement(node) {
1655
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1656
- context,
1657
- node,
1658
- polymorphicPropName,
1659
- additionalComponents
1661
+ create: create12,
1662
+ defaultOptions: []
1663
+ });
1664
+ function create12(context) {
1665
+ const settings2 = getSettingsFromContext(context);
1666
+ const polymorphicPropName = settings2.polymorphicPropName;
1667
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
1668
+ return {
1669
+ JSXElement(node) {
1670
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1671
+ context,
1672
+ node,
1673
+ polymorphicPropName,
1674
+ additionalComponents
1675
+ );
1676
+ if (elementNameOnDom !== "a") return;
1677
+ const elementScope = context.sourceCode.getScope(node);
1678
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1679
+ const getAttributeStringValue = (name3) => {
1680
+ const customComponentProp = findCustomComponentProp(name3, customComponent?.attributes ?? []);
1681
+ const propNameOnJsx = customComponentProp?.name ?? name3;
1682
+ const attributeNode = JSX.getAttribute(
1683
+ propNameOnJsx,
1684
+ node.openingElement.attributes,
1685
+ elementScope
1660
1686
  );
1661
- if (elementNameOnDom !== "a") return;
1662
- const elementScope = context.sourceCode.getScope(node);
1663
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1664
- const getAttributeStringValue = (name3) => {
1665
- const customComponentProp = findCustomComponentProp(name3, customComponent?.attributes ?? []);
1666
- const propNameOnJsx = customComponentProp?.name ?? name3;
1667
- const attributeNode = JSX.getAttribute(
1668
- propNameOnJsx,
1669
- node.openingElement.attributes,
1670
- elementScope
1671
- );
1672
- if (attributeNode == null) return customComponentProp?.defaultValue;
1673
- const attributeScope = context.sourceCode.getScope(attributeNode);
1674
- const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1675
- if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1676
- return attributeValue.value;
1677
- }
1678
- return _;
1679
- };
1680
- if (getAttributeStringValue("target") !== "_blank") {
1681
- return;
1682
- }
1683
- if (!isExternalLinkLike(getAttributeStringValue("href"))) {
1684
- return;
1687
+ if (attributeNode == null) return customComponentProp?.defaultValue;
1688
+ const attributeScope = context.sourceCode.getScope(attributeNode);
1689
+ const attributeValue = JSX.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1690
+ if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1691
+ return attributeValue.value;
1685
1692
  }
1686
- if (isSafeRel(getAttributeStringValue("rel"))) {
1687
- return;
1688
- }
1689
- context.report({
1690
- messageId: "noUnsafeTargetBlank",
1691
- node
1692
- });
1693
+ return _;
1694
+ };
1695
+ if (getAttributeStringValue("target") !== "_blank") {
1696
+ return;
1693
1697
  }
1694
- };
1695
- },
1696
- defaultOptions: []
1697
- });
1698
+ if (!isExternalLinkLike(getAttributeStringValue("href"))) {
1699
+ return;
1700
+ }
1701
+ if (isSafeRel(getAttributeStringValue("rel"))) {
1702
+ return;
1703
+ }
1704
+ context.report({
1705
+ messageId: "noUnsafeTargetBlank",
1706
+ node
1707
+ });
1708
+ }
1709
+ };
1710
+ }
1698
1711
  var RULE_NAME13 = "no-void-elements-with-children";
1699
1712
  var RULE_FEATURES12 = [
1700
1713
  "CHK"
@@ -1730,39 +1743,40 @@ var no_void_elements_with_children_default = createRule({
1730
1743
  schema: []
1731
1744
  },
1732
1745
  name: RULE_NAME13,
1733
- create(context) {
1734
- return {
1735
- JSXElement(node) {
1736
- const elementName = JSX.getElementType(node);
1737
- if (elementName.length === 0 || !voidElements.has(elementName)) {
1738
- return;
1739
- }
1740
- if (node.children.length > 0) {
1741
- context.report({
1742
- messageId: "noVoidElementsWithChildren",
1743
- node,
1744
- data: {
1745
- element: elementName
1746
- }
1747
- });
1748
- }
1749
- const { attributes } = node.openingElement;
1750
- const initialScope = context.sourceCode.getScope(node);
1751
- const hasAttribute3 = (name3) => JSX.hasAttribute(name3, attributes, initialScope);
1752
- if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1753
- context.report({
1754
- messageId: "noVoidElementsWithChildren",
1755
- node,
1756
- data: {
1757
- element: elementName
1758
- }
1759
- });
1760
- }
1761
- }
1762
- };
1763
- },
1746
+ create: create13,
1764
1747
  defaultOptions: []
1765
1748
  });
1749
+ function create13(context) {
1750
+ return {
1751
+ JSXElement(node) {
1752
+ const elementName = JSX.getElementType(node);
1753
+ if (elementName.length === 0 || !voidElements.has(elementName)) {
1754
+ return;
1755
+ }
1756
+ if (node.children.length > 0) {
1757
+ context.report({
1758
+ messageId: "noVoidElementsWithChildren",
1759
+ node,
1760
+ data: {
1761
+ element: elementName
1762
+ }
1763
+ });
1764
+ }
1765
+ const { attributes } = node.openingElement;
1766
+ const initialScope = context.sourceCode.getScope(node);
1767
+ const hasAttribute3 = (name3) => JSX.hasAttribute(name3, attributes, initialScope);
1768
+ if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1769
+ context.report({
1770
+ messageId: "noVoidElementsWithChildren",
1771
+ node,
1772
+ data: {
1773
+ element: elementName
1774
+ }
1775
+ });
1776
+ }
1777
+ }
1778
+ };
1779
+ }
1766
1780
 
1767
1781
  // src/plugin.ts
1768
1782
  var plugin = {