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

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
@@ -63,7 +63,7 @@ var settings = {
63
63
 
64
64
  // package.json
65
65
  var name2 = "eslint-plugin-react-dom";
66
- var version = "1.34.0-beta.0";
66
+ var version = "1.34.0-beta.1";
67
67
  var createRule = shared.createRuleForPlugin("dom");
68
68
 
69
69
  // src/utils/find-custom-component.ts
@@ -111,26 +111,27 @@ var no_dangerously_set_innerhtml_default = createRule({
111
111
  schema: []
112
112
  },
113
113
  name: RULE_NAME,
114
- create(context) {
115
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
116
- return {
117
- JSXElement(node) {
118
- const attributes = node.openingElement.attributes;
119
- const attribute = JSX__namespace.getAttribute(
120
- "dangerouslySetInnerHTML",
121
- attributes,
122
- context.sourceCode.getScope(node)
123
- );
124
- if (attribute == null) return;
125
- context.report({
126
- messageId: "noDangerouslySetInnerhtml",
127
- node: attribute
128
- });
129
- }
130
- };
131
- },
114
+ create,
132
115
  defaultOptions: []
133
116
  });
117
+ function create(context) {
118
+ if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
119
+ return {
120
+ JSXElement(node) {
121
+ const attributes = node.openingElement.attributes;
122
+ const attribute = JSX__namespace.getAttribute(
123
+ "dangerouslySetInnerHTML",
124
+ attributes,
125
+ context.sourceCode.getScope(node)
126
+ );
127
+ if (attribute == null) return;
128
+ context.report({
129
+ messageId: "noDangerouslySetInnerhtml",
130
+ node: attribute
131
+ });
132
+ }
133
+ };
134
+ }
134
135
  var RULE_NAME2 = "no-dangerously-set-innerhtml-with-children";
135
136
  var RULE_FEATURES2 = [
136
137
  "CHK"
@@ -148,24 +149,25 @@ var no_dangerously_set_innerhtml_with_children_default = createRule({
148
149
  schema: []
149
150
  },
150
151
  name: RULE_NAME2,
151
- create(context) {
152
- if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
153
- return {
154
- JSXElement(node) {
155
- const attributes = node.openingElement.attributes;
156
- const initialScope = context.sourceCode.getScope(node);
157
- const hasChildren = hasChildrenWithin(node) || JSX__namespace.hasAttribute("children", attributes, initialScope);
158
- if (hasChildren && JSX__namespace.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
159
- context.report({
160
- messageId: "noDangerouslySetInnerhtmlWithChildren",
161
- node
162
- });
163
- }
164
- }
165
- };
166
- },
152
+ create: create2,
167
153
  defaultOptions: []
168
154
  });
155
+ function create2(context) {
156
+ if (!context.sourceCode.text.includes("dangerouslySetInnerHTML")) return {};
157
+ return {
158
+ JSXElement(node) {
159
+ const attributes = node.openingElement.attributes;
160
+ const initialScope = context.sourceCode.getScope(node);
161
+ const hasChildren = hasChildrenWithin(node) || JSX__namespace.hasAttribute("children", attributes, initialScope);
162
+ if (hasChildren && JSX__namespace.hasAttribute("dangerouslySetInnerHTML", attributes, initialScope)) {
163
+ context.report({
164
+ messageId: "noDangerouslySetInnerhtmlWithChildren",
165
+ node
166
+ });
167
+ }
168
+ }
169
+ };
170
+ }
169
171
  function hasChildrenWithin(node) {
170
172
  return node.children.length > 0 && node.children[0] != null && !JSX__namespace.isLineBreak(node.children[0]);
171
173
  }
@@ -186,28 +188,29 @@ var no_find_dom_node_default = createRule({
186
188
  schema: []
187
189
  },
188
190
  name: RULE_NAME3,
189
- create(context) {
190
- if (!context.sourceCode.text.includes("findDOMNode")) return {};
191
- return {
192
- CallExpression(node) {
193
- const { callee } = node;
194
- switch (callee.type) {
195
- case types.AST_NODE_TYPES.Identifier:
196
- if (callee.name === "findDOMNode") {
197
- context.report({ messageId: "noFindDomNode", node });
198
- }
199
- return;
200
- case types.AST_NODE_TYPES.MemberExpression:
201
- if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
202
- context.report({ messageId: "noFindDomNode", node });
203
- }
204
- return;
205
- }
206
- }
207
- };
208
- },
191
+ create: create3,
209
192
  defaultOptions: []
