Permalink
Browse files

Fix: `no-return-assign` to check for null tokens (fixes #6159) (#6162)

  • Loading branch information...
gyandeeps authored and ilyavolodin committed May 14, 2016
1 parent 8b78697 commit f33e49ffbc7414b747b3345489ca90c004762821
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/rules/no-return-assign.js
  2. +6 −0 tests/lib/rules/no-return-assign.js
@@ -20,7 +20,7 @@ function isEnclosedInParens(node, sourceCode) {
var prevToken = sourceCode.getTokenBefore(node);
var nextToken = sourceCode.getTokenAfter(node);
return prevToken.value === "(" && nextToken.value === ")";
return prevToken && prevToken.value === "(" && nextToken && nextToken.value === ")";
}
//------------------------------------------------------------------------------
@@ -25,6 +25,12 @@ var ruleTester = new RuleTester();
ruleTester.run("no-return-assign", rule, {
valid: [
{
code: "module.exports = {'a': 1};",
parserOptions: {
sourceType: "module"
}
},
"var result = a * b;",
"function x() { var result = a * b; return result; }",
"function x() { return (result = a * b); }",

0 comments on commit f33e49f

Please sign in to comment.