Skip to content

Commit

Permalink
[[FIX]] Warn about using var inside for (...) when varstmt: true
Browse files Browse the repository at this point in the history
Fixes #2627
  • Loading branch information
nicolo-ribaudo authored and jugglinmike committed Aug 27, 2015
1 parent b5ba7d6 commit f1ab638
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jshint.js
Expand Up @@ -3610,7 +3610,7 @@ var JSHINT = (function() {
lone = true;
}

if (!prefix && report && state.option.varstmt) {
if (!(prefix && implied) && report && state.option.varstmt) {
warning("W132", this);
}

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/options.js
Expand Up @@ -2979,7 +2979,8 @@ exports.varstmt = function (test) {
"var fn = function() {",
" var x;",
" var y = 5;",
"};"
"};",
"for (var a in x);"
];

TestRun(test)
Expand All @@ -2988,6 +2989,7 @@ exports.varstmt = function (test) {
.addError(3, "`var` declarations are forbidden. Use `let` or `const` instead.")
.addError(4, "`var` declarations are forbidden. Use `let` or `const` instead.")
.addError(5, "`var` declarations are forbidden. Use `let` or `const` instead.")
.addError(7, "`var` declarations are forbidden. Use `let` or `const` instead.")
.test(code, { varstmt: true });

test.done();
Expand Down

0 comments on commit f1ab638

Please sign in to comment.