@aak.lear/eslint-config
Version:
This package simplifies the initial setup of eslint and prettier. It installs and apply eslint-config-airbnb to your project, also resolves peerDependencies that are required for eslint-config-airbnb package.
62 lines (56 loc) • 1.49 kB
JavaScript
import { CONFIG_NAMES } from '../constants.js';
import picocolors from 'picocolors';
import prompts from 'prompts';
const { underline } = picocolors;
export const getPreferences = async () => {
const promptQuestions = [
{
type: 'multiselect',
name: 'configs',
message: 'Select preferred rule sets',
instructions: false,
choices: [
{
title: 'Base',
description: 'Core ESLint rules',
value: CONFIG_NAMES.base,
selected: true,
},
{
title: 'TypeScript',
description: `TypeScript rules with ${underline(
'@typescript-eslint',
)} plugin`,
value: CONFIG_NAMES.typescript,
selected: true,
},
{
title: 'React',
description: `React rules with ${underline('react')} and ${underline(
'react-hooks',
)} plugins`,
value: CONFIG_NAMES.react,
selected: true,
},
],
hint: 'Arrows – navigation, Space – select. Enter – submit',
},
{
type: 'toggle',
name: 'withPrettier',
message: 'Do you want to use prettier?',
initial: true,
active: 'yes',
inactive: 'no',
},
];
const { configs, withPrettier } = await prompts(promptQuestions);
if (!configs) {
process.exit(1);
}
return {
configs,
withPrettier,
withTypescript: configs.includes(CONFIG_NAMES.typescript),
};
};