This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix: `requireVarDeclFirst` - ignore let/const

Fixes #1783
  • Loading branch information...
hzoo committed Oct 17, 2015
1 parent ae65ec3 commit 2199ca488a56ff1472d876ac2b21fe2292ae8413
Showing with 16 additions and 1 deletion.
  1. +5 −0 lib/rules/require-var-decl-first.js
  2. +11 −1 test/specs/rules/require-var-decl-first.js
@@ -234,6 +234,11 @@ module.exports.prototype = {
});
file.iterateNodesByType(['VariableDeclaration'], function(varDecl) {
// Ignore let and const for now #1783
if (varDecl.kind !== 'var') {
return;
}
var enclosingScope;
var scopeContents;
var previousNode;
@@ -36,6 +36,16 @@ describe('rules/require-var-decl-first', function() {
}
};
describe('VariableDeclaration kinds #1783', function() {
it('should not return errors for let', function() {
checker.checkString('let a;').isEmpty();
});
it('should not return errors for const', function() {
checker.checkString('const a;').isEmpty();
});
});
describe('statements without spaces or linebreaks', function() {
it('should not return errors for single var declaration at top of program scope', function() {
testDeclStatements(checker, 'var a;', 0);
@@ -135,7 +145,7 @@ describe('rules/require-var-decl-first', function() {
});
it('should return 2 errors for 2 var declarations not at the top of program scope', function() {
testDeclStatements(checker, 'var a;a=1;var b;const c=1;', 2);
testDeclStatements(checker, 'var a;a=1;var b;var c=1;', 2);
});
});

0 comments on commit 2199ca4

Please sign in to comment.