diff --git a/lib/config/config-initializer.js b/lib/config/config-initializer.js index 75cf6adbaf3..4a9ae068586 100644 --- a/lib/config/config-initializer.js +++ b/lib/config/config-initializer.js @@ -262,6 +262,7 @@ function getConfigForStyleGuide(guide) { const guides = { google: {extends: "google"}, airbnb: {extends: "airbnb", plugins: ["react", "jsx-a11y", "import"]}, + "airbnb-base": {extends: "airbnb-base", plugins: ["import"]}, standard: {extends: "standard", plugins: ["standard", "promise"]} }; @@ -305,6 +306,15 @@ function promptUser(callback) { return answers.source === "guide" && answers.packageJsonExists; } }, + { + type: "confirm", + name: "airbnbReact", + message: "Do you use React?", + default: false, + when(answers) { + return answers.styleguide === "airbnb"; + }, + }, { type: "input", name: "patterns", @@ -337,7 +347,9 @@ function promptUser(callback) { 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; } - + if (earlyAnswers.styleguide === "airbnb" && !earlyAnswers.airbnbReact) { + earlyAnswers.styleguide = "airbnb-base"; + } try { config = getConfigForStyleGuide(earlyAnswers.styleguide); writeFile(config, earlyAnswers.format); @@ -390,7 +402,7 @@ function promptUser(callback) { { type: "confirm", name: "react", - message: "Do you use React", + message: "Do you use React?", default: false, when(answers) { return answers.jsx; diff --git a/tests/lib/config/config-initializer.js b/tests/lib/config/config-initializer.js index 77c8188afdf..28ce3dfca51 100644 --- a/tests/lib/config/config-initializer.js +++ b/tests/lib/config/config-initializer.js @@ -188,6 +188,12 @@ describe("configInitializer", () => { assert.deepEqual(config, {extends: "airbnb", installedESLint: true, plugins: ["react", "jsx-a11y", "import"]}); }); + it("should support the airbnb base style guide", () => { + const config = init.getConfigForStyleGuide("airbnb-base"); + + assert.deepEqual(config, {extends: "airbnb-base", installedESLint: true, plugins: ["import"]}); + }); + it("should support the standard style guide", () => { const config = init.getConfigForStyleGuide("standard");