diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecea360 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}] +charset = utf-8 +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..ad9bdac --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "semi": false, + "singleQuote": true, + "arrowParens": "avoid" +} diff --git a/bin/create-eslint-config.js b/bin/create-eslint-config.js index 2c858d1..3dc6bfe 100644 --- a/bin/create-eslint-config.js +++ b/bin/create-eslint-config.js @@ -5,7 +5,7 @@ import path from 'node:path' import process from 'node:process' import { bold, blue, yellow, red, green, dim } from 'kolorist' -import createConfig, { deepMerge, CREATE_ALIAS_SETTING_PLACEHOLDER } from '../index.js' +import createConfig, { deepMerge } from '../index.js' const require = createRequire(import.meta.url) const Enquirer = require('enquirer') @@ -43,6 +43,7 @@ const pkg = JSON.parse(rawPkgJson) // 1. check for existing config files // `.eslintrc.*`, `eslintConfig` in `package.json` +// FIXME: `eslint.config.*` // ask if wanna overwrite? // https://eslint.org/docs/latest/user-guide/configuring/configuration-files#configuration-file-formats @@ -89,55 +90,20 @@ if (pkg.eslintConfig) { } // 2. Check Vue -// Not detected? Choose from Vue 2 or 3 -// TODO: better support for 2.7 and vue-demi let vueVersion +// Not detected? Abort +// Vue 2? Abort because this tool only supports Vue 3 try { vueVersion = requireInCwd('vue/package.json').version console.info(dim(`Detected Vue.js version: ${vueVersion}`)) } catch (e) { - const anwsers = await prompt({ - type: 'select', - name: 'vueVersion', - message: 'Which Vue.js version do you use in the project?', - choices: [ - '3.x', - '2.x' - ] - }) - vueVersion = anwsers.vueVersion + // FIXME: warning that this only support Vue 3 } -// 3. Choose a style guide -// - Error Prevention (ESLint Recommended) -// - Standard -// - Airbnb -const { styleGuide } = await prompt({ - type: 'select', - name: 'styleGuide', - message: 'Which style guide do you want to follow?', - choices: [ - { - name: 'default', - message: 'ESLint Recommended (Error-Prevention-Only)' - }, - { - name: 'airbnb', - message: `Airbnb ${dim('(https://airbnb.io/javascript/)')}` - }, - { - name: 'standard', - message: `Standard ${dim('(https://standardjs.com/)')}` - } - ] -}) - // 4. Check TypeScript // 4.1 Allow JS? -// 4.2 Allow JS in Vue? -// 4.3 Allow JSX (TSX, if answered no in 4.1) in Vue? +// 4.2 Allow JS in Vue? Allow JSX (TSX, if answered no in 4.1) in Vue? let hasTypeScript = false -const additionalConfig = {} try { const tsVersion = requireInCwd('typescript/package.json').version console.info(dim(`Detected TypeScript version: ${tsVersion}`)) @@ -154,108 +120,54 @@ try { hasTypeScript = anwsers.hasTypeScript } -// TODO: we don't have more fine-grained sub-rulsets in `@vue/eslint-config-typescript` yet -if (hasTypeScript && styleGuide !== 'default') { - const { allowJsInVue } = await prompt({ - type: 'toggle', - disabled: 'No', - enabled: 'Yes', - name: 'allowJsInVue', - message: `Do you use plain ${yellow('