diff options
author | Rich Trott <rtrott@gmail.com> | 2016-02-15 14:45:53 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-02-18 10:13:13 -0800 |
commit | d7aa8fa088f3b8a31c7d85c6d71824c8c60e7c17 (patch) | |
tree | 739f4a86de562584f10eba7f1a06a406d8d66366 /tools/eslint/lib/code-path-analysis/id-generator.js | |
parent | d3c3a928c3a2f9e961881b47ef0796e57ae8d429 (diff) | |
download | node-new-d7aa8fa088f3b8a31c7d85c6d71824c8c60e7c17.tar.gz |
tools: update ESLint to version 2.1.0
Update ESLint to 2.1.0. ESLint has a number of potentially-useful new
features but this change attempts to be minimal in its changes.
However, some things could not be avoided reasonably.
ESLint 2.1.0 found a few lint issues that ESLing 1.x missed with
template strings that did not take advantage of any features of
template strings, and `let` declarations where `const` sufficed.
Additionally, ESLint 2.1.0 removes some granularity around enabling ES6
features. Some features (e.g., spread operator) that had been turned off
in our configuration for ESLint 1.x are now permitted.
PR-URL: https://github.com/nodejs/node/pull/5214
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'tools/eslint/lib/code-path-analysis/id-generator.js')
-rw-r--r-- | tools/eslint/lib/code-path-analysis/id-generator.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/eslint/lib/code-path-analysis/id-generator.js b/tools/eslint/lib/code-path-analysis/id-generator.js new file mode 100644 index 0000000000..c37e7d7e5b --- /dev/null +++ b/tools/eslint/lib/code-path-analysis/id-generator.js @@ -0,0 +1,43 @@ +/** + * @fileoverview A class of identifiers generator for code path segments. + * + * Each rule uses the identifier of code path segments to store additional + * information of the code path. + * + * @author Toru Nagashima + * @copyright 2015 Toru Nagashima. All rights reserved. + * See LICENSE file in root directory for full license. + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Public Interface +//------------------------------------------------------------------------------ + +/** + * A generator for unique ids. + * + * @constructor + * @param {string} prefix - Optional. A prefix of generated ids. + */ +function IdGenerator(prefix) { + this.prefix = String(prefix); + this.n = 0; +} + +/** + * Generates id. + * + * @returns {string} A generated id. + */ +IdGenerator.prototype.next = function() { + this.n = 1 + this.n | 0; + /* istanbul ignore if */ + if (this.n < 0) { + this.n = 1; + } + return this.prefix + this.n; +}; + +module.exports = IdGenerator; |