210
193
  });
194
+ function create3(context) {
195
+ if (!context.sourceCode.text.includes("findDOMNode")) return {};
196
+ return {
197
+ CallExpression(node) {
198
+ const { callee } = node;
199
+ switch (callee.type) {
200
+ case types.AST_NODE_TYPES.Identifier:
201
+ if (callee.name === "findDOMNode") {
202
+ context.report({ messageId: "noFindDomNode", node });
203
+ }
204
+ return;
205
+ case types.AST_NODE_TYPES.MemberExpression:
206
+ if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "findDOMNode") {
207
+ context.report({ messageId: "noFindDomNode", node });
208
+ }
209
+ return;
210
+ }
211
+ }
212
+ };
213
+ }
211
214
  var RULE_NAME4 = "no-flush-sync";
212
215
  var RULE_FEATURES4 = [
213
216
  "CHK"
@@ -225,28 +228,29 @@ var no_flush_sync_default = createRule({
225
228
  schema: []
226
229
  },
227
230
  name: RULE_NAME4,
228
- create(context) {
229
- if (!context.sourceCode.text.includes("flushSync")) return {};
230
- return {
231
- CallExpression(node) {
232
- const { callee } = node;
233
- switch (callee.type) {
234
- case types.AST_NODE_TYPES.Identifier:
235
- if (callee.name === "flushSync") {
236
- context.report({ messageId: "noFlushSync", node });
237
- }
238
- return;
239
- case types.AST_NODE_TYPES.MemberExpression:
240
- if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
241
- context.report({ messageId: "noFlushSync", node });
242
- }
243
- return;
244
- }
245
- }
246
- };
247
- },
231
+ create: create4,
248
232
  defaultOptions: []
249
233
  });
234
+ function create4(context) {
235
+ if (!context.sourceCode.text.includes("flushSync")) return {};
236
+ return {
237
+ CallExpression(node) {
238
+ const { callee } = node;
239
+ switch (callee.type) {
240
+ case types.AST_NODE_TYPES.Identifier:
241
+ if (callee.name === "flushSync") {
242
+ context.report({ messageId: "noFlushSync", node });
243
+ }
244
+ return;
245
+ case types.AST_NODE_TYPES.MemberExpression:
246
+ if (callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "flushSync") {
247
+ context.report({ messageId: "noFlushSync", node });
248
+ }
249
+ return;
250
+ }
251
+ }
252
+ };
253
+ }
250
254
  var RULE_NAME5 = "no-missing-button-type";
251
255
  var RULE_FEATURES5 = [
252
256
  "CHK"
@@ -264,50 +268,51 @@ var no_missing_button_type_default = createRule({
264
268
  schema: []
265
269
  },
266
270
  name: RULE_NAME5,
267
- create(context) {
268
- const settings2 = shared.getSettingsFromContext(context);
269
- const polymorphicPropName = settings2.polymorphicPropName;
270
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
271
- return {
272
- JSXElement(node) {
273
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
274
- context,
275
- node,
276
- polymorphicPropName,
277
- additionalComponents
278
- );
279
- if (elementNameOnDom !== "button") return;
280
- const elementScope = context.sourceCode.getScope(node);
281
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
282
- const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
283
- const propNameOnJsx = customComponentProp?.name ?? "type";
284
- const attributeNode = JSX__namespace.getAttribute(
285
- propNameOnJsx,
286
- node.openingElement.attributes,
287
- elementScope
288
- );
289
- if (attributeNode != null) {
290
- const attributeScope = context.sourceCode.getScope(attributeNode);
291
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
292
- if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
293
- context.report({
294
- messageId: "noMissingButtonType",
295
- node: attributeNode
296
- });
297
- }
298
- return;
299
- }
300
- if (typeof customComponentProp?.defaultValue !== "string") {
271
+ create: create5,
272
+ defaultOptions: []
273
+ });
274
+ function create5(context) {
275
+ const settings2 = shared.getSettingsFromContext(context);
276
+ const polymorphicPropName = settings2.polymorphicPropName;
277
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "button");
278
+ return {
279
+ JSXElement(node) {
280
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
281
+ context,
282
+ node,
283
+ polymorphicPropName,
284
+ additionalComponents
285
+ );
286
+ if (elementNameOnDom !== "button") return;
287
+ const elementScope = context.sourceCode.getScope(node);
288
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
289
+ const customComponentProp = findCustomComponentProp("type", customComponent?.attributes ?? []);
290
+ const propNameOnJsx = customComponentProp?.name ?? "type";
291
+ const attributeNode = JSX__namespace.getAttribute(
292
+ propNameOnJsx,
293
+ node.openingElement.attributes,
294
+ elementScope
295
+ );
296
+ if (attributeNode != null) {
297
+ const attributeScope = context.sourceCode.getScope(attributeNode);
298
+ const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
299
+ if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
301
300
  context.report({
302
301
  messageId: "noMissingButtonType",
303
- node
302
+ node: attributeNode
304
303
  });
305
304
  }
305
+ return;
306
306
  }
307
- };
308
- },
309
- defaultOptions: []
310
- });
307
+ if (typeof customComponentProp?.defaultValue !== "string") {
308
+ context.report({
309
+ messageId: "noMissingButtonType",
310
+ node
311
+ });
312
+ }
313
+ }
314
+ };
315
+ }
311
316
  var RULE_NAME6 = "no-missing-iframe-sandbox";
