Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: antfu/eslint-config
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.8.2
Choose a base ref
...
head repository: antfu/eslint-config
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.8.3
Choose a head ref
  • 3 commits
  • 15 files changed
  • 2 contributors

Commits on Mar 15, 2024

  1. docs: changed the default value for astro config and add description … (

    injurka authored Mar 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    daf20cc View commit details
  2. feat: improve cli (#420)

    Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
    injurka and antfu authored Mar 15, 2024
    Copy the full SHA
    bc13ba5 View commit details
  3. chore: release v2.8.3

    antfu committed Mar 15, 2024
    Copy the full SHA
    89fdb40 View commit details
Showing with 449 additions and 194 deletions.
  1. +8 −10 README.md
  2. +2 −2 package.json
  3. +22 −3 pnpm-lock.yaml
  4. +62 −8 src/cli/constants.ts
  5. +24 −8 src/cli/index.ts
  6. +93 −138 src/cli/run.ts
  7. +70 −0 src/cli/stages/update-eslint-files.ts
  8. +69 −0 src/cli/stages/update-package-json.ts
  9. +37 −0 src/cli/stages/update-vscode-settings.ts
  10. +16 −0 src/cli/types.ts
  11. +13 −0 src/cli/utils.ts
  12. +7 −0 src/factory.ts
  13. +7 −1 src/types.ts
  14. +4 −8 src/utils.ts
  15. +15 −16 test/cli.spec.ts
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -21,6 +21,14 @@
## Usage

### Wizard

We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config.

```bash
npx @antfu/eslint-config@latest
```

### Install

```bash
@@ -91,16 +99,6 @@ For example:
}
```

### Migration

We provided an experimental CLI tool to help you migrate from the legacy config to the new flat config.

```bash
npx @antfu/eslint-config@latest
```

Before running the migration, make sure to commit your unsaved changes first.

## VS Code support (auto fix)

Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@antfu/eslint-config",
"type": "module",
"version": "2.8.2",
"version": "2.8.3",
"packageManager": "pnpm@8.15.4",
"description": "Anthony's ESLint config",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -88,6 +88,7 @@
"dependencies": {
"@antfu/eslint-define-config": "^1.23.0-2",
"@antfu/install-pkg": "^0.3.1",
"@clack/prompts": "^0.7.0",
"@eslint-types/jsdoc": "46.8.2-1",
"@eslint-types/typescript-eslint": "^7.0.2",
"@eslint-types/unicorn": "^51.0.1",
@@ -117,7 +118,6 @@
"local-pkg": "^0.5.0",
"parse-gitignore": "^2.0.0",
"picocolors": "^1.0.0",
"prompts": "^2.4.2",
"toml-eslint-parser": "^0.9.3",
"vue-eslint-parser": "^9.4.2",
"yaml-eslint-parser": "^1.2.2",
25 changes: 22 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 62 additions & 8 deletions src/cli/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import c from 'picocolors'
import { devDependencies, version } from '../../package.json'
import pkgJson from '../../package.json'
import type { ExtraLibrariesOption, FrameworkOption, PromItem } from './types'

export const ARROW = c.cyan('→')
export const CHECK = c.green('✔')
export const CROSS = c.red('✘')
export const WARN = c.yellow('ℹ')

export const eslintVersion = devDependencies.eslint
export { version }
export { pkgJson }

export const vscodeSettingsString = `
// Enable the ESlint flat config support
@@ -53,3 +48,62 @@ export const vscodeSettingsString = `
"astro",
]
`

export const frameworkOptions: PromItem<FrameworkOption>[] = [
{
label: c.green('Vue'),
value: 'vue',
},
{
label: c.cyan('React'),
value: 'react',
},
{
label: c.red('Svelte'),
value: 'svelte',
},
{
label: c.magenta('Astro'),
value: 'astro',
},
{
label: c.blue('Slidev'),
value: 'slidev',
},
]

export const frameworks: FrameworkOption[] = frameworkOptions.map(({ value }) => (value))

export const extraOptions: PromItem<ExtraLibrariesOption>[] = [
{
hint: 'Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)',
label: c.red('Formatter'),
value: 'formatter',
},
{
label: c.cyan('UnoCSS'),
value: 'unocss',
},
]

export const extra: ExtraLibrariesOption[] = extraOptions.map(({ value }) => (value))

export const dependenciesMap = {
astro: [
'eslint-plugin-astro',
'astro-eslint-parser',
],
react: [
'eslint-plugin-react',
'eslint-plugin-react-hooks',
'eslint-plugin-react-refresh',
],
slidev: [
'prettier-plugin-slidev',
],
svelte: [
'eslint-plugin-svelte',
'svelte-eslint-parser',
],
vue: [],
} as const
32 changes: 24 additions & 8 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* eslint-disable no-console */
import process from 'node:process'
import c from 'picocolors'
import { hideBin } from 'yargs/helpers'
import yargs from 'yargs'
import * as p from '@clack/prompts'
import { run } from './run'
import { CROSS, version } from './constants'
import { pkgJson } from './constants'

function header() {
console.log(`\n${c.green(`@antfu/eslint-config `)}${c.dim(`v${version}`)}`)
// eslint-disable-next-line no-console
console.log('\n')
p.intro(`${c.green(`@antfu/eslint-config `)}${c.dim(`v${pkgJson.version}`)}`)
}

const instance = yargs(hideBin(process.argv))
@@ -17,24 +19,38 @@ const instance = yargs(hideBin(process.argv))
'*',
'Run the initialization or migration',
args => args
.option('yes', { alias: 'y', description: 'Skip prompts and use default values', type: 'boolean' })
.option('yes', {
alias: 'y',
description: 'Skip prompts and use default values',
type: 'boolean',
})
.option('template', {
alias: 't',
description: 'Use the framework template for optimal customization: vue / react / svelte / astro',
type: 'string',
})
.option('extra', {
alias: 'e',
array: true,
description: 'Use the extra utils: formatter / perfectionist / unocss',
type: 'string',
})
.help(),
async (args) => {
header()
console.log()
try {
await run(args)
}
catch (error) {
console.error(c.inverse(c.red(' Failed to migrate ')))
console.error(c.red(`${CROSS} ${String(error)}`))
p.log.error(c.inverse(c.red(' Failed to migrate ')))
p.log.error(c.red(` ${String(error)}`))
process.exit(1)
}
},
)
.showHelpOnFail(false)
.alias('h', 'help')
.version('version', version)
.version('version', pkgJson.version)
.alias('v', 'version')

// eslint-disable-next-line no-unused-expressions
Loading