Skip to content

Commit

Permalink
fix: primitive constructor types regex
Browse files Browse the repository at this point in the history
  • Loading branch information
danharper committed Nov 27, 2016
1 parent 0d2e10f commit ceea11c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/noPrimitiveConstructorTypes.js
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/rules/assertions/noPrimitiveConstructorTypes.js
Expand Up @@ -64,6 +64,15 @@ export default {
},
{
code: '(x: boolean) => {}'
},
{
code: 'type x = MyNumber'
},
{
code: 'type x = MyString'
},
{
code: 'type x = MyBoolean'
}
]
};

0 comments on commit ceea11c

Please sign in to comment.