312
317
  var RULE_FEATURES6 = [
313
318
  "CHK"
@@ -346,49 +351,50 @@ var no_missing_iframe_sandbox_default = createRule({
346
351
  schema: []
347
352
  },
348
353
  name: RULE_NAME6,
349
- create(context) {
350
- const settings2 = shared.getSettingsFromContext(context);
351
- const polymorphicPropName = settings2.polymorphicPropName;
352
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
353
- return {
354
- JSXElement(node) {
355
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
356
- context,
357
- node,
358
- polymorphicPropName,
359
- additionalComponents
360
- );
361
- if (elementNameOnDom !== "iframe") return;
362
- const elementScope = context.sourceCode.getScope(node);
363
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
364
- const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
365
- const propNameOnJsx = customComponentProp?.name ?? "sandbox";
366
- const attributeNode = JSX__namespace.getAttribute(
367
- propNameOnJsx,
368
- node.openingElement.attributes,
369
- elementScope
370
- );
371
- if (attributeNode != null) {
372
- const attributeScope = context.sourceCode.getScope(attributeNode);
373
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
374
- if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
375
- context.report({
376
- messageId: "noMissingIframeSandbox",
377
- node: attributeNode
378
- });
379
- return;
380
- }
381
- if (!hasValidSandBox(customComponentProp?.defaultValue)) {
382
- context.report({
383
- messageId: "noMissingIframeSandbox",
384
- node
385
- });
386
- }
387
- }
388
- };
389
- },
354
+ create: create6,
390
355
  defaultOptions: []
391
356
  });
357
+ function create6(context) {
358
+ const settings2 = shared.getSettingsFromContext(context);
359
+ const polymorphicPropName = settings2.polymorphicPropName;
360
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
361
+ return {
362
+ JSXElement(node) {
363
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
364
+ context,
365
+ node,
366
+ polymorphicPropName,
367
+ additionalComponents
368
+ );
369
+ if (elementNameOnDom !== "iframe") return;
370
+ const elementScope = context.sourceCode.getScope(node);
371
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
372
+ const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
373
+ const propNameOnJsx = customComponentProp?.name ?? "sandbox";
374
+ const attributeNode = JSX__namespace.getAttribute(
375
+ propNameOnJsx,
376
+ node.openingElement.attributes,
377
+ elementScope
378
+ );
379
+ if (attributeNode != null) {
380
+ const attributeScope = context.sourceCode.getScope(attributeNode);
381
+ const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
382
+ if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
383
+ context.report({
384
+ messageId: "noMissingIframeSandbox",
385
+ node: attributeNode
386
+ });
387
+ return;
388
+ }
389
+ if (!hasValidSandBox(customComponentProp?.defaultValue)) {
390
+ context.report({
391
+ messageId: "noMissingIframeSandbox",
392
+ node
393
+ });
394
+ }
395
+ }
396
+ };
397
+ }
392
398
  var RULE_NAME7 = "no-namespace";
