config-initializer.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /**
  2. * @fileoverview Config initialization wizard.
  3. * @author Ilya Volodin
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const util = require("util"),
  10. path = require("path"),
  11. enquirer = require("enquirer"),
  12. ProgressBar = require("progress"),
  13. semver = require("semver"),
  14. espree = require("espree"),
  15. recConfig = require("../../conf/eslint-recommended"),
  16. ConfigOps = require("@eslint/eslintrc/lib/shared/config-ops"),
  17. log = require("../shared/logging"),
  18. naming = require("@eslint/eslintrc/lib/shared/naming"),
  19. ModuleResolver = require("../shared/relative-module-resolver"),
  20. autoconfig = require("./autoconfig.js"),
  21. ConfigFile = require("./config-file"),
  22. npmUtils = require("./npm-utils"),
  23. { getSourceCodeOfFiles } = require("./source-code-utils");
  24. const debug = require("debug")("eslint:config-initializer");
  25. //------------------------------------------------------------------------------
  26. // Private
  27. //------------------------------------------------------------------------------
  28. /* istanbul ignore next: hard to test fs function */
  29. /**
  30. * Create .eslintrc file in the current working directory
  31. * @param {Object} config object that contains user's answers
  32. * @param {string} format The file format to write to.
  33. * @returns {void}
  34. */
  35. function writeFile(config, format) {
  36. // default is .js
  37. let extname = ".js";
  38. if (format === "YAML") {
  39. extname = ".yml";
  40. } else if (format === "JSON") {
  41. extname = ".json";
  42. }
  43. const installedESLint = config.installedESLint;
  44. delete config.installedESLint;
  45. ConfigFile.write(config, `./.eslintrc${extname}`);
  46. log.info(`Successfully created .eslintrc${extname} file in ${process.cwd()}`);
  47. if (installedESLint) {
  48. log.info("ESLint was installed locally. We recommend using this local copy instead of your globally-installed copy.");
  49. }
  50. }
  51. /**
  52. * Get the peer dependencies of the given module.
  53. * This adds the gotten value to cache at the first time, then reuses it.
  54. * In a process, this function is called twice, but `npmUtils.fetchPeerDependencies` needs to access network which is relatively slow.
  55. * @param {string} moduleName The module name to get.
  56. * @returns {Object} The peer dependencies of the given module.
  57. * This object is the object of `peerDependencies` field of `package.json`.
  58. * Returns null if npm was not found.
  59. */
  60. function getPeerDependencies(moduleName) {
  61. let result = getPeerDependencies.cache.get(moduleName);
  62. if (!result) {
  63. log.info(`Checking peerDependencies of ${moduleName}`);
  64. result = npmUtils.fetchPeerDependencies(moduleName);
  65. getPeerDependencies.cache.set(moduleName, result);
  66. }
  67. return result;
  68. }
  69. getPeerDependencies.cache = new Map();
  70. /**
  71. * Return necessary plugins, configs, parsers, etc. based on the config
  72. * @param {Object} config config object
  73. * @param {boolean} [installESLint=true] If `false` is given, it does not install eslint.
  74. * @returns {string[]} An array of modules to be installed.
  75. */
  76. function getModulesList(config, installESLint) {
  77. const modules = {};
  78. // Create a list of modules which should be installed based on config
  79. if (config.plugins) {
  80. for (const plugin of config.plugins) {
  81. const moduleName = naming.normalizePackageName(plugin, "eslint-plugin");
  82. modules[moduleName] = "latest";
  83. }
  84. }
  85. if (config.extends) {
  86. const extendList = Array.isArray(config.extends) ? config.extends : [config.extends];
  87. for (const extend of extendList) {
  88. if (extend.startsWith("eslint:") || extend.startsWith("plugin:")) {
  89. continue;
  90. }
  91. const moduleName = naming.normalizePackageName(extend, "eslint-config");
  92. modules[moduleName] = "latest";
  93. Object.assign(
  94. modules,
  95. getPeerDependencies(`${moduleName}@latest`)
  96. );
  97. }
  98. }
  99. const parser = config.parser || (config.parserOptions && config.parserOptions.parser);
  100. if (parser) {
  101. modules[parser] = "latest";
  102. }
  103. if (installESLint === false) {
  104. delete modules.eslint;
  105. } else {
  106. const installStatus = npmUtils.checkDevDeps(["eslint"]);
  107. // Mark to show messages if it's new installation of eslint.
  108. if (installStatus.eslint === false) {
  109. log.info("Local ESLint installation not found.");
  110. modules.eslint = modules.eslint || "latest";
  111. config.installedESLint = true;
  112. }
  113. }
  114. return Object.keys(modules).map(name => `${name}@${modules[name]}`);
  115. }
  116. /**
  117. * Set the `rules` of a config by examining a user's source code
  118. *
  119. * Note: This clones the config object and returns a new config to avoid mutating
  120. * the original config parameter.
  121. * @param {Object} answers answers received from enquirer
  122. * @param {Object} config config object
  123. * @returns {Object} config object with configured rules
  124. */
  125. function configureRules(answers, config) {
  126. const BAR_TOTAL = 20,
  127. BAR_SOURCE_CODE_TOTAL = 4,
  128. newConfig = Object.assign({}, config),
  129. disabledConfigs = {};
  130. let sourceCodes,
  131. registry;
  132. // Set up a progress bar, as this process can take a long time
  133. const bar = new ProgressBar("Determining Config: :percent [:bar] :elapseds elapsed, eta :etas ", {
  134. width: 30,
  135. total: BAR_TOTAL
  136. });
  137. bar.tick(0); // Shows the progress bar
  138. // Get the SourceCode of all chosen files
  139. const patterns = answers.patterns.split(/[\s]+/u);
  140. try {
  141. sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, total => {
  142. bar.tick((BAR_SOURCE_CODE_TOTAL / total));
  143. });
  144. } catch (e) {
  145. log.info("\n");
  146. throw e;
  147. }
  148. const fileQty = Object.keys(sourceCodes).length;
  149. if (fileQty === 0) {
  150. log.info("\n");
  151. throw new Error("Automatic Configuration failed. No files were able to be parsed.");
  152. }
  153. // Create a registry of rule configs
  154. registry = new autoconfig.Registry();
  155. registry.populateFromCoreRules();
  156. // Lint all files with each rule config in the registry
  157. registry = registry.lintSourceCode(sourceCodes, newConfig, total => {
  158. bar.tick((BAR_TOTAL - BAR_SOURCE_CODE_TOTAL) / total); // Subtract out ticks used at beginning
  159. });
  160. debug(`\nRegistry: ${util.inspect(registry.rules, { depth: null })}`);
  161. // Create a list of recommended rules, because we don't want to disable them
  162. const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
  163. // Find and disable rules which had no error-free configuration
  164. const failingRegistry = registry.getFailingRulesRegistry();
  165. Object.keys(failingRegistry.rules).forEach(ruleId => {
  166. // If the rule is recommended, set it to error, otherwise disable it
  167. disabledConfigs[ruleId] = (recRules.indexOf(ruleId) !== -1) ? 2 : 0;
  168. });
  169. // Now that we know which rules to disable, strip out configs with errors
  170. registry = registry.stripFailingConfigs();
  171. /*
  172. * If there is only one config that results in no errors for a rule, we should use it.
  173. * createConfig will only add rules that have one configuration in the registry.
  174. */
  175. const singleConfigs = registry.createConfig().rules;
  176. /*
  177. * The "sweet spot" for number of options in a config seems to be two (severity plus one option).
  178. * Very often, a third option (usually an object) is available to address
  179. * edge cases, exceptions, or unique situations. We will prefer to use a config with
  180. * specificity of two.
  181. */
  182. const specTwoConfigs = registry.filterBySpecificity(2).createConfig().rules;
  183. // Maybe a specific combination using all three options works
  184. const specThreeConfigs = registry.filterBySpecificity(3).createConfig().rules;
  185. // If all else fails, try to use the default (severity only)
  186. const defaultConfigs = registry.filterBySpecificity(1).createConfig().rules;
  187. // Combine configs in reverse priority order (later take precedence)
  188. newConfig.rules = Object.assign({}, disabledConfigs, defaultConfigs, specThreeConfigs, specTwoConfigs, singleConfigs);
  189. // Make sure progress bar has finished (floating point rounding)
  190. bar.update(BAR_TOTAL);
  191. // Log out some stats to let the user know what happened
  192. const finalRuleIds = Object.keys(newConfig.rules);
  193. const totalRules = finalRuleIds.length;
  194. const enabledRules = finalRuleIds.filter(ruleId => (newConfig.rules[ruleId] !== 0)).length;
  195. const resultMessage = [
  196. `\nEnabled ${enabledRules} out of ${totalRules}`,
  197. `rules based on ${fileQty}`,
  198. `file${(fileQty === 1) ? "." : "s."}`
  199. ].join(" ");
  200. log.info(resultMessage);
  201. ConfigOps.normalizeToStrings(newConfig);
  202. return newConfig;
  203. }
  204. /**
  205. * process user's answers and create config object
  206. * @param {Object} answers answers received from enquirer
  207. * @returns {Object} config object
  208. */
  209. function processAnswers(answers) {
  210. let config = {
  211. rules: {},
  212. env: {},
  213. parserOptions: {},
  214. extends: []
  215. };
  216. config.parserOptions.ecmaVersion = espree.latestEcmaVersion;
  217. config.env.es2021 = true;
  218. // set the module type
  219. if (answers.moduleType === "esm") {
  220. config.parserOptions.sourceType = "module";
  221. } else if (answers.moduleType === "commonjs") {
  222. config.env.commonjs = true;
  223. }
  224. // add in browser and node environments if necessary
  225. answers.env.forEach(env => {
  226. config.env[env] = true;
  227. });
  228. // add in library information
  229. if (answers.framework === "react") {
  230. config.parserOptions.ecmaFeatures = {
  231. jsx: true
  232. };
  233. config.plugins = ["react"];
  234. config.extends.push("plugin:react/recommended");
  235. } else if (answers.framework === "vue") {
  236. config.plugins = ["vue"];
  237. config.extends.push("plugin:vue/essential");
  238. }
  239. if (answers.typescript) {
  240. if (answers.framework === "vue") {
  241. config.parserOptions.parser = "@typescript-eslint/parser";
  242. } else {
  243. config.parser = "@typescript-eslint/parser";
  244. }
  245. if (Array.isArray(config.plugins)) {
  246. config.plugins.push("@typescript-eslint");
  247. } else {
  248. config.plugins = ["@typescript-eslint"];
  249. }
  250. }
  251. // setup rules based on problems/style enforcement preferences
  252. if (answers.purpose === "problems") {
  253. config.extends.unshift("eslint:recommended");
  254. } else if (answers.purpose === "style") {
  255. if (answers.source === "prompt") {
  256. config.extends.unshift("eslint:recommended");
  257. config.rules.indent = ["error", answers.indent];
  258. config.rules.quotes = ["error", answers.quotes];
  259. config.rules["linebreak-style"] = ["error", answers.linebreak];
  260. config.rules.semi = ["error", answers.semi ? "always" : "never"];
  261. } else if (answers.source === "auto") {
  262. config = configureRules(answers, config);
  263. config = autoconfig.extendFromRecommended(config);
  264. }
  265. }
  266. if (answers.typescript && config.extends.includes("eslint:recommended")) {
  267. config.extends.push("plugin:@typescript-eslint/recommended");
  268. }
  269. // normalize extends
  270. if (config.extends.length === 0) {
  271. delete config.extends;
  272. } else if (config.extends.length === 1) {
  273. config.extends = config.extends[0];
  274. }
  275. ConfigOps.normalizeToStrings(config);
  276. return config;
  277. }
  278. /**
  279. * Get the version of the local ESLint.
  280. * @returns {string|null} The version. If the local ESLint was not found, returns null.
  281. */
  282. function getLocalESLintVersion() {
  283. try {
  284. const eslintPath = ModuleResolver.resolve("eslint", path.join(process.cwd(), "__placeholder__.js"));
  285. const eslint = require(eslintPath);
  286. return eslint.linter.version || null;
  287. } catch {
  288. return null;
  289. }
  290. }
  291. /**
  292. * Get the shareable config name of the chosen style guide.
  293. * @param {Object} answers The answers object.
  294. * @returns {string} The shareable config name.
  295. */
  296. function getStyleGuideName(answers) {
  297. if (answers.styleguide === "airbnb" && answers.framework !== "react") {
  298. return "airbnb-base";
  299. }
  300. return answers.styleguide;
  301. }
  302. /**
  303. * Check whether the local ESLint version conflicts with the required version of the chosen shareable config.
  304. * @param {Object} answers The answers object.
  305. * @returns {boolean} `true` if the local ESLint is found then it conflicts with the required version of the chosen shareable config.
  306. */
  307. function hasESLintVersionConflict(answers) {
  308. // Get the local ESLint version.
  309. const localESLintVersion = getLocalESLintVersion();
  310. if (!localESLintVersion) {
  311. return false;
  312. }
  313. // Get the required range of ESLint version.
  314. const configName = getStyleGuideName(answers);
  315. const moduleName = `eslint-config-${configName}@latest`;
  316. const peerDependencies = getPeerDependencies(moduleName) || {};
  317. const requiredESLintVersionRange = peerDependencies.eslint;
  318. if (!requiredESLintVersionRange) {
  319. return false;
  320. }
  321. answers.localESLintVersion = localESLintVersion;
  322. answers.requiredESLintVersionRange = requiredESLintVersionRange;
  323. // Check the version.
  324. if (semver.satisfies(localESLintVersion, requiredESLintVersionRange)) {
  325. answers.installESLint = false;
  326. return false;
  327. }
  328. return true;
  329. }
  330. /**
  331. * Install modules.
  332. * @param {string[]} modules Modules to be installed.
  333. * @returns {void}
  334. */
  335. function installModules(modules) {
  336. log.info(`Installing ${modules.join(", ")}`);
  337. npmUtils.installSyncSaveDev(modules);
  338. }
  339. /* istanbul ignore next: no need to test enquirer */
  340. /**
  341. * Ask user to install modules.
  342. * @param {string[]} modules Array of modules to be installed.
  343. * @param {boolean} packageJsonExists Indicates if package.json is existed.
  344. * @returns {Promise} Answer that indicates if user wants to install.
  345. */
  346. function askInstallModules(modules, packageJsonExists) {
  347. // If no modules, do nothing.
  348. if (modules.length === 0) {
  349. return Promise.resolve();
  350. }
  351. log.info("The config that you've selected requires the following dependencies:\n");
  352. log.info(modules.join(" "));
  353. return enquirer.prompt([
  354. {
  355. type: "toggle",
  356. name: "executeInstallation",
  357. message: "Would you like to install them now with npm?",
  358. enabled: "Yes",
  359. disabled: "No",
  360. initial: 1,
  361. skip() {
  362. return !(modules.length && packageJsonExists);
  363. },
  364. result(input) {
  365. return this.skipped ? null : input;
  366. }
  367. }
  368. ]).then(({ executeInstallation }) => {
  369. if (executeInstallation) {
  370. installModules(modules);
  371. }
  372. });
  373. }
  374. /* istanbul ignore next: no need to test enquirer */
  375. /**
  376. * Ask use a few questions on command prompt
  377. * @returns {Promise} The promise with the result of the prompt
  378. */
  379. function promptUser() {
  380. return enquirer.prompt([
  381. {
  382. type: "select",
  383. name: "purpose",
  384. message: "How would you like to use ESLint?",
  385. // The returned number matches the name value of nth in the choices array.
  386. initial: 1,
  387. choices: [
  388. { message: "To check syntax only", name: "syntax" },
  389. { message: "To check syntax and find problems", name: "problems" },
  390. { message: "To check syntax, find problems, and enforce code style", name: "style" }
  391. ]
  392. },
  393. {
  394. type: "select",
  395. name: "moduleType",
  396. message: "What type of modules does your project use?",
  397. initial: 0,
  398. choices: [
  399. { message: "JavaScript modules (import/export)", name: "esm" },
  400. { message: "CommonJS (require/exports)", name: "commonjs" },
  401. { message: "None of these", name: "none" }
  402. ]
  403. },
  404. {
  405. type: "select",
  406. name: "framework",
  407. message: "Which framework does your project use?",
  408. initial: 0,
  409. choices: [
  410. { message: "React", name: "react" },
  411. { message: "Vue.js", name: "vue" },
  412. { message: "None of these", name: "none" }
  413. ]
  414. },
  415. {
  416. type: "toggle",
  417. name: "typescript",
  418. message: "Does your project use TypeScript?",
  419. enabled: "Yes",
  420. disabled: "No",
  421. initial: 0
  422. },
  423. {
  424. type: "multiselect",
  425. name: "env",
  426. message: "Where does your code run?",
  427. hint: "(Press <space> to select, <a> to toggle all, <i> to invert selection)",
  428. initial: 0,
  429. choices: [
  430. { message: "Browser", name: "browser" },
  431. { message: "Node", name: "node" }
  432. ]
  433. },
  434. {
  435. type: "select",
  436. name: "source",
  437. message: "How would you like to define a style for your project?",
  438. choices: [
  439. { message: "Use a popular style guide", name: "guide" },
  440. { message: "Answer questions about your style", name: "prompt" },
  441. { message: "Inspect your JavaScript file(s)", name: "auto" }
  442. ],
  443. skip() {
  444. return this.state.answers.purpose !== "style";
  445. },
  446. result(input) {
  447. return this.skipped ? null : input;
  448. }
  449. },
  450. {
  451. type: "select",
  452. name: "styleguide",
  453. message: "Which style guide do you want to follow?",
  454. choices: [
  455. { message: "Airbnb: https://github.com/airbnb/javascript", name: "airbnb" },
  456. { message: "Standard: https://github.com/standard/standard", name: "standard" },
  457. { message: "Google: https://github.com/google/eslint-config-google", name: "google" }
  458. ],
  459. skip() {
  460. this.state.answers.packageJsonExists = npmUtils.checkPackageJson();
  461. return !(this.state.answers.source === "guide" && this.state.answers.packageJsonExists);
  462. },
  463. result(input) {
  464. return this.skipped ? null : input;
  465. }
  466. },
  467. {
  468. type: "input",
  469. name: "patterns",
  470. message: "Which file(s), path(s), or glob(s) should be examined?",
  471. skip() {
  472. return this.state.answers.source !== "auto";
  473. },
  474. validate(input) {
  475. if (!this.skipped && input.trim().length === 0 && input.trim() !== ",") {
  476. return "You must tell us what code to examine. Try again.";
  477. }
  478. return true;
  479. }
  480. },
  481. {
  482. type: "select",
  483. name: "format",
  484. message: "What format do you want your config file to be in?",
  485. initial: 0,
  486. choices: ["JavaScript", "YAML", "JSON"]
  487. },
  488. {
  489. type: "toggle",
  490. name: "installESLint",
  491. message(answers) {
  492. const verb = semver.ltr(answers.localESLintVersion, answers.requiredESLintVersionRange)
  493. ? "upgrade"
  494. : "downgrade";
  495. return `The style guide "${answers.styleguide}" requires eslint@${answers.requiredESLintVersionRange}. You are currently using eslint@${answers.localESLintVersion}.\n Do you want to ${verb}?`;
  496. },
  497. enabled: "Yes",
  498. disabled: "No",
  499. initial: 1,
  500. skip() {
  501. return !(this.state.answers.source === "guide" && this.state.answers.packageJsonExists && hasESLintVersionConflict(this.state.answers));
  502. },
  503. result(input) {
  504. return this.skipped ? null : input;
  505. }
  506. }
  507. ]).then(earlyAnswers => {
  508. // early exit if no style guide is necessary
  509. if (earlyAnswers.purpose !== "style") {
  510. const config = processAnswers(earlyAnswers);
  511. const modules = getModulesList(config);
  512. return askInstallModules(modules, earlyAnswers.packageJsonExists)
  513. .then(() => writeFile(config, earlyAnswers.format));
  514. }
  515. // early exit if you are using a style guide
  516. if (earlyAnswers.source === "guide") {
  517. if (!earlyAnswers.packageJsonExists) {
  518. 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.");
  519. return void 0;
  520. }
  521. if (earlyAnswers.installESLint === false && !semver.satisfies(earlyAnswers.localESLintVersion, earlyAnswers.requiredESLintVersionRange)) {
  522. log.info(`Note: it might not work since ESLint's version is mismatched with the ${earlyAnswers.styleguide} config.`);
  523. }
  524. if (earlyAnswers.styleguide === "airbnb" && earlyAnswers.framework !== "react") {
  525. earlyAnswers.styleguide = "airbnb-base";
  526. }
  527. const config = processAnswers(earlyAnswers);
  528. if (Array.isArray(config.extends)) {
  529. config.extends.push(earlyAnswers.styleguide);
  530. } else if (config.extends) {
  531. config.extends = [config.extends, earlyAnswers.styleguide];
  532. } else {
  533. config.extends = [earlyAnswers.styleguide];
  534. }
  535. const modules = getModulesList(config);
  536. return askInstallModules(modules, earlyAnswers.packageJsonExists)
  537. .then(() => writeFile(config, earlyAnswers.format));
  538. }
  539. if (earlyAnswers.source === "auto") {
  540. const combinedAnswers = Object.assign({}, earlyAnswers);
  541. const config = processAnswers(combinedAnswers);
  542. const modules = getModulesList(config);
  543. return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format));
  544. }
  545. // continue with the style questions otherwise...
  546. return enquirer.prompt([
  547. {
  548. type: "select",
  549. name: "indent",
  550. message: "What style of indentation do you use?",
  551. initial: 0,
  552. choices: [{ message: "Tabs", name: "tab" }, { message: "Spaces", name: 4 }]
  553. },
  554. {
  555. type: "select",
  556. name: "quotes",
  557. message: "What quotes do you use for strings?",
  558. initial: 0,
  559. choices: [{ message: "Double", name: "double" }, { message: "Single", name: "single" }]
  560. },
  561. {
  562. type: "select",
  563. name: "linebreak",
  564. message: "What line endings do you use?",
  565. initial: 0,
  566. choices: [{ message: "Unix", name: "unix" }, { message: "Windows", name: "windows" }]
  567. },
  568. {
  569. type: "toggle",
  570. name: "semi",
  571. message: "Do you require semicolons?",
  572. enabled: "Yes",
  573. disabled: "No",
  574. initial: 1
  575. }
  576. ]).then(answers => {
  577. const totalAnswers = Object.assign({}, earlyAnswers, answers);
  578. const config = processAnswers(totalAnswers);
  579. const modules = getModulesList(config);
  580. return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format));
  581. });
  582. });
  583. }
  584. //------------------------------------------------------------------------------
  585. // Public Interface
  586. //------------------------------------------------------------------------------
  587. const init = {
  588. getModulesList,
  589. hasESLintVersionConflict,
  590. installModules,
  591. processAnswers,
  592. /* istanbul ignore next */initializeConfig() {
  593. return promptUser();
  594. }
  595. };
  596. module.exports = init;