UNPKG

@mx-design/config-eslint9

Version:
78 lines (75 loc) 2.2 kB
import { intro, group, select, confirm, cancel } from '@clack/prompts'; import { compose } from '../utils/compose.mjs'; import '../utils/execPromise.mjs'; import '../utils/print.mjs'; import { TS, JS, REACT, VUE, NEXT, NEXT_JS, answer } from './constants.mjs'; import { handleEslint } from './handleEslint.mjs'; import { runner } from './runner.mjs'; function generateConfig(program) { program.command("config").description("generate eslint configuration file").action(async () => { intro("start to configure eslint9.x config file"); const config = await group( { languageType: () => select({ message: "Would you like to use Typescript in your project ?", initialValue: TS, options: [ { value: TS, label: TS }, { value: JS, label: JS } ] }), frameworksType: () => select({ message: "Which framework would you use in your project ?", initialValue: REACT, options: [ { value: REACT, label: REACT }, { value: VUE, label: VUE }, { value: NEXT, label: NEXT_JS } ] }), tailwind: () => confirm({ message: "Would you like to use TailWind CSS in your project ?", initialValue: true }), prettier: () => confirm({ message: "Would you like to use Prettier in your project ?", initialValue: true }) }, { onCancel: () => { cancel("Operation cancelled."); process.exit(0); } } ); const { languageType, frameworksType, tailwind, prettier } = config; compose([handleEslint, runner], { [answer]: { react: frameworksType === REACT, vue: frameworksType === VUE, nextjs: frameworksType === NEXT, javascript: languageType === JS, typescript: languageType === TS, tailwind, prettier } }); }); } export { generateConfig };