Skip to content

Commit

Permalink
Fix: no-deprecated-api crash on undeclared assignment (fixes #55) (#56
Browse files Browse the repository at this point in the history
)
  • Loading branch information
not-an-aardvark authored and mysticatea committed Nov 1, 2016
1 parent 382886e commit 610b905
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/rules/no-deprecated-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,10 @@ module.exports = function(context) {
break

case "Identifier":
checkVariable(
findVariable(node, globalScope),
path,
infoMap
)
var variable = findVariable(node, globalScope)
if (variable != null) {
checkVariable(variable, path, infoMap)
}
break

case "ObjectPattern":
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/no-deprecated-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ ruleTester.run("no-deprecated-api", rule, {
code: "import domain from 'domain';",
parserOptions: {sourceType: "module"},
},

// https://github.com/mysticatea/eslint-plugin-node/issues/55
{
code: "undefinedVar = require('fs')",
env: {node: true},
},
],
invalid: [
//----------------------------------------------------------------------
Expand Down

0 comments on commit 610b905

Please sign in to comment.