Skip to content

Commit

Permalink
Fix: --init with Vue.js failed (fixes #11970)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jul 14, 2019
1 parent 2a10856 commit 926f74e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/init/config-initializer.js
Expand Up @@ -100,14 +100,21 @@ function getModulesList(config, installESLint) {
modules[`eslint-plugin-${plugin}`] = "latest";
}
}
if (config.extends && config.extends.indexOf("eslint:") === -1) {
const moduleName = `eslint-config-${config.extends}`;

modules[moduleName] = "latest";
Object.assign(
modules,
getPeerDependencies(`${moduleName}@latest`)
);
if (config.extends) {
const extendList = Array.isArray(config.extends) ? config.extends : [config.extends];

for (const extend of extendList) {
if (extend.startsWith("eslint:") || extend.startsWith("plugin:")) {
continue;
}
const moduleName = `eslint-config-${extend}`;

modules[moduleName] = "latest";
Object.assign(
modules,
getPeerDependencies(`${moduleName}@latest`)
);
}
}

if (installESLint === false) {
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/init/config-initializer.js
Expand Up @@ -306,6 +306,17 @@ describe("configInitializer", () => {
});
});
});

it("should support the standard style guide with Vue.js", () => {
const config = {
plugins: ["vue"],
extends: ["plugin:vue/essential", "standard"]
};
const modules = init.getModulesList(config);

assert.include(modules, "eslint-plugin-vue@latest");
assert.include(modules, "eslint-config-standard@latest");
});
});

describe("auto", () => {
Expand Down

0 comments on commit 926f74e

Please sign in to comment.