393
399
  var RULE_FEATURES7 = [
394
400
  "CHK"
@@ -406,25 +412,26 @@ var no_namespace_default = createRule({
406
412
  schema: []
407
413
  },
408
414
  name: RULE_NAME7,
409
- create(context) {
410
- return {
411
- JSXElement(node) {
412
- const name3 = JSX__namespace.getElementType(node);
413
- if (typeof name3 !== "string" || !name3.includes(":")) {
414
- return;
415
- }
416
- context.report({
417
- messageId: "noNamespace",
418
- node: node.openingElement.name,
419
- data: {
420
- name: name3
421
- }
422
- });
423
- }
424
- };
425
- },
415
+ create: create7,
426
416
  defaultOptions: []
427
417
  });
418
+ function create7(context) {
419
+ return {
420
+ JSXElement(node) {
421
+ const name3 = JSX__namespace.getElementType(node);
422
+ if (typeof name3 !== "string" || !name3.includes(":")) {
423
+ return;
424
+ }
425
+ context.report({
426
+ messageId: "noNamespace",
427
+ node: node.openingElement.name,
428
+ data: {
429
+ name: name3
430
+ }
431
+ });
432
+ }
433
+ };
434
+ }
428
435
  var RULE_NAME8 = "no-render-return-value";
429
436
  var RULE_FEATURES8 = [
430
437
  "CHK"
@@ -449,35 +456,36 @@ var no_render_return_value_default = createRule({
449
456
  schema: []
450
457
  },
451
458
  name: RULE_NAME8,
452
- create(context) {
453
- return {
454
- CallExpression(node) {
455
- const { callee, parent } = node;
456
- if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
457
- return;
458
- }
459
- if (callee.object.type !== types.AST_NODE_TYPES.Identifier) {
460
- return;
461
- }
462
- if (!("name" in callee.object)) {
463
- return;
464
- }
465
- const objectName = callee.object.name;
466
- if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== types.AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST__namespace.isOneOf(banParentTypes)(parent)) {
467
- return;
468
- }
469
- context.report({
470
- messageId: "noRenderReturnValue",
471
- node,
472
- data: {
473
- objectName
474
- }
475
- });
476
- }
477
- };
478
- },
459
+ create: create8,
479
460
  defaultOptions: []
480
461
  });
462
+ function create8(context) {
463
+ return {
464
+ CallExpression(node) {
465
+ const { callee, parent } = node;
466
+ if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
467
+ return;
468
+ }
469
+ if (callee.object.type !== types.AST_NODE_TYPES.Identifier) {
470
+ return;
471
+ }
472
+ if (!("name" in callee.object)) {
473
+ return;
474
+ }
475
+ const objectName = callee.object.name;
476
+ if (objectName.toLowerCase() !== "reactdom" || callee.property.type !== types.AST_NODE_TYPES.Identifier || callee.property.name !== "render" || !AST__namespace.isOneOf(banParentTypes)(parent)) {
477
+ return;
478
+ }
479
+ context.report({
480
+ messageId: "noRenderReturnValue",
481
+ node,
482
+ data: {
483
+ objectName
484
+ }
485
+ });
486
+ }
487
+ };
488
+ }
481
489
  var RULE_NAME9 = "no-script-url";
482
490
  var RULE_FEATURES9 = [
483
491
  "CHK"
@@ -495,27 +503,28 @@ var no_script_url_default = createRule({
495
503
  schema: []
496
504
  },
497
505
  name: RULE_NAME9,
498
- create(context) {
499
- return {
500
- JSXAttribute(node) {
501
- if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier || node.value == null) {
502
- return;
503
- }
504
- const attributeScope = context.sourceCode.getScope(node);
505
- const attributeName = JSX__namespace.getAttributeName(node);
506
- const attributeValue = JSX__namespace.getAttributeValue(node, attributeName, attributeScope);
507
- if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
508
- if (shared.RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
509
- context.report({
510
- messageId: "noScriptUrl",
511
- node: node.value
512
- });
513
- }
514
- }
515
- };
516
- },
506
+ create: create9,
517
507
  defaultOptions: []
518
508
  });
