diff --git a/src/rules/noPrimitiveConstructorTypes.js b/src/rules/noPrimitiveConstructorTypes.js index 086828d6..6c1c9efb 100644 --- a/src/rules/noPrimitiveConstructorTypes.js +++ b/src/rules/noPrimitiveConstructorTypes.js @@ -6,7 +6,7 @@ export default { GenericTypeAnnotation: (node) => { const name = _.get(node, 'id.name'); - if (RegExp(/(Boolean|Number|String)/).test(name)) { + if (RegExp(/^(Boolean|Number|String)$/).test(name)) { context.report({ data: { name diff --git a/tests/rules/assertions/noPrimitiveConstructorTypes.js b/tests/rules/assertions/noPrimitiveConstructorTypes.js index 2d9ae0b3..4af2e30d 100644 --- a/tests/rules/assertions/noPrimitiveConstructorTypes.js +++ b/tests/rules/assertions/noPrimitiveConstructorTypes.js @@ -64,6 +64,15 @@ export default { }, { code: '(x: boolean) => {}' + }, + { + code: 'type x = MyNumber' + }, + { + code: 'type x = MyString' + }, + { + code: 'type x = MyBoolean' } ] };