Skip to content

Commit 3bb03ca

Browse files
fix: boolean-prop-naming literalType error fix
1 parent 901c794 commit 3bb03ca

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/rules/boolean-prop-naming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ module.exports = {
380380
let propType;
381381
if (annotation.type === 'GenericTypeAnnotation') {
382382
propType = objectTypeAnnotations.get(annotation.id.name);
383-
} else if (annotation.type === 'ObjectTypeAnnotation') {
383+
} else if (annotation.type === 'ObjectTypeAnnotation' || annotation.type === 'TSTypeLiteral') {
384384
propType = annotation;
385385
} else if (annotation.type === 'TSTypeReference') {
386386
propType = objectTypeAnnotations.get(annotation.typeName.name);

tests/lib/rules/boolean-prop-naming.js

+10
Original file line numberDiff line numberDiff line change
@@ -1254,5 +1254,15 @@ ruleTester.run('boolean-prop-naming', rule, {
12541254
},
12551255
],
12561256
},
1257+
{
1258+
code: 'const Hello = (props: {enabled:boolean}) => <div />;',
1259+
options: [{ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+' }],
1260+
features: ['ts', 'no-babel'],
1261+
errors: [
1262+
{
1263+
message: 'Prop name (enabled) doesn\'t match rule (^(is|has)[A-Z]([A-Za-z0-9]?)+)',
1264+
},
1265+
],
1266+
},
12571267
]),
12581268
});

0 commit comments

Comments
 (0)