Skip to content

Commit

Permalink
(#610): Fix crash when calling require() with a number
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Oct 6, 2016
1 parent 4f3aa28 commit e282c42
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/staticRequire.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default function isStaticRequire(node) {
node.callee.type === 'Identifier' &&
node.callee.name === 'require' &&
node.arguments.length === 1 &&
node.arguments[0].type === 'Literal'
node.arguments[0].type === 'Literal' &&
typeof node.arguments[0].value === 'string'
}
1 change: 1 addition & 0 deletions tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
filename: 'foo.spec.js',
}),
test({ code: 'require(6)' }),
],
invalid: [
test({
Expand Down

0 comments on commit e282c42

Please sign in to comment.