From ceea11c48f65f9d16032e4a673ae010736a56aec Mon Sep 17 00:00:00 2001 From: Dan Harper Date: Sun, 27 Nov 2016 11:21:17 +0000 Subject: [PATCH] fix: primitive constructor types regex --- src/rules/noPrimitiveConstructorTypes.js | 2 +- tests/rules/assertions/noPrimitiveConstructorTypes.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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' } ] };