Skip to content

Commit

Permalink
fix: boolean-prop-naming literalType error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
developer-bandi committed Mar 7, 2024
1 parent 901c794 commit 3bb03ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ module.exports = {
let propType;
if (annotation.type === 'GenericTypeAnnotation') {
propType = objectTypeAnnotations.get(annotation.id.name);
} else if (annotation.type === 'ObjectTypeAnnotation') {
} else if (annotation.type === 'ObjectTypeAnnotation' || annotation.type === 'TSTypeLiteral') {
propType = annotation;
} else if (annotation.type === 'TSTypeReference') {
propType = objectTypeAnnotations.get(annotation.typeName.name);
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -1254,5 +1254,15 @@ ruleTester.run('boolean-prop-naming', rule, {
},
],
},
{
code: 'const Hello = (props: {enabled:boolean}) => <div />;',
options: [{ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+' }],
features: ['ts', 'no-babel'],
errors: [
{
message: 'Prop name (enabled) doesn\'t match rule (^(is|has)[A-Z]([A-Za-z0-9]?)+)',
},
],
},
]),
});

0 comments on commit 3bb03ca

Please sign in to comment.