@@ -502,60 +502,63 @@ module.exports = {
502502
503503 const tagName = getTagName ( node ) ;
504504
505- // Let's dive deeper into tags that are HTML/DOM elements (`<button>`), and not React components (`<Button />`)
506- if ( isValidHTMLTagInJSX ( node ) ) {
507- // Some attributes are allowed on some tags only
508- const allowedTags = has ( ATTRIBUTE_TAGS_MAP , name ) ? ATTRIBUTE_TAGS_MAP [ name ] : null ;
509- if ( tagName && allowedTags ) {
510- // Scenario 1A: Allowed attribute found where not supposed to, report it
511- if ( allowedTags . indexOf ( tagName ) === - 1 ) {
512- report ( context , messages . invalidPropOnTag , 'invalidPropOnTag' , {
513- node,
514- data : {
515- name,
516- tagName,
517- allowedTags : allowedTags . join ( ', ' ) ,
518- } ,
519- } ) ;
520- }
521- // Scenario 1B: There are allowed attributes on allowed tags, no need to report it
522- return ;
523- }
524-
525- // Let's see if the attribute is a close version to some standard property name
526- const standardName = getStandardName ( name , context ) ;
505+ if ( tagName === 'fbt' ) { return ; } // fbt nodes are bonkers, let's not go there
527506
528- const hasStandardNameButIsNotUsed = standardName && standardName !== name ;
529- const usesStandardName = standardName && standardName === name ;
507+ if ( ! isValidHTMLTagInJSX ( node ) ) { return ; }
530508
531- if ( usesStandardName ) {
532- // Scenario 2A: The attribute name is the standard name, no need to report it
533- return ;
534- }
509+ // Let's dive deeper into tags that are HTML/DOM elements (`<button>`), and not React components (`<Button />`)
535510
536- if ( hasStandardNameButIsNotUsed ) {
537- // Scenario 2B: The name of the attribute is close to a standard one, report it with the standard name
538- report ( context , messages . unknownPropWithStandardName , 'unknownPropWithStandardName' , {
511+ // Some attributes are allowed on some tags only
512+ const allowedTags = has ( ATTRIBUTE_TAGS_MAP , name ) ? ATTRIBUTE_TAGS_MAP [ name ] : null ;
513+ if ( tagName && allowedTags ) {
514+ // Scenario 1A: Allowed attribute found where not supposed to, report it
515+ if ( allowedTags . indexOf ( tagName ) === - 1 ) {
516+ report ( context , messages . invalidPropOnTag , 'invalidPropOnTag' , {
539517 node,
540518 data : {
541519 name,
542- standardName,
543- } ,
544- fix ( fixer ) {
545- return fixer . replaceText ( node . name , standardName ) ;
520+ tagName,
521+ allowedTags : allowedTags . join ( ', ' ) ,
546522 } ,
547523 } ) ;
548- return ;
549524 }
525+ // Scenario 1B: There are allowed attributes on allowed tags, no need to report it
526+ return ;
527+ }
528+
529+ // Let's see if the attribute is a close version to some standard property name
530+ const standardName = getStandardName ( name , context ) ;
550531
551- // Scenario 3: We have an attribute that is unknown, report it
552- report ( context , messages . unknownProp , 'unknownProp' , {
532+ const hasStandardNameButIsNotUsed = standardName && standardName !== name ;
533+ const usesStandardName = standardName && standardName === name ;
534+
535+ if ( usesStandardName ) {
536+ // Scenario 2A: The attribute name is the standard name, no need to report it
537+ return ;
538+ }
539+
540+ if ( hasStandardNameButIsNotUsed ) {
541+ // Scenario 2B: The name of the attribute is close to a standard one, report it with the standard name
542+ report ( context , messages . unknownPropWithStandardName , 'unknownPropWithStandardName' , {
553543 node,
554544 data : {
555545 name,
546+ standardName,
547+ } ,
548+ fix ( fixer ) {
549+ return fixer . replaceText ( node . name , standardName ) ;
556550 } ,
557551 } ) ;
552+ return ;
558553 }
554+
555+ // Scenario 3: We have an attribute that is unknown, report it
556+ report ( context , messages . unknownProp , 'unknownProp' , {
557+ node,
558+ data : {
559+ name,
560+ } ,
561+ } ) ;
559562 } ,
560563 } ;
561564 } ,
0 commit comments