Skip to content

Commit

Permalink
fix(rules): don't crash on require() (#115)
Browse files Browse the repository at this point in the history
fixes #114
  • Loading branch information
jacekkopecky authored and SimenB committed May 27, 2018
1 parent 4586bdc commit 523e2f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions rules/__tests__/no-jest-import.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ruleTester.run('no-jest-import', rule, {
parserOptions: { sourceType: 'module' },
},
'require("somethingElse")',
'require()',
'entirelyDifferent(fn)',
],
invalid: [
Expand Down
6 changes: 5 additions & 1 deletion rules/no-jest-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ module.exports = {
},
CallExpression(node) {
const calleeName = getNodeName(node.callee);
if (calleeName === 'require' && node.arguments[0].value === 'jest') {
if (
calleeName === 'require' &&
node.arguments[0] &&
node.arguments[0].value === 'jest'
) {
context.report({
loc: {
end: {
Expand Down

0 comments on commit 523e2f4

Please # to comment.