Squashed from: - deps: Add node-inspect 1.10.1 This adds a reimplementation of the old CLI debugger (`node debug`) against the new debugger protocol (`node --inspect`). This is necessary because the old protocol won't be supported in future versions of V8. - deps: Update node-inspect to 1.10.2 Starting with 1.10.2 the test suite should pass consistently on windows. - deps: Update to node-inspect 1.10.4 PR-URL: https://github.com/nodejs/node/pull/10187 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
/**
|
|
* @fileoverview Prohibit the use of `let` as the loop variable
|
|
* in the initialization of for, and the left-hand
|
|
* iterator in forIn and forOf loops.
|
|
*
|
|
* @author Jessica Quynh Tran
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
create(context) {
|
|
|
|
const msg = 'Use of `let` as the loop variable in a for-loop is ' +
|
|
'not recommended. Please use `var` instead.';
|
|
|
|
/**
|
|
* Report function to test if the for-loop is declared using `let`.
|
|
*/
|
|
function testForLoop(node) {
|
|
if (node.init && node.init.kind === 'let') {
|
|
context.report(node.init, msg);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Report function to test if the for-in or for-of loop
|
|
* is declared using `let`.
|
|
*/
|
|
function testForInOfLoop(node) {
|
|
if (node.left && node.left.kind === 'let') {
|
|
context.report(node.left, msg);
|
|
}
|
|
}
|
|
|
|
return {
|
|
'ForStatement': testForLoop,
|
|
'ForInStatement': testForInOfLoop,
|
|
'ForOfStatement': testForInOfLoop
|
|
};
|
|
}
|
|
};
|