diff --git a/src/core/staticRequire.js b/src/core/staticRequire.js index c13c4b066..45ed79d79 100644 --- a/src/core/staticRequire.js +++ b/src/core/staticRequire.js @@ -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' } diff --git a/tests/src/rules/no-extraneous-dependencies.js b/tests/src/rules/no-extraneous-dependencies.js index 4d739ee71..1a743b545 100644 --- a/tests/src/rules/no-extraneous-dependencies.js +++ b/tests/src/rules/no-extraneous-dependencies.js @@ -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({