509
+ function create9(context) {
510
+ return {
511
+ JSXAttribute(node) {
512
+ if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier || node.value == null) {
513
+ return;
514
+ }
515
+ const attributeScope = context.sourceCode.getScope(node);
516
+ const attributeName = JSX__namespace.getAttributeName(node);
517
+ const attributeValue = JSX__namespace.getAttributeValue(node, attributeName, attributeScope);
518
+ if (attributeValue.kind === "none" || typeof attributeValue.value !== "string") return;
519
+ if (shared.RE_JAVASCRIPT_PROTOCOL.test(attributeValue.value)) {
520
+ context.report({
521
+ messageId: "noScriptUrl",
522
+ node: node.value
523
+ });
524
+ }
525
+ }
526
+ };
527
+ }
519
528
  var RULE_NAME10 = "no-unknown-property";
520
529
  var DEFAULTS = {
521
530
  ignore: [],
@@ -1456,6 +1465,7 @@ var messages = {
1456
1465
  };
1457
1466
  var no_unknown_property_default = createRule({
1458
1467
  meta: {
1468
+ type: "problem",
1459
1469
  docs: {
1460
1470
  description: "disallow usage of unknown DOM property"
1461
1471
  },
@@ -1479,84 +1489,85 @@ var no_unknown_property_default = createRule({
1479
1489
  }]
1480
1490
  },
1481
1491
  name: RULE_NAME10,
1482
- create(context) {
1483
- function getIgnoreConfig() {
1484
- return context.options[0]?.ignore || DEFAULTS.ignore;
1485
- }
1486
- function getRequireDataLowercase() {
1487
- return context.options[0] && typeof context.options[0].requireDataLowercase !== "undefined" ? !!context.options[0].requireDataLowercase : DEFAULTS.requireDataLowercase;
1488
- }
1489
- return {
1490
- JSXAttribute(node) {
1491
- const ignoreNames = getIgnoreConfig();
1492
- const actualName = getText(context, node.name);
1493
- if (ignoreNames.indexOf(actualName) >= 0) {
1494
- return;
1495
- }
1496
- const name3 = normalizeAttributeCase(actualName);
1497
- if (tagNameHasDot(node)) {
1498
- return;
1499
- }
1500
- if (isValidDataAttribute(name3)) {
1501
- if (getRequireDataLowercase() && hasUpperCaseCharacter(name3)) {
1502
- report(context, messages.dataLowercaseRequired, "dataLowercaseRequired", {
1503
- node,
1504
- data: {
1505
- name: actualName,
1506
- lowerCaseName: actualName.toLowerCase()
1507
- }
1508
- });
1509
- }
1510
- return;
1511
- }
1512
- if (isValidAriaAttribute(name3)) return;
1513
- const tagName = getTagName(node);
1514
- if (tagName === "fbt" || tagName === "fbs") return;
1515
- if (!isValidHTMLTagInJSX(node)) return;
1516
- const allowedTags = has(ATTRIBUTE_TAGS_MAP, name3) ? ATTRIBUTE_TAGS_MAP[name3] : null;
1517
- if (tagName && allowedTags) {
1518
- if (allowedTags.indexOf(tagName) === -1) {
1519
- report(context, messages.invalidPropOnTag, "invalidPropOnTag", {
1520
- node,
1521
- data: {
1522
- name: actualName,
1523
- allowedTags: allowedTags.join(", "),
1524
- tagName
1525
- }
1526
- });
1527
- }
1528
- return;
1529
- }
1530
- const standardName = getStandardName(name3, context);
1531
- const hasStandardNameButIsNotUsed = standardName && standardName !== name3;
1532
- const usesStandardName = standardName && standardName === name3;
1533
- if (usesStandardName) {
1534
- return;
1492
+ create: create10,
1493
+ defaultOptions: []
1494
+ });
1495
+ function create10(context) {
1496
+ function getIgnoreConfig() {
1497
+ return context.options[0]?.ignore || DEFAULTS.ignore;
1498
+ }
1499
+ function getRequireDataLowercase() {
1500
+ return context.options[0] && typeof context.options[0].requireDataLowercase !== "undefined" ? !!context.options[0].requireDataLowercase : DEFAULTS.requireDataLowercase;
1501
+ }
1502
+ return {
1503
+ JSXAttribute(node) {
1504
+ const ignoreNames = getIgnoreConfig();
1505
+ const actualName = getText(context, node.name);
1506
+ if (ignoreNames.indexOf(actualName) >= 0) {
1507
+ return;
1508
+ }
1509
+ const name3 = normalizeAttributeCase(actualName);
1510
+ if (tagNameHasDot(node)) {
1511
+ return;
1512
+ }
1513
+ if (isValidDataAttribute(name3)) {
1514
+ if (getRequireDataLowercase() && hasUpperCaseCharacter(name3)) {
1515
+ report(context, messages.dataLowercaseRequired, "dataLowercaseRequired", {
1516
+ node,
1517
+ data: {
1518
+ name: actualName,
1519
+ lowerCaseName: actualName.toLowerCase()
1520
+ }
1521
+ });
1535
1522
  }
1536
- if (hasStandardNameButIsNotUsed) {
1537
- report(context, messages.unknownPropWithStandardName, "unknownPropWithStandardName", {
1523
+ return;
1524
+ }
1525
+ if (isValidAriaAttribute(name3)) return;
1526
+ const tagName = getTagName(node);
1527
+ if (tagName === "fbt" || tagName === "fbs") return;
1528
+ if (!isValidHTMLTagInJSX(node)) return;
1529
+ const allowedTags = has(ATTRIBUTE_TAGS_MAP, name3) ? ATTRIBUTE_TAGS_MAP[name3] : null;
1530
+ if (tagName && allowedTags) {
1531
+ if (allowedTags.indexOf(tagName) === -1) {
1532
+ report(context, messages.invalidPropOnTag, "invalidPropOnTag", {
1538
1533
  node,
1539
1534
  data: {
1540
1535
  name: actualName,
1541
- standardName
1542
- },
1543
- fix(fixer) {
1544
- return fixer.replaceText(node.name, standardName);
1536
+ allowedTags: allowedTags.join(", "),
1537
+ tagName
1545
1538
  }
1546
1539
  });
1547
- return;
1548
1540
  }
1549
- report(context, messages.unknownProp, "unknownProp", {
1541
+ return;
1542
+ }
1543
+ const standardName = getStandardName(name3, context);
1544
+ const hasStandardNameButIsNotUsed = standardName && standardName !== name3;
1545
+ const usesStandardName = standardName && standardName === name3;
1546
+ if (usesStandardName) {
1547
+ return;
1548
+ }
1549
+ if (hasStandardNameButIsNotUsed) {
1550
+ report(context, messages.unknownPropWithStandardName, "unknownPropWithStandardName", {
1550
1551
  node,
1551
1552
  data: {
1552
- name: actualName
1553
+ name: actualName,
1554
+ standardName
1555
+ },
1556
+ fix(fixer) {
1557
+ return fixer.replaceText(node.name, standardName);
1553
1558
  }
1554
1559
  });
1560
+ return;
1555
1561
  }
1556
- };
1557
- },
1558
- defaultOptions: []
1559
- });
1562
+ report(context, messages.unknownProp, "unknownProp", {
1563
+ node,
1564
+ data: {
1565
+ name: actualName
1566
+ }
1567
+ });
1568
+ }
1569
+ };
1570
+ }
1560
1571
  function has(obj, key) {
1561
1572
  return Object.hasOwn(obj, key);
1562
1573
  }
@@ -1599,51 +1610,52 @@ var no_unsafe_iframe_sandbox_default = createRule({
1599
1610
  schema: []
1600
1611
  },
1601
1612
  name: RULE_NAME11,
1602
- create(context) {
1603
- const settings2 = shared.getSettingsFromContext(context);
1604
- const polymorphicPropName = settings2.polymorphicPropName;
1605
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
1606
- return {
1607
- JSXElement(node) {
1608
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1609
- context,
1610
- node,
1611
- polymorphicPropName,
1612
- additionalComponents
1613
- );
1614
- if (elementNameOnDom !== "iframe") return;
1615
- const elementScope = context.sourceCode.getScope(node);
1616
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1617
- const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
1618
- const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1619
- const attributeNode = JSX__namespace.getAttribute(
1620
- propNameOnJsx,
1621
- node.openingElement.attributes,
1622
- elementScope
1623
- );
1624
- if (attributeNode != null) {
1625
- const attributeScope = context.sourceCode.getScope(attributeNode);
1626
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1627
- if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1628
- context.report({
1629
- messageId: "noUnsafeIframeSandbox",
1630
- node: attributeNode
1631
- });
1632
- return;
1633
- }
1634
- }
1635
- if (customComponentProp?.defaultValue == null) return;
1636
- if (!hasSafeSandbox(customComponentProp.defaultValue)) {
1613
+ create: create11,
1614
+ defaultOptions: []
1615
+ });
1616
+ function create11(context) {
1617
+ const settings2 = shared.getSettingsFromContext(context);
1618
+ const polymorphicPropName = settings2.polymorphicPropName;
1619
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "iframe");
1620
+ return {
1621
+ JSXElement(node) {
1622
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1623
+ context,
1624
+ node,
1625
+ polymorphicPropName,
1626
+ additionalComponents
1627
+ );
1628
+ if (elementNameOnDom !== "iframe") return;
1629
+ const elementScope = context.sourceCode.getScope(node);
1630
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1631
+ const customComponentProp = findCustomComponentProp("sandbox", customComponent?.attributes ?? []);
1632
+ const propNameOnJsx = customComponentProp?.name ?? "sandbox";
1633
+ const attributeNode = JSX__namespace.getAttribute(
1634
+ propNameOnJsx,
1635
+ node.openingElement.attributes,
1636
+ elementScope
1637
+ );
1638
+ if (attributeNode != null) {
1639
+ const attributeScope = context.sourceCode.getScope(attributeNode);
1640
+ const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1641
+ if (attributeValue.kind === "some" && !hasSafeSandbox(attributeValue.value)) {
1637
1642
  context.report({
1638
1643
  messageId: "noUnsafeIframeSandbox",
1639
- node
1644
+ node: attributeNode
1640
1645
  });
1646
+ return;
1641
1647
  }
1642
1648
  }
1643
- };
1644
- },
1645
- defaultOptions: []
1646
- });
1649
+ if (customComponentProp?.defaultValue == null) return;
1650
+ if (!hasSafeSandbox(customComponentProp.defaultValue)) {
1651
+ context.report({
1652
+ messageId: "noUnsafeIframeSandbox",
1653
+ node
1654
+ });
1655
+ }
1656
+ }
1657
+ };
1658
+ }
1647
1659
  var RULE_NAME12 = "no-unsafe-target-blank";
1648
1660
  var RULE_FEATURES11 = [
1649
1661
  "CHK"
@@ -1669,55 +1681,56 @@ var no_unsafe_target_blank_default = createRule({
1669
1681
  schema: []
1670
1682
  },
1671
1683
  name: RULE_NAME12,
1672
- create(context) {
1673
- const settings2 = shared.getSettingsFromContext(context);
1674
- const polymorphicPropName = settings2.polymorphicPropName;
1675
- const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
1676
- return {
1677
- JSXElement(node) {
1678
- const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1679
- context,
1680
- node,
1681
- polymorphicPropName,
1682
- additionalComponents
1684
+ create: create12,
1685
+ defaultOptions: []
1686
+ });
1687
+ function create12(context) {
1688
+ const settings2 = shared.getSettingsFromContext(context);
1689
+ const polymorphicPropName = settings2.polymorphicPropName;
1690
+ const additionalComponents = settings2.additionalComponents.filter((c) => c.as === "a");
1691
+ return {
1692
+ JSXElement(node) {
1693
+ const [elementNameOnJsx, elementNameOnDom] = getElementTypeOnJsxAndDom(
1694
+ context,
1695
+ node,
1696
+ polymorphicPropName,
1697
+ additionalComponents
1698
+ );
1699
+ if (elementNameOnDom !== "a") return;
1700
+ const elementScope = context.sourceCode.getScope(node);
1701
+ const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1702
+ const getAttributeStringValue = (name3) => {
1703
+ const customComponentProp = findCustomComponentProp(name3, customComponent?.attributes ?? []);
1704
+ const propNameOnJsx = customComponentProp?.name ?? name3;
1705
+ const attributeNode = JSX__namespace.getAttribute(
1706
+ propNameOnJsx,
1707
+ node.openingElement.attributes,
1708
+ elementScope
1683
1709
  );
1684
- if (elementNameOnDom !== "a") return;
1685
- const elementScope = context.sourceCode.getScope(node);
1686
- const customComponent = findCustomComponent(elementNameOnJsx, additionalComponents);
1687
- const getAttributeStringValue = (name3) => {
1688
- const customComponentProp = findCustomComponentProp(name3, customComponent?.attributes ?? []);
1689
- const propNameOnJsx = customComponentProp?.name ?? name3;
1690
- const attributeNode = JSX__namespace.getAttribute(
1691
- propNameOnJsx,
1692
- node.openingElement.attributes,
1693
- elementScope
1694
- );
1695
- if (attributeNode == null) return customComponentProp?.defaultValue;
1696
- const attributeScope = context.sourceCode.getScope(attributeNode);
1697
- const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1698
- if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1699
- return attributeValue.value;
1700
- }
1701
- return eff._;
1702
- };
1703
- if (getAttributeStringValue("target") !== "_blank") {
1704
- return;
1705
- }
1706
- if (!isExternalLinkLike(getAttributeStringValue("href"))) {
1707
- return;
1710
+ if (attributeNode == null) return customComponentProp?.defaultValue;
1711
+ const attributeScope = context.sourceCode.getScope(attributeNode);
1712
+ const attributeValue = JSX__namespace.getAttributeValue(attributeNode, propNameOnJsx, attributeScope);
1713
+ if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1714
+ return attributeValue.value;
1708
1715
  }
1709
- if (isSafeRel(getAttributeStringValue("rel"))) {
1710
- return;
1711
- }
1712
- context.report({
1713
- messageId: "noUnsafeTargetBlank",
1714
- node
1715
- });
1716
+ return eff._;
1717
+ };
1718
+ if (getAttributeStringValue("target") !== "_blank") {
1719
+ return;
1716
1720
  }
1717
- };
1718
- },
1719
- defaultOptions: []
1720
- });
1721
+ if (!isExternalLinkLike(getAttributeStringValue("href"))) {
1722
+ return;
1723
+ }
1724
+ if (isSafeRel(getAttributeStringValue("rel"))) {
1725
+ return;
1726
+ }
1727
+ context.report({
1728
+ messageId: "noUnsafeTargetBlank",
1729
+ node
1730
+ });
1731
+ }
1732
+ };
1733
+ }
1721
1734
  var RULE_NAME13 = "no-void-elements-with-children";
1722
1735
  var RULE_FEATURES12 = [
1723
1736
  "CHK"
@@ -1753,39 +1766,40 @@ var no_void_elements_with_children_default = createRule({
1753
1766
  schema: []
1754
1767
  },
1755
1768
  name: RULE_NAME13,
1756
- create(context) {
1757
- return {
1758
- JSXElement(node) {
1759
- const elementName = JSX__namespace.getElementType(node);
1760
- if (elementName.length === 0 || !voidElements.has(elementName)) {
1761
- return;
1762
- }
1763
- if (node.children.length > 0) {
1764
- context.report({
1765
- messageId: "noVoidElementsWithChildren",
1766
- node,
1767
- data: {
1768
- element: elementName
1769
- }
1770
- });
1771
- }
1772
- const { attributes } = node.openingElement;
1773
- const initialScope = context.sourceCode.getScope(node);
1774
- const hasAttribute3 = (name3) => JSX__namespace.hasAttribute(name3, attributes, initialScope);
1775
- if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1776
- context.report({
1777
- messageId: "noVoidElementsWithChildren",
1778
- node,
1779
- data: {
1780
- element: elementName
1781
- }
1782
- });
1783
- }
1784
- }
1785
- };
1786
- },
1769
+ create: create13,
1787
1770
  defaultOptions: []
1788
1771
  });
1772
+ function create13(context) {
1773
+ return {
1774
+ JSXElement(node) {
1775
+ const elementName = JSX__namespace.getElementType(node);
1776
+ if (elementName.length === 0 || !voidElements.has(elementName)) {
1777
+ return;
1778
+ }
1779
+ if (node.children.length > 0) {
1780
+ context.report({
1781
+ messageId: "noVoidElementsWithChildren",
1782
+ node,
1783
+ data: {
1784
+ element: elementName
1785
+ }
1786
+ });
1787
+ }
1788
+ const { attributes } = node.openingElement;
1789
+ const initialScope = context.sourceCode.getScope(node);
1790
+ const hasAttribute3 = (name3) => JSX__namespace.hasAttribute(name3, attributes, initialScope);
1791
+ if (hasAttribute3("children") || hasAttribute3("dangerouslySetInnerHTML")) {
1792
+ context.report({
1793
+ messageId: "noVoidElementsWithChildren",
1794
+ node,
1795
+ data: {
1796
+ element: elementName
1797
+ }
1798
+ });
1799
+ }
1800
+ }
1801
+ };
1802
+ }
1789
1803
 
1790
1804
  // src/plugin.ts
1791
1805
  var plugin = {