@@ -29,6 +29,7 @@ const DOM_ATTRIBUTE_NAMES = {
29
29
30
30
const ATTRIBUTE_TAGS_MAP = {
31
31
abbr : [ 'th' , 'td' ] ,
32
+ charset : [ 'meta' ] ,
32
33
checked : [ 'input' ] ,
33
34
// image is required for SVG support, all other tags are HTML.
34
35
crossOrigin : [ 'script' , 'img' , 'video' , 'audio' , 'link' , 'image' ] ,
@@ -103,6 +104,9 @@ const ATTRIBUTE_TAGS_MAP = {
103
104
loop : [ 'audio' , 'video' ] ,
104
105
muted : [ 'audio' , 'video' ] ,
105
106
playsInline : [ 'video' ] ,
107
+ allowFullScreen : [ 'video' ] ,
108
+ webkitAllowFullScreen : [ 'video' ] ,
109
+ mozAllowFullScreen : [ 'video' ] ,
106
110
poster : [ 'video' ] ,
107
111
preload : [ 'audio' , 'video' ] ,
108
112
scrolling : [ 'iframe' ] ,
@@ -393,6 +397,22 @@ function isValidHTMLTagInJSX(childNode) {
393
397
return false ;
394
398
}
395
399
400
+ /**
401
+ * Checks if the attribute name is included in the attributes that are excluded
402
+ * from the camel casing.
403
+ *
404
+ * // returns 'charSet'
405
+ * @example normalizeAttributeCase('charset')
406
+ *
407
+ * Note - these exclusions are not made by React core team, but `eslint-plugin-react` community.
408
+ *
409
+ * @param {String } name - Attribute name to be normalized
410
+ * @returns {String } Result
411
+ */
412
+ function normalizeAttributeCase ( name ) {
413
+ return DOM_PROPERTIES_IGNORE_CASE . find ( ( element ) => element . toLowerCase ( ) === name . toLowerCase ( ) ) || name ;
414
+ }
415
+
396
416
/**
397
417
* Checks if an attribute name is a valid `data-*` attribute:
398
418
* if the name starts with "data-" and has alphanumeric words (browsers require lowercase, but React and TS lowercase them),
@@ -418,23 +438,6 @@ function isValidAriaAttribute(name) {
418
438
return ARIA_PROPERTIES . some ( ( element ) => element === name ) ;
419
439
}
420
440
421
- /**
422
- * Checks if the attribute name is included in the attributes that are excluded
423
- * from the camel casing.
424
- *
425
- * // returns true
426
- * @example isCaseIgnoredAttribute('charSet')
427
- *
428
- * Note - these exclusions are not made by React core team, but `eslint-plugin-react` community.
429
- *
430
- * @param {String } name - Attribute name to be tested
431
- * @returns {Boolean } Result
432
- */
433
-
434
- function isCaseIgnoredAttribute ( name ) {
435
- return DOM_PROPERTIES_IGNORE_CASE . some ( ( element ) => element . toLowerCase ( ) === name . toLowerCase ( ) ) ;
436
- }
437
-
438
441
/**
439
442
* Extracts the tag name for the JSXAttribute
440
443
* @param {JSXAttribute } node - JSXAttribute being tested.
@@ -523,10 +526,11 @@ module.exports = {
523
526
return {
524
527
JSXAttribute ( node ) {
525
528
const ignoreNames = getIgnoreConfig ( ) ;
526
- const name = context . getSourceCode ( ) . getText ( node . name ) ;
527
- if ( ignoreNames . indexOf ( name ) >= 0 ) {
529
+ const actualName = context . getSourceCode ( ) . getText ( node . name ) ;
530
+ if ( ignoreNames . indexOf ( actualName ) >= 0 ) {
528
531
return ;
529
532
}
533
+ const name = normalizeAttributeCase ( actualName ) ;
530
534
531
535
// Ignore tags like <Foo.bar />
532
536
if ( tagNameHasDot ( node ) ) {
@@ -537,8 +541,6 @@ module.exports = {
537
541
538
542
if ( isValidAriaAttribute ( name ) ) { return ; }
539
543
540
- if ( isCaseIgnoredAttribute ( name ) ) { return ; }
541
-
542
544
const tagName = getTagName ( node ) ;
543
545
544
546
if ( tagName === 'fbt' ) { return ; } // fbt nodes are bonkers, let's not go there
@@ -555,7 +557,7 @@ module.exports = {
555
557
report ( context , messages . invalidPropOnTag , 'invalidPropOnTag' , {
556
558
node,
557
559
data : {
558
- name,
560
+ name : actualName ,
559
561
tagName,
560
562
allowedTags : allowedTags . join ( ', ' ) ,
561
563
} ,
@@ -581,7 +583,7 @@ module.exports = {
581
583
report ( context , messages . unknownPropWithStandardName , 'unknownPropWithStandardName' , {
582
584
node,
583
585
data : {
584
- name,
586
+ name : actualName ,
585
587
standardName,
586
588
} ,
587
589
fix ( fixer ) {
@@ -595,7 +597,7 @@ module.exports = {
595
597
report ( context , messages . unknownProp , 'unknownProp' , {
596
598
node,
597
599
data : {
598
- name,
600
+ name : actualName ,
599
601
} ,
600
602
} ) ;
601
603
} ,
0 commit comments