diff --git a/README.md b/README.md index 091645e..61385ac 100644 --- a/README.md +++ b/README.md @@ -28,5 +28,5 @@ npm init @eslint/config@latest -- --config eslint-config-standard To use an eslintrc-style (legacy) shared config: ```bash -npm init @eslint/config -- --eslintrc --config eslint-config-standard +npm init @eslint/config@latest -- --eslintrc --config eslint-config-standard ``` diff --git a/bin/create-config.js b/bin/create-config.js index f385b20..6623c25 100755 --- a/bin/create-config.js +++ b/bin/create-config.js @@ -31,7 +31,7 @@ if (sharedConfigIndex === -1) { // passed "--config" const packageName = argv[sharedConfigIndex + 1]; const type = argv.includes("--eslintrc") ? "eslintrc" : "flat"; - const answers = { purpose: "style", moduleType: "module", styleguide: { packageName, type } }; + const answers = { config: { packageName, type } }; const generator = new ConfigGenerator({ cwd, packageJsonPath, answers }); generator.calc(); diff --git a/lib/config-generator.js b/lib/config-generator.js index e81c5ff..34dc37d 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -11,17 +11,6 @@ import { isPackageTypeModule, installSyncSaveDev, fetchPeerDependencies, findPac import { getShorthandName } from "./utils/naming.js"; import * as log from "./utils/logging.js"; -// TODO: need to specify the package version - they may export flat configs in the future. -const jsStyleGuides = [ - { message: "Airbnb: https://github.com/airbnb/javascript", name: "airbnb", value: { packageName: "eslint-config-airbnb-base", type: "eslintrc" } }, - { message: "Standard: https://github.com/standard/standard", name: "standard", value: { packageName: "eslint-config-standard", type: "eslintrc" } }, - { message: "XO: https://github.com/xojs/eslint-config-xo", name: "xo", value: { packageName: "eslint-config-xo", type: "eslintrc" } } -]; -const tsStyleGuides = [ - { message: "Standard: https://github.com/standard/eslint-config-standard-with-typescript", name: "standard", value: { packageName: "eslint-config-standard-with-typescript", type: "eslintrc" } }, - { message: "XO: https://github.com/xojs/eslint-config-xo-typescript", name: "xo", value: { packageName: "eslint-config-xo-typescript", type: "eslintrc" } } -]; - /** * Class representing a ConfigGenerator. */ @@ -39,7 +28,7 @@ export class ConfigGenerator { this.packageJsonPath = options.packageJsonPath || findPackageJson(this.cwd); this.answers = options.answers || {}; this.result = { - devDependencies: ["eslint"], + devDependencies: [], configFilename: "eslint.config.js", configContent: "" }; @@ -58,8 +47,7 @@ export class ConfigGenerator { initial: 1, choices: [ { message: "To check syntax only", name: "syntax" }, - { message: "To check syntax and find problems", name: "problems" }, - { message: "To check syntax, find problems, and enforce code style", name: "style" } + { message: "To check syntax and find problems", name: "problems" } ] }, { @@ -110,20 +98,6 @@ export class ConfigGenerator { const answers = await enquirer.prompt(questions); Object.assign(this.answers, answers); - - if (answers.purpose === "style") { - - const choices = this.answers.language === "javascript" ? jsStyleGuides : tsStyleGuides; - const styleguideAnswer = await enquirer.prompt({ - type: "select", - name: "styleguide", - message: "Which style guide do you want to follow?", - choices, - result: choice => choices.find(it => it.name === choice).value - }); - - Object.assign(this.answers, styleguideAnswer); - } } /** @@ -134,22 +108,9 @@ export class ConfigGenerator { const isESMModule = isPackageTypeModule(this.packageJsonPath); this.result.configFilename = isESMModule ? "eslint.config.js" : "eslint.config.mjs"; - this.answers.styleguide = typeof this.answers.styleguide === "string" - ? { packageName: this.answers.styleguide, type: "flat" } - : this.answers.styleguide; - - // replaced `eslint-config-airbnb-base` with `eslint-config-airbnb`(for react supports) - if (this.answers.styleguide?.packageName === "eslint-config-airbnb-base" && this.answers.framework === "react") { - this.answers.styleguide.packageName = "eslint-config-airbnb"; - this.answers.framework = "none"; - } - - // tseslint should have been a dependency in the shared configs - // avoid install tseslint - it may install multi tseslint versions - // see https://github.com/eslint/create-config/issues/97 - if (this.answers.styleguide && this.answers.language === "typescript") { - this.answers.language = "javascript"; - } + this.answers.config = typeof this.answers.config === "string" + ? { packageName: this.answers.config, type: "flat" } + : this.answers.config; let importContent = ""; const helperContent = `import path from "path"; @@ -188,28 +149,6 @@ const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: plug this.result.devDependencies.push("@eslint/js"); importContent += "import pluginJs from \"@eslint/js\";\n"; exportContent += " pluginJs.configs.recommended,\n"; - } else if (this.answers.purpose === "style") { - const styleguide = this.answers.styleguide; - - this.result.devDependencies.push(styleguide.packageName); - - // install peer dependencies - it's needed for most eslintrc-style shared configs. - const peers = fetchPeerDependencies(styleguide.packageName); - - if (peers !== null) { - this.result.devDependencies.push(...peers); - } - - if (styleguide.type === "flat" || styleguide.type === void 0) { - importContent += `import styleGuide from "${styleguide.packageName}";\n`; - exportContent += " ...[].concat(styleGuide),\n"; - } else if (styleguide.type === "eslintrc") { - needCompatHelper = true; - - const shorthandName = getShorthandName(styleguide.packageName, "eslint-config"); - - exportContent += ` ...compat.extends("${shorthandName}"),\n`; - } } if (this.answers.language === "typescript") { @@ -231,10 +170,39 @@ const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: plug importContent += "import pluginReactConfig from \"eslint-plugin-react/configs/recommended.js\";\n"; exportContent += " pluginReactConfig,\n"; } + if (this.answers.config) { + const config = this.answers.config; + + this.result.devDependencies.push(config.packageName); + + // install peer dependencies - it's needed for most eslintrc-style shared configs. + const peers = fetchPeerDependencies(config.packageName); + + if (peers !== null) { + this.result.devDependencies.push(...peers); + } + + if (config.type === "flat" || config.type === void 0) { + importContent += `import config from "${config.packageName}";\n`; + exportContent += " ...[].concat(config),\n"; + } else if (config.type === "eslintrc") { + needCompatHelper = true; + + const shorthandName = getShorthandName(config.packageName, "eslint-config"); + + exportContent += ` ...compat.extends("${shorthandName}"),\n`; + } + } if (needCompatHelper) { this.result.devDependencies.push("@eslint/eslintrc", "@eslint/js"); } + + const hasEslint = this.result.devDependencies.some(dep => (/^eslint(@|$)/u.test(dep))); + + if (!hasEslint) { + this.result.devDependencies.push("eslint"); + } this.result.configContent = `${importContent} ${needCompatHelper ? helperContent : ""} export default [\n${exportContent}];`; diff --git a/tests/__snapshots__/style-esm-react-airbnb b/tests/__snapshots__/config@eslint-config-airbnb similarity index 85% rename from tests/__snapshots__/style-esm-react-airbnb rename to tests/__snapshots__/config@eslint-config-airbnb index 97153d5..8a37ae6 100644 --- a/tests/__snapshots__/style-esm-react-airbnb +++ b/tests/__snapshots__/config@eslint-config-airbnb @@ -1,6 +1,5 @@ { - "configContent": "import globals from "globals"; - + "configContent": " import path from "path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; @@ -12,13 +11,10 @@ const __dirname = path.dirname(__filename); const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); export default [ - {languageOptions: { globals: globals.browser }}, ...compat.extends("airbnb"), ];", "configFilename": "eslint.config.mjs", "devDependencies": [ - "eslint", - "globals", "eslint-config-airbnb", "eslint@^7.32.0 || ^8.2.0", "eslint-plugin-import@^2.25.3", diff --git a/tests/__snapshots__/style-esm-none-airbnb b/tests/__snapshots__/config@eslint-config-airbnb-base similarity index 83% rename from tests/__snapshots__/style-esm-none-airbnb rename to tests/__snapshots__/config@eslint-config-airbnb-base index e6dfcfd..02abf19 100644 --- a/tests/__snapshots__/style-esm-none-airbnb +++ b/tests/__snapshots__/config@eslint-config-airbnb-base @@ -1,6 +1,5 @@ { - "configContent": "import globals from "globals"; - + "configContent": " import path from "path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; @@ -12,13 +11,10 @@ const __dirname = path.dirname(__filename); const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); export default [ - {languageOptions: { globals: globals.browser }}, ...compat.extends("airbnb-base"), ];", "configFilename": "eslint.config.mjs", "devDependencies": [ - "eslint", - "globals", "eslint-config-airbnb-base", "eslint@^7.32.0 || ^8.2.0", "eslint-plugin-import@^2.25.2", diff --git a/tests/__snapshots__/style-esm-none-xo-typescript b/tests/__snapshots__/config@eslint-config-standard similarity index 61% rename from tests/__snapshots__/style-esm-none-xo-typescript rename to tests/__snapshots__/config@eslint-config-standard index b030443..f16330b 100644 --- a/tests/__snapshots__/style-esm-none-xo-typescript +++ b/tests/__snapshots__/config@eslint-config-standard @@ -1,6 +1,5 @@ { - "configContent": "import globals from "globals"; - + "configContent": " import path from "path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; @@ -12,18 +11,15 @@ const __dirname = path.dirname(__filename); const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); export default [ - {languageOptions: { globals: globals.browser }}, - ...compat.extends("xo-typescript"), + ...compat.extends("standard"), ];", "configFilename": "eslint.config.mjs", "devDependencies": [ - "eslint", - "globals", - "eslint-config-xo-typescript", - "@typescript-eslint/eslint-plugin@>=7.0.2", - "@typescript-eslint/parser@>=7.0.2", - "eslint@>=8.56.0", - "typescript@>=5.0.0", + "eslint-config-standard", + "eslint@^8.0.1", + "eslint-plugin-import@^2.25.2", + "eslint-plugin-n@^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise@^6.0.0", "@eslint/eslintrc", "@eslint/js", ], diff --git a/tests/__snapshots__/config@eslint-config-standard-flat b/tests/__snapshots__/config@eslint-config-standard-flat new file mode 100644 index 0000000..9b748c7 --- /dev/null +++ b/tests/__snapshots__/config@eslint-config-standard-flat @@ -0,0 +1,16 @@ +{ + "configContent": "import config from "eslint-config-standard"; + + +export default [ + ...[].concat(config), +];", + "configFilename": "eslint.config.mjs", + "devDependencies": [ + "eslint-config-standard", + "eslint@^8.0.1", + "eslint-plugin-import@^2.25.2", + "eslint-plugin-n@^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise@^6.0.0", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/config@eslint-config-standard-flat2 b/tests/__snapshots__/config@eslint-config-standard-flat2 new file mode 100644 index 0000000..9b748c7 --- /dev/null +++ b/tests/__snapshots__/config@eslint-config-standard-flat2 @@ -0,0 +1,16 @@ +{ + "configContent": "import config from "eslint-config-standard"; + + +export default [ + ...[].concat(config), +];", + "configFilename": "eslint.config.mjs", + "devDependencies": [ + "eslint-config-standard", + "eslint@^8.0.1", + "eslint-plugin-import@^2.25.2", + "eslint-plugin-n@^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise@^6.0.0", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/style-esm-none-xo-javascript b/tests/__snapshots__/config@eslint-config-xo similarity index 82% rename from tests/__snapshots__/style-esm-none-xo-javascript rename to tests/__snapshots__/config@eslint-config-xo index f0a0acf..d6d5693 100644 --- a/tests/__snapshots__/style-esm-none-xo-javascript +++ b/tests/__snapshots__/config@eslint-config-xo @@ -1,6 +1,5 @@ { - "configContent": "import globals from "globals"; - + "configContent": " import path from "path"; import { fileURLToPath } from "url"; import { FlatCompat } from "@eslint/eslintrc"; @@ -12,13 +11,10 @@ const __dirname = path.dirname(__filename); const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); export default [ - {languageOptions: { globals: globals.node }}, ...compat.extends("xo"), ];", "configFilename": "eslint.config.mjs", "devDependencies": [ - "eslint", - "globals", "eslint-config-xo", "eslint@>=8.56.0", "@eslint/eslintrc", diff --git a/tests/__snapshots__/problems-commonjs-none-javascript b/tests/__snapshots__/problems-commonjs-none-javascript index be19a4b..7bbbcf4 100644 --- a/tests/__snapshots__/problems-commonjs-none-javascript +++ b/tests/__snapshots__/problems-commonjs-none-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-commonjs-none-typescript b/tests/__snapshots__/problems-commonjs-none-typescript index 00a021d..d93b416 100644 --- a/tests/__snapshots__/problems-commonjs-none-typescript +++ b/tests/__snapshots__/problems-commonjs-none-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-commonjs-react-javascript b/tests/__snapshots__/problems-commonjs-react-javascript index bf035ea..ab27fb8 100644 --- a/tests/__snapshots__/problems-commonjs-react-javascript +++ b/tests/__snapshots__/problems-commonjs-react-javascript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-commonjs-react-typescript b/tests/__snapshots__/problems-commonjs-react-typescript index efb4c31..0ff88fe 100644 --- a/tests/__snapshots__/problems-commonjs-react-typescript +++ b/tests/__snapshots__/problems-commonjs-react-typescript @@ -14,10 +14,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-commonjs-vue-javascript b/tests/__snapshots__/problems-commonjs-vue-javascript index 8b58d41..a925ee1 100644 --- a/tests/__snapshots__/problems-commonjs-vue-javascript +++ b/tests/__snapshots__/problems-commonjs-vue-javascript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-commonjs-vue-typescript b/tests/__snapshots__/problems-commonjs-vue-typescript index fbf258b..db4688f 100644 --- a/tests/__snapshots__/problems-commonjs-vue-typescript +++ b/tests/__snapshots__/problems-commonjs-vue-typescript @@ -14,10 +14,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-none-javascript b/tests/__snapshots__/problems-esm-none-javascript index feeaec4..e66bb2b 100644 --- a/tests/__snapshots__/problems-esm-none-javascript +++ b/tests/__snapshots__/problems-esm-none-javascript @@ -9,8 +9,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-none-typescript b/tests/__snapshots__/problems-esm-none-typescript index 0ff9676..a3c753e 100644 --- a/tests/__snapshots__/problems-esm-none-typescript +++ b/tests/__snapshots__/problems-esm-none-typescript @@ -11,9 +11,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-react-javascript b/tests/__snapshots__/problems-esm-react-javascript index a529a49..c844a1c 100644 --- a/tests/__snapshots__/problems-esm-react-javascript +++ b/tests/__snapshots__/problems-esm-react-javascript @@ -11,9 +11,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-react-typescript b/tests/__snapshots__/problems-esm-react-typescript index 295b1ef..8898193 100644 --- a/tests/__snapshots__/problems-esm-react-typescript +++ b/tests/__snapshots__/problems-esm-react-typescript @@ -13,10 +13,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-vue-javascript b/tests/__snapshots__/problems-esm-vue-javascript index da40a1b..0555cc3 100644 --- a/tests/__snapshots__/problems-esm-vue-javascript +++ b/tests/__snapshots__/problems-esm-vue-javascript @@ -11,9 +11,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-esm-vue-typescript b/tests/__snapshots__/problems-esm-vue-typescript index 3b82eaa..3632511 100644 --- a/tests/__snapshots__/problems-esm-vue-typescript +++ b/tests/__snapshots__/problems-esm-vue-typescript @@ -13,10 +13,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-none-javascript b/tests/__snapshots__/problems-script-none-javascript index 96840e0..cd756b1 100644 --- a/tests/__snapshots__/problems-script-none-javascript +++ b/tests/__snapshots__/problems-script-none-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-none-typescript b/tests/__snapshots__/problems-script-none-typescript index d17bee0..a50b00f 100644 --- a/tests/__snapshots__/problems-script-none-typescript +++ b/tests/__snapshots__/problems-script-none-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-react-javascript b/tests/__snapshots__/problems-script-react-javascript index ed1e9bc..b3001f7 100644 --- a/tests/__snapshots__/problems-script-react-javascript +++ b/tests/__snapshots__/problems-script-react-javascript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-react-typescript b/tests/__snapshots__/problems-script-react-typescript index b35aafe..2f744bf 100644 --- a/tests/__snapshots__/problems-script-react-typescript +++ b/tests/__snapshots__/problems-script-react-typescript @@ -14,10 +14,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-vue-javascript b/tests/__snapshots__/problems-script-vue-javascript index 4c0fb51..42f07b1 100644 --- a/tests/__snapshots__/problems-script-vue-javascript +++ b/tests/__snapshots__/problems-script-vue-javascript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/problems-script-vue-typescript b/tests/__snapshots__/problems-script-vue-typescript index 9244df2..4a91e35 100644 --- a/tests/__snapshots__/problems-script-vue-typescript +++ b/tests/__snapshots__/problems-script-vue-typescript @@ -14,10 +14,10 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "@eslint/js", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-none-javascript b/tests/__snapshots__/syntax-commonjs-none-javascript index c92284f..6035d03 100644 --- a/tests/__snapshots__/syntax-commonjs-none-javascript +++ b/tests/__snapshots__/syntax-commonjs-none-javascript @@ -8,7 +8,7 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-none-typescript b/tests/__snapshots__/syntax-commonjs-none-typescript index 7f3d2be..2afed03 100644 --- a/tests/__snapshots__/syntax-commonjs-none-typescript +++ b/tests/__snapshots__/syntax-commonjs-none-typescript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-react-javascript b/tests/__snapshots__/syntax-commonjs-react-javascript index c99a6ff..724bca5 100644 --- a/tests/__snapshots__/syntax-commonjs-react-javascript +++ b/tests/__snapshots__/syntax-commonjs-react-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-react-typescript b/tests/__snapshots__/syntax-commonjs-react-typescript index 80e932e..05dcabe 100644 --- a/tests/__snapshots__/syntax-commonjs-react-typescript +++ b/tests/__snapshots__/syntax-commonjs-react-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-vue-javascript b/tests/__snapshots__/syntax-commonjs-vue-javascript index 478b344..a66b850 100644 --- a/tests/__snapshots__/syntax-commonjs-vue-javascript +++ b/tests/__snapshots__/syntax-commonjs-vue-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-commonjs-vue-typescript b/tests/__snapshots__/syntax-commonjs-vue-typescript index 34a5635..9222bc7 100644 --- a/tests/__snapshots__/syntax-commonjs-vue-typescript +++ b/tests/__snapshots__/syntax-commonjs-vue-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-none-javascript b/tests/__snapshots__/syntax-esm-none-javascript index 2da2340..1e9a0e1 100644 --- a/tests/__snapshots__/syntax-esm-none-javascript +++ b/tests/__snapshots__/syntax-esm-none-javascript @@ -7,7 +7,7 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-none-typescript b/tests/__snapshots__/syntax-esm-none-typescript index e9f51f1..3dc297b 100644 --- a/tests/__snapshots__/syntax-esm-none-typescript +++ b/tests/__snapshots__/syntax-esm-none-typescript @@ -9,8 +9,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-react-javascript b/tests/__snapshots__/syntax-esm-react-javascript index 9a6bdf1..d5b5aa4 100644 --- a/tests/__snapshots__/syntax-esm-react-javascript +++ b/tests/__snapshots__/syntax-esm-react-javascript @@ -9,8 +9,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-react-typescript b/tests/__snapshots__/syntax-esm-react-typescript index 4221331..04bdc76 100644 --- a/tests/__snapshots__/syntax-esm-react-typescript +++ b/tests/__snapshots__/syntax-esm-react-typescript @@ -11,9 +11,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-vue-javascript b/tests/__snapshots__/syntax-esm-vue-javascript index 60f0964..00a8b83 100644 --- a/tests/__snapshots__/syntax-esm-vue-javascript +++ b/tests/__snapshots__/syntax-esm-vue-javascript @@ -9,8 +9,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-esm-vue-typescript b/tests/__snapshots__/syntax-esm-vue-typescript index e909753..4fc0ce5 100644 --- a/tests/__snapshots__/syntax-esm-vue-typescript +++ b/tests/__snapshots__/syntax-esm-vue-typescript @@ -11,9 +11,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-none-javascript b/tests/__snapshots__/syntax-script-none-javascript index 0e7bc5d..5fd05d0 100644 --- a/tests/__snapshots__/syntax-script-none-javascript +++ b/tests/__snapshots__/syntax-script-none-javascript @@ -8,7 +8,7 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-none-typescript b/tests/__snapshots__/syntax-script-none-typescript index 917262d..57c5d79 100644 --- a/tests/__snapshots__/syntax-script-none-typescript +++ b/tests/__snapshots__/syntax-script-none-typescript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-react-javascript b/tests/__snapshots__/syntax-script-react-javascript index 733b3b8..32b9953 100644 --- a/tests/__snapshots__/syntax-script-react-javascript +++ b/tests/__snapshots__/syntax-script-react-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-react-typescript b/tests/__snapshots__/syntax-script-react-typescript index 475ab3f..1ae72f2 100644 --- a/tests/__snapshots__/syntax-script-react-typescript +++ b/tests/__snapshots__/syntax-script-react-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-react", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-vue-javascript b/tests/__snapshots__/syntax-script-vue-javascript index 0392812..e350254 100644 --- a/tests/__snapshots__/syntax-script-vue-javascript +++ b/tests/__snapshots__/syntax-script-vue-javascript @@ -10,8 +10,8 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/__snapshots__/syntax-script-vue-typescript b/tests/__snapshots__/syntax-script-vue-typescript index c15aa12..39b2f1e 100644 --- a/tests/__snapshots__/syntax-script-vue-typescript +++ b/tests/__snapshots__/syntax-script-vue-typescript @@ -12,9 +12,9 @@ export default [ ];", "configFilename": "eslint.config.js", "devDependencies": [ - "eslint", "globals", "typescript-eslint", "eslint-plugin-vue", + "eslint", ], } \ No newline at end of file diff --git a/tests/config-snapshots.spec.js b/tests/config-snapshots.spec.js index 3a7d823..21507b9 100644 --- a/tests/config-snapshots.spec.js +++ b/tests/config-snapshots.spec.js @@ -72,47 +72,35 @@ describe("generate config for esm projects", () => { describe("generate config for cjs projects", () => { const cjsProjectDir = join(__filename, "../fixtures/cjs-project"); const inputs = [{ - name: "style-esm-none-xo-javascript", + name: "config@eslint-config-xo", answers: { - purpose: "style", - moduleType: "esm", - framework: "none", - language: "javascript", - env: ["node"], - styleguide: { packageName: "eslint-config-xo", type: "eslintrc" } + config: { packageName: "eslint-config-xo", type: "eslintrc" } } }, { - name: "style-esm-none-xo-typescript", + name: "config@eslint-config-airbnb-base", answers: { - purpose: "style", - moduleType: "esm", - framework: "none", - language: "typescript", - env: ["browser"], - styleguide: { packageName: "eslint-config-xo-typescript", type: "eslintrc" } + config: { packageName: "eslint-config-airbnb-base", type: "eslintrc" } } - }, - { - name: "style-esm-react-airbnb", + }, { + name: "config@eslint-config-airbnb", answers: { - purpose: "style", - moduleType: "esm", - framework: "react", - language: "javascript", - env: ["browser"], - styleguide: { packageName: "eslint-config-airbnb-base", type: "eslintrc" } + config: { packageName: "eslint-config-airbnb", type: "eslintrc" } } - }, - { - name: "style-esm-none-airbnb", + }, { + name: "config@eslint-config-standard", + answers: { + config: { packageName: "eslint-config-standard", type: "eslintrc" } + } + }, { + name: "config@eslint-config-standard-flat", + answers: { + config: { packageName: "eslint-config-standard", type: "flat" } + } + }, { + name: "config@eslint-config-standard-flat2", answers: { - purpose: "style", - moduleType: "esm", - framework: "none", - language: "javascript", - env: ["browser"], - styleguide: { packageName: "eslint-config-airbnb-base", type: "eslintrc" } + config: "eslint-config-standard" } }];