Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update: Add airbnb-base to init styleguides (fixes #6986) (#7699)
  • Loading branch information
alberto authored and vitorbal committed Dec 8, 2016
1 parent 63bb3f8 commit 7079c89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/config/config-initializer.js
Expand Up @@ -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"]}
};

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/config/config-initializer.js
Expand Up @@ -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");

Expand Down

0 comments on commit 7079c89

Please sign in to comment.