Skip to content
Permalink
Browse files

Fix: --init with Vue.js failed (fixes #11970) (#11985)

* Fix: --init with Vue.js failed (fixes #11970)

* move 'naming.js' to 'shared' directory

* use naming utility
  • Loading branch information...
mysticatea authored and kaicataldo committed Jul 16, 2019
1 parent 93633c2 commit 6669f78a3dd305aef6191e7eea24fae2ae4fd2e8
@@ -20,6 +20,7 @@ const path = require("path");
const defaultOptions = require("../../conf/default-cli-options");
const pkg = require("../../package.json");
const ConfigOps = require("../shared/config-ops");
const naming = require("../shared/naming");
const ModuleResolver = require("../shared/relative-module-resolver");
const { Linter } = require("../linter");
const builtInRules = require("../rules");
@@ -29,7 +30,6 @@ const { FileEnumerator } = require("./file-enumerator");
const hash = require("./hash");
const { IgnoredPaths } = require("./ignored-paths");
const LintResultCache = require("./lint-result-cache");
const naming = require("./naming");

const debug = require("debug")("eslint:cli-engine");
const validFixTypes = new Set(["problem", "suggestion", "layout"]);
@@ -38,9 +38,9 @@ const path = require("path");
const importFresh = require("import-fresh");
const stripComments = require("strip-json-comments");
const { validateConfigSchema } = require("../shared/config-validator");
const naming = require("../shared/naming");
const ModuleResolver = require("../shared/relative-module-resolver");
const { ConfigArray, ConfigDependency, OverrideTester } = require("./config-array");
const naming = require("./naming");
const debug = require("debug")("eslint:config-array-factory");

//------------------------------------------------------------------------------
@@ -18,6 +18,7 @@ const util = require("util"),
recConfig = require("../../conf/eslint-recommended"),
ConfigOps = require("../shared/config-ops"),
log = require("../shared/logging"),
naming = require("../shared/naming"),
ModuleResolver = require("../shared/relative-module-resolver"),
autoconfig = require("./autoconfig.js"),
ConfigFile = require("./config-file"),
@@ -97,17 +98,26 @@ function getModulesList(config, installESLint) {
// Create a list of modules which should be installed based on config
if (config.plugins) {
for (const plugin of config.plugins) {
modules[`eslint-plugin-${plugin}`] = "latest";
const moduleName = naming.normalizePackageName(plugin, "eslint-plugin");

modules[moduleName] = "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 = naming.normalizePackageName(extend, "eslint-config");

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

if (installESLint === false) {
File renamed without changes.
@@ -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", () => {
@@ -9,7 +9,7 @@

const assert = require("chai").assert,
leche = require("leche"),
naming = require("../../../lib/cli-engine/naming");
naming = require("../../../lib/shared/naming");

//------------------------------------------------------------------------------
// Tests

0 comments on commit 6669f78

Please sign in to comment.
You can’t perform that action at this time.