diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index 6d63feb17e..54f7dbe96b 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -386,7 +386,12 @@ module.exports = { } else if (annotation.type === 'TSTypeReference') { propType = objectTypeAnnotations.get(annotation.typeName.name); } else if (annotation.type === 'TSIntersectionType') { - propType = flatMap(annotation.types, (type) => objectTypeAnnotations.get(type.typeName.name)); + propType = flatMap(annotation.types, (type) => { + if (type.type === 'TSTypeReference') { + return objectTypeAnnotations.get(type.typeName.name); + } + return type; + }); } if (propType) { diff --git a/tests/lib/rules/boolean-prop-naming.js b/tests/lib/rules/boolean-prop-naming.js index 393c04a508..1d1794a6f1 100644 --- a/tests/lib/rules/boolean-prop-naming.js +++ b/tests/lib/rules/boolean-prop-naming.js @@ -1338,5 +1338,34 @@ ruleTester.run('boolean-prop-naming', rule, { }, ], }, + { + code: ` + type Props = { + enabled: boolean + } + + const Hello = (props: Props & { + semi: boolean + }) =>
; + `, + options: [{ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+' }], + features: ['ts', 'no-babel', 'no-ts-old'], + errors: [ + { + messageId: 'patternMismatch', + data: { + propName: 'enabled', + pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+', + }, + }, + { + messageId: 'patternMismatch', + data: { + propName: 'semi', + pattern: '^(is|has)[A-Z]([A-Za-z0-9]?)+', + }, + }, + ], + }, ]), });