diff options
author | Rich Trott <rtrott@gmail.com> | 2016-07-07 15:44:32 -0700 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2016-07-15 08:09:42 -0500 |
commit | df697c486e7af5b50efca4a21105bb137cbeddbd (patch) | |
tree | f5ecf30000db4281c3538df7b9372ede231d9f8a /tools/eslint/lib/config/config-initializer.js | |
parent | a81ff702cc57f9d7912cdbbcee826af9cda35915 (diff) | |
download | node-new-df697c486e7af5b50efca4a21105bb137cbeddbd.tar.gz |
tools: update ESLint, fix unused vars bug
Update ESLint to 3.0.0. This includes an enhancement to `no-unused-vars`
such that it finds a few instances in our code base that it did not find
previously (fixed in previous commits readying this for landing).
PR-URL: https://github.com/nodejs/node/pull/7601
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'tools/eslint/lib/config/config-initializer.js')
-rw-r--r-- | tools/eslint/lib/config/config-initializer.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/eslint/lib/config/config-initializer.js b/tools/eslint/lib/config/config-initializer.js index 3d0e78fefe..91d2454a8a 100644 --- a/tools/eslint/lib/config/config-initializer.js +++ b/tools/eslint/lib/config/config-initializer.js @@ -46,7 +46,6 @@ function writeFile(config, format) { extname = ".json"; } - ConfigFile.write(config, "./.eslintrc" + extname); log.info("Successfully created .eslintrc" + extname + " file in " + process.cwd()); @@ -318,7 +317,8 @@ function promptUser(callback) { message: "Which style guide do you want to follow?", choices: [{name: "Google", value: "google"}, {name: "AirBnB", value: "airbnb"}, {name: "Standard", value: "standard"}], when: function(answers) { - return answers.source === "guide"; + answers.packageJsonExists = npmUtil.checkPackageJson(); + return answers.source === "guide" && answers.packageJsonExists; } }, { @@ -342,13 +342,18 @@ function promptUser(callback) { default: "JavaScript", choices: ["JavaScript", "YAML", "JSON"], when: function(answers) { - return (answers.source === "guide" || answers.source === "auto"); + return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto"); } } ], function(earlyAnswers) { // early exit if you are using a style guide if (earlyAnswers.source === "guide") { + if (!earlyAnswers.packageJsonExists) { + log.info("A package.json is necessary to install plugins such as style guides. Run `npm init` to create a package.json file and try again."); + return; + } + try { config = getConfigForStyleGuide(earlyAnswers.styleguide); writeFile(config, earlyAnswers.format); |