@@ -29,6 +29,7 @@ const DOM_ATTRIBUTE_NAMES = {
2929
3030const ATTRIBUTE_TAGS_MAP = {
3131 abbr : [ 'th' , 'td' ] ,
32+ charset : [ 'meta' ] ,
3233 checked : [ 'input' ] ,
3334 // image is required for SVG support, all other tags are HTML.
3435 crossOrigin : [ 'script' , 'img' , 'video' , 'audio' , 'link' , 'image' ] ,
@@ -103,6 +104,9 @@ const ATTRIBUTE_TAGS_MAP = {
103104 loop : [ 'audio' , 'video' ] ,
104105 muted : [ 'audio' , 'video' ] ,
105106 playsInline : [ 'video' ] ,
107+ allowFullScreen : [ 'video' ] ,
108+ webkitAllowFullScreen : [ 'video' ] ,
109+ mozAllowFullScreen : [ 'video' ] ,
106110 poster : [ 'video' ] ,
107111 preload : [ 'audio' , 'video' ] ,
108112 scrolling : [ 'iframe' ] ,
@@ -393,6 +397,22 @@ function isValidHTMLTagInJSX(childNode) {
393397 return false ;
394398}
395399
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+
396416/**
397417 * Checks if an attribute name is a valid `data-*` attribute:
398418 * 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) {
418438 return ARIA_PROPERTIES . some ( ( element ) => element === name ) ;
419439}
420440
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-
438441/**
439442 * Extracts the tag name for the JSXAttribute
440443 * @param {JSXAttribute } node - JSXAttribute being tested.
@@ -523,10 +526,11 @@ module.exports = {
523526 return {
524527 JSXAttribute ( node ) {
525528 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 ) {
528531 return ;
529532 }
533+ const name = normalizeAttributeCase ( actualName ) ;
530534
531535 // Ignore tags like <Foo.bar />
532536 if ( tagNameHasDot ( node ) ) {
@@ -537,8 +541,6 @@ module.exports = {
537541
538542 if ( isValidAriaAttribute ( name ) ) { return ; }
539543
540- if ( isCaseIgnoredAttribute ( name ) ) { return ; }
541-
542544 const tagName = getTagName ( node ) ;
543545
544546 if ( tagName === 'fbt' ) { return ; } // fbt nodes are bonkers, let's not go there
@@ -555,7 +557,7 @@ module.exports = {
555557 report ( context , messages . invalidPropOnTag , 'invalidPropOnTag' , {
556558 node,
557559 data : {
558- name,
560+ name : actualName ,
559561 tagName,
560562 allowedTags : allowedTags . join ( ', ' ) ,
561563 } ,
@@ -581,7 +583,7 @@ module.exports = {
581583 report ( context , messages . unknownPropWithStandardName , 'unknownPropWithStandardName' , {
582584 node,
583585 data : {
584- name,
586+ name : actualName ,
585587 standardName,
586588 } ,
587589 fix ( fixer ) {
@@ -595,7 +597,7 @@ module.exports = {
595597 report ( context , messages . unknownProp , 'unknownProp' , {
596598 node,
597599 data : {
598- name,
600+ name : actualName ,
599601 } ,
600602 } ) ;
601603 } ,
0 commit comments