diff --git a/bin/create-config.js b/bin/create-config.js index 8f83892..48a400e 100755 --- a/bin/create-config.js +++ b/bin/create-config.js @@ -36,7 +36,7 @@ if (sharedConfigIndex === -1) { // passed "--config" const packageName = argv[sharedConfigIndex + 1]; const type = argv.includes("--eslintrc") ? "eslintrc" : "flat"; - const answers = { config: { packageName, type } }; + const answers = { config: { packageName, type }, languages: ["javascript"] }; const generator = new ConfigGenerator({ cwd, packageJsonPath, answers }); generator.calc(); diff --git a/lib/config-generator.js b/lib/config-generator.js index 2bcd491..d28d817 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -10,6 +10,18 @@ import enquirer from "enquirer"; import { isPackageTypeModule, installSyncSaveDev, fetchPeerDependencies, findPackageJson } from "./utils/npm-utils.js"; import { getShorthandName } from "./utils/naming.js"; import * as log from "./utils/logging.js"; +import { langQuestions, jsQuestions, mdQuestions, installationQuestions } from "./questions.js"; + +const helperContent = `import path from "path"; +import { fileURLToPath } from "url"; +import { FlatCompat } from "@eslint/eslintrc"; +import pluginJs from "@eslint/js"; + +// mimic CommonJS variables -- not needed if using CommonJS +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); +`; /** * Class representing a ConfigGenerator. @@ -40,65 +52,15 @@ export class ConfigGenerator { * @returns {void} */ async prompt() { - const questions = [ - { - type: "select", - name: "purpose", - message: "How would you like to use ESLint?", - initial: 1, - choices: [ - { message: "To check syntax only", name: "syntax" }, - { message: "To check syntax and find problems", name: "problems" } - ] - }, - { - type: "select", - name: "moduleType", - message: "What type of modules does your project use?", - initial: 0, - choices: [ - { message: "JavaScript modules (import/export)", name: "esm" }, - { message: "CommonJS (require/exports)", name: "commonjs" }, - { message: "None of these", name: "script" } - ] - }, - { - type: "select", - name: "framework", - message: "Which framework does your project use?", - initial: 0, - choices: [ - { message: "React", name: "react" }, - { message: "Vue.js", name: "vue" }, - { message: "None of these", name: "none" } - ] - }, - { - type: "select", - name: "language", - message: "Does your project use TypeScript?", - choices: [ - { message: "No", name: "javascript" }, - { message: "Yes", name: "typescript" } - ], - initial: 0 - }, - { - type: "multiselect", - name: "env", - message: "Where does your code run?", - hint: "(Press to select, to toggle all, to invert selection)", - initial: 0, - choices: [ - { message: "Browser", name: "browser" }, - { message: "Node", name: "node" } - ] - } - ]; + Object.assign(this.answers, await enquirer.prompt(langQuestions)); - const answers = await enquirer.prompt(questions); + if (this.answers.languages.includes("javascript")) { + Object.assign(this.answers, await enquirer.prompt(jsQuestions)); + } - Object.assign(this.answers, answers); + if (this.answers.languages.includes("md")) { + Object.assign(this.answers, await enquirer.prompt(mdQuestions)); + } } /** @@ -107,6 +69,7 @@ export class ConfigGenerator { */ calc() { const isESMModule = isPackageTypeModule(this.packageJsonPath); + const useTs = this.answers.useTs; this.result.configFilename = isESMModule ? "eslint.config.js" : "eslint.config.mjs"; this.answers.config = typeof this.answers.config === "string" @@ -115,73 +78,116 @@ export class ConfigGenerator { const extensions = []; // file extensions to lint, the default is ["js", "mjs", "cjs"] let importContent = ""; - const helperContent = `import path from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; -import pluginJs from "@eslint/js"; - -// mimic CommonJS variables -- not needed if using CommonJS -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended}); -`; let exportContent = ""; let needCompatHelper = false; + const languages = this.answers.languages ?? ["javascript"]; + const purpose = this.answers.purpose; - if (this.answers.moduleType === "commonjs" || this.answers.moduleType === "script") { - exportContent += ` {files: ["**/*.js"], languageOptions: {sourceType: "${this.answers.moduleType}"}},\n`; - } + if (languages.includes("javascript")) { + if (this.answers.moduleType === "commonjs" || this.answers.moduleType === "script") { + exportContent += ` {files: ["**/*.js"], languageOptions: {sourceType: "${this.answers.moduleType}"}},\n`; + } - if (this.answers.env?.length > 0) { - this.result.devDependencies.push("globals"); - importContent += "import globals from \"globals\";\n"; - const envContent = { - browser: "globals: globals.browser", - node: "globals: globals.node", - "browser,node": "globals: {...globals.browser, ...globals.node}" - }; + if (this.answers.env?.length > 0) { + this.result.devDependencies.push("globals"); + importContent += "import globals from \"globals\";\n"; + const envContent = { + browser: "globals: globals.browser", + node: "globals: globals.node", + "browser,node": "globals: {...globals.browser, ...globals.node}" + }; - exportContent += ` {languageOptions: { ${envContent[this.answers.env.join(",")]} }},\n`; - } + exportContent += ` {languageOptions: { ${envContent[this.answers.env.join(",")]} }},\n`; + } + + if (purpose === "syntax") { + + // no need to install any plugin + } else if (purpose === "problems") { + this.result.devDependencies.push("@eslint/js"); + importContent += "import pluginJs from \"@eslint/js\";\n"; + exportContent += " pluginJs.configs.recommended,\n"; + } + + if (useTs) { + extensions.push("ts"); + this.result.devDependencies.push("typescript-eslint"); + importContent += "import tseslint from \"typescript-eslint\";\n"; + exportContent += " ...tseslint.configs.recommended,\n"; + } + + if (this.answers.framework === "vue") { + extensions.push("vue"); + this.result.devDependencies.push("eslint-plugin-vue"); + importContent += "import pluginVue from \"eslint-plugin-vue\";\n"; + exportContent += " ...pluginVue.configs[\"flat/essential\"],\n"; + + // https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser + if (useTs) { + exportContent += " {files: [\"**/*.vue\"], languageOptions: {parserOptions: {parser: tseslint.parser}}},\n"; + } + } + + if (this.answers.framework === "react") { + extensions.push("jsx"); + + if (useTs) { + extensions.push("tsx"); + } - if (this.answers.purpose === "syntax") { + this.result.devDependencies.push("eslint-plugin-react"); + importContent += "import pluginReact from \"eslint-plugin-react\";\n"; + exportContent += " pluginReact.configs.flat.recommended,\n"; + } + } else { + exportContent += " {ignores: [\"**/*.js\", \"**/*.cjs\", \"**/*.mjs\"]},\n"; + } - // no need to install any plugin - } else if (this.answers.purpose === "problems") { - this.result.devDependencies.push("@eslint/js"); - importContent += "import pluginJs from \"@eslint/js\";\n"; - exportContent += " pluginJs.configs.recommended,\n"; + if (languages.some(item => item.startsWith("json"))) { + this.result.devDependencies.push("@eslint/json"); + importContent += "import json from \"@eslint/json\";\n"; } + if (languages.includes("json")) { + const config = purpose === "syntax" + ? " {files: [\"**/*.json\"], plugins: {json}, language: \"json/json\"},\n" + : " {files: [\"**/*.json\"], language: \"json/json\", ...json.configs.recommended},\n"; - if (this.answers.language === "typescript") { - extensions.push("ts"); - this.result.devDependencies.push("typescript-eslint"); - importContent += "import tseslint from \"typescript-eslint\";\n"; - exportContent += " ...tseslint.configs.recommended,\n"; + exportContent += config; } + if (languages.includes("jsonc")) { + const config = purpose === "syntax" + ? " {files: [\"**/*.jsonc\"], plugins: {json}, language: \"json/jsonc\"},\n" + : " {files: [\"**/*.jsonc\"], language: \"json/jsonc\", ...json.configs.recommended},\n"; - if (this.answers.framework === "vue") { - extensions.push("vue"); - this.result.devDependencies.push("eslint-plugin-vue"); - importContent += "import pluginVue from \"eslint-plugin-vue\";\n"; - exportContent += " ...pluginVue.configs[\"flat/essential\"],\n"; + exportContent += config; + } + if (languages.includes("json5")) { + const config = purpose === "syntax" + ? " {files: [\"**/*.json5\"], plugins: {json}, language: \"json/json5\"},\n" + : " {files: [\"**/*.json5\"], language: \"json/json5\", ...json.configs.recommended},\n"; - // https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser - if (this.answers.language === "typescript") { - exportContent += " {files: [\"**/*.vue\"], languageOptions: {parserOptions: {parser: tseslint.parser}}},\n"; - } + exportContent += config; } - if (this.answers.framework === "react") { - extensions.push("jsx"); + if (languages.includes("md")) { + this.result.devDependencies.push("@eslint/markdown"); + importContent += "import markdown from \"@eslint/markdown\";\n"; - if (this.answers.language === "typescript") { - extensions.push("tsx"); - } + if (purpose === "syntax") { + const config = this.answers.mdType === "commonmark" + ? " {files: [\"**/*.md\"], plugins: {markdown}, language: \"markdown/commonmark\"},\n" + : " {files: [\"**/*.md\"], plugins: {markdown}, language: \"markdown/gfm\"},\n"; + + exportContent += config; + } else if (purpose === "problems") { + exportContent += " ...markdown.configs.recommended,\n"; + + if (this.answers.mdType === "gfm") { - this.result.devDependencies.push("eslint-plugin-react"); - importContent += "import pluginReact from \"eslint-plugin-react\";\n"; - exportContent += " pluginReact.configs.flat.recommended,\n"; + // the default is commonmark + exportContent += " {files: [\"**/*.md\"], language: \"markdown/gfm\"},\n"; + } + } } if (this.answers.config) { @@ -243,24 +249,7 @@ export default [\n${exportContent}];`; log.info("The config that you've selected requires the following dependencies:\n"); log.info(this.result.devDependencies.join(", ")); - const questions = [{ - type: "toggle", - name: "executeInstallation", - message: "Would you like to install them now?", - enabled: "Yes", - disabled: "No", - initial: 1 - }, { - type: "select", - name: "packageManager", - message: "Which package manager do you want to use?", - initial: 0, - choices: ["npm", "yarn", "pnpm", "bun"], - skip() { - return this.state.answers.executeInstallation === false; - } - }]; - const { executeInstallation, packageManager } = (await enquirer.prompt(questions)); + const { executeInstallation, packageManager } = (await enquirer.prompt(installationQuestions)); const configPath = path.join(this.cwd, this.result.configFilename); if (executeInstallation === true) { diff --git a/lib/questions.js b/lib/questions.js new file mode 100644 index 0000000..377c53c --- /dev/null +++ b/lib/questions.js @@ -0,0 +1,100 @@ +/** + * @fileoverview all the questions for the quiz + * @author 唯然 + */ + +export const langQuestions = [{ + type: "multiselect", + name: "languages", + message: "What do you want to lint?", + choices: [ + { message: "JavaScript", name: "javascript" }, + { message: "JSON", name: "json" }, + { message: "JSON with comments", name: "jsonc" }, + { message: "JSON5", name: "json5" }, + { message: "Markdown", name: "md" } + ], + initial: 0 +}, { + type: "select", + name: "purpose", + message: "How would you like to use ESLint?", + initial: 1, + choices: [ + { message: "To check syntax only", name: "syntax" }, + { message: "To check syntax and find problems", name: "problems" } + ] +}]; + +export const jsQuestions = [ + { + type: "select", + name: "moduleType", + message: "What type of modules does your project use?", + initial: 0, + choices: [ + { message: "JavaScript modules (import/export)", name: "esm" }, + { message: "CommonJS (require/exports)", name: "commonjs" }, + { message: "None of these", name: "script" } + ] + }, + { + type: "select", + name: "framework", + message: "Which framework does your project use?", + initial: 0, + choices: [ + { message: "React", name: "react" }, + { message: "Vue.js", name: "vue" }, + { message: "None of these", name: "none" } + ] + }, + { + type: "toggle", + name: "useTs", + message: "Does your project use TypeScript?", + initial: 0 + }, + { + type: "multiselect", + name: "env", + message: "Where does your code run?", + hint: "(Press to select, to toggle all, to invert selection)", + initial: 0, + choices: [ + { message: "Browser", name: "browser" }, + { message: "Node", name: "node" } + ] + } +]; + +export const mdQuestions = [{ + type: "select", + name: "mdType", + message: "What flavor of Markdown do you want to lint?", + initial: 0, + choices: [ + { message: "CommonMark", name: "commonmark" }, + { message: "GitHub Flavored Markdown", name: "gfm" } + ] +}]; + +export const installationQuestions = [ + { + type: "toggle", + name: "executeInstallation", + message: "Would you like to install them now?", + enabled: "Yes", + disabled: "No", + initial: 1 + }, { + type: "select", + name: "packageManager", + message: "Which package manager do you want to use?", + initial: 0, + choices: ["npm", "yarn", "pnpm", "bun"], + skip() { + return this.state.answers.executeInstallation === false; + } + } +]; diff --git a/tests/__snapshots__/esm-javascript-json-problems b/tests/__snapshots__/esm-javascript-json-problems new file mode 100644 index 0000000..1a5e88c --- /dev/null +++ b/tests/__snapshots__/esm-javascript-json-problems @@ -0,0 +1,23 @@ +{ + "configContent": "import globals from "globals"; +import pluginJs from "@eslint/js"; +import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {languageOptions: { globals: globals.node }}, + pluginJs.configs.recommended, + {files: ["**/*.json"], language: "json/json", ...json.configs.recommended}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "globals", + "@eslint/js", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-json-problems b/tests/__snapshots__/esm-json-problems new file mode 100644 index 0000000..48948c9 --- /dev/null +++ b/tests/__snapshots__/esm-json-problems @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.json"], language: "json/json", ...json.configs.recommended}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-json-syntax b/tests/__snapshots__/esm-json-syntax new file mode 100644 index 0000000..341d54c --- /dev/null +++ b/tests/__snapshots__/esm-json-syntax @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.json"], plugins: {json}, language: "json/json"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-json5-problems b/tests/__snapshots__/esm-json5-problems new file mode 100644 index 0000000..dc1da37 --- /dev/null +++ b/tests/__snapshots__/esm-json5-problems @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.json5"], language: "json/json5", ...json.configs.recommended}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-json5-syntax b/tests/__snapshots__/esm-json5-syntax new file mode 100644 index 0000000..df28057 --- /dev/null +++ b/tests/__snapshots__/esm-json5-syntax @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.json5"], plugins: {json}, language: "json/json5"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-jsonc-problems b/tests/__snapshots__/esm-jsonc-problems new file mode 100644 index 0000000..da5dc57 --- /dev/null +++ b/tests/__snapshots__/esm-jsonc-problems @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.jsonc"], language: "json/jsonc", ...json.configs.recommended}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-jsonc-syntax b/tests/__snapshots__/esm-jsonc-syntax new file mode 100644 index 0000000..07a7989 --- /dev/null +++ b/tests/__snapshots__/esm-jsonc-syntax @@ -0,0 +1,18 @@ +{ + "configContent": "import json from "@eslint/json"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.jsonc"], plugins: {json}, language: "json/jsonc"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/json", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-markdown-commonmark-problems b/tests/__snapshots__/esm-markdown-commonmark-problems new file mode 100644 index 0000000..4f5f4c8 --- /dev/null +++ b/tests/__snapshots__/esm-markdown-commonmark-problems @@ -0,0 +1,18 @@ +{ + "configContent": "import markdown from "@eslint/markdown"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + ...markdown.configs.recommended, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/markdown", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-markdown-commonmark-syntax b/tests/__snapshots__/esm-markdown-commonmark-syntax new file mode 100644 index 0000000..0f827ff --- /dev/null +++ b/tests/__snapshots__/esm-markdown-commonmark-syntax @@ -0,0 +1,18 @@ +{ + "configContent": "import markdown from "@eslint/markdown"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.md"], plugins: {markdown}, language: "markdown/commonmark"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/markdown", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-markdown-gfm-problems b/tests/__snapshots__/esm-markdown-gfm-problems new file mode 100644 index 0000000..a3d9072 --- /dev/null +++ b/tests/__snapshots__/esm-markdown-gfm-problems @@ -0,0 +1,19 @@ +{ + "configContent": "import markdown from "@eslint/markdown"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + ...markdown.configs.recommended, + {files: ["**/*.md"], language: "markdown/gfm"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/markdown", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/__snapshots__/esm-markdown-gfm-syntax b/tests/__snapshots__/esm-markdown-gfm-syntax new file mode 100644 index 0000000..fa0de92 --- /dev/null +++ b/tests/__snapshots__/esm-markdown-gfm-syntax @@ -0,0 +1,18 @@ +{ + "configContent": "import markdown from "@eslint/markdown"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + {ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"]}, + {files: ["**/*.md"], plugins: {markdown}, language: "markdown/gfm"}, +];", + "configFilename": "eslint.config.js", + "devDependencies": [ + "eslint", + "@eslint/markdown", + ], + "installFlags": [ + "-D", + ], +} \ No newline at end of file diff --git a/tests/config-snapshots.spec.js b/tests/config-snapshots.spec.js index c277632..0f090e3 100644 --- a/tests/config-snapshots.spec.js +++ b/tests/config-snapshots.spec.js @@ -19,24 +19,37 @@ describe("generate config for esm projects", () => { purpose: ["syntax", "problems"], moduleType: ["esm", "commonjs", "script"], framework: ["react", "vue", "none"], - language: ["javascript", "typescript"], + useTs: [false, true], env: ["browser", "node"] }; - const inputs = []; + const inputs = [ + { name: "esm-json-syntax", answers: { languages: ["json"], purpose: "syntax" } }, + { name: "esm-json-problems", answers: { languages: ["json"], purpose: "problems" } }, + { name: "esm-json5-syntax", answers: { languages: ["json5"], purpose: "syntax" } }, + { name: "esm-json5-problems", answers: { languages: ["json5"], purpose: "problems" } }, + { name: "esm-jsonc-syntax", answers: { languages: ["jsonc"], purpose: "syntax" } }, + { name: "esm-jsonc-problems", answers: { languages: ["jsonc"], purpose: "problems" } }, + { name: "esm-markdown-commonmark-syntax", answers: { languages: ["md"], mdType: "commonmark", purpose: "syntax" } }, + { name: "esm-markdown-commonmark-problems", answers: { languages: ["md"], mdType: "commonmark", purpose: "problems" } }, + { name: "esm-markdown-gfm-syntax", answers: { languages: ["md"], mdType: "gfm", purpose: "syntax" } }, + { name: "esm-markdown-gfm-problems", answers: { languages: ["md"], mdType: "gfm", purpose: "problems" } }, + { name: "esm-javascript-json-problems", answers: { languages: ["javascript", "json"], purpose: "problems", moduleType: "esm", framework: "none", useTs: false, env: ["node"] } } + ]; // generate all possible combinations for (let i = 0; i < choices.purpose.length; i++) { for (let j = 0; j < choices.moduleType.length; j++) { for (let k = 0; k < choices.framework.length; k++) { - for (let m = 0; m < choices.language.length; m++) { + for (let m = 0; m < choices.useTs.length; m++) { inputs.push({ - name: `${choices.purpose[i]}-${choices.moduleType[j]}-${choices.framework[k]}-${choices.language[m]}`, + name: `${choices.purpose[i]}-${choices.moduleType[j]}-${choices.framework[k]}-${choices.useTs[m] ? "typescript" : "javascript"}`, answers: { + languages: ["javascript"], purpose: choices.purpose[i], moduleType: choices.moduleType[j], framework: choices.framework[k], - language: choices.language[m], + useTs: choices.useTs[m], env: ["browser", "node"] } }); @@ -59,7 +72,7 @@ describe("generate config for esm projects", () => { test("sub dir", () => { const sub = join(__filename, "../fixtures/esm-project/sub"); - const generator = new ConfigGenerator({ cwd: sub, answers: { purpose: "problems", moduleType: "esm", framework: "none", language: "javascript", env: ["node"] } }); + const generator = new ConfigGenerator({ cwd: sub, answers: { languages: ["javascript"], purpose: "problems", moduleType: "esm", framework: "none", useTs: false, env: ["node"] } }); generator.calc();