Skip to content

Commit

Permalink
feat!: drop legacy configs, requires ESLint v9 and ESM (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Jan 30, 2025
1 parent ac4afef commit cbcd674
Show file tree
Hide file tree
Showing 46 changed files with 64 additions and 3,737 deletions.
2 changes: 1 addition & 1 deletion docs/content/1.packages/0.module.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All-in-one ESLint integration for Nuxt. It generates a project-aware [ESLint fla
:::callout{icon="i-ph-lightbulb-duotone"}
This module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) which is the [default format since ESLint v9](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/). Flat config is supported since ESLint v8.45.0 so you can use any version of ESLint later than that. We recommend you to use the latest version of ESLint to get the best experience.
<br><br>
The legacy `.eslintrc` config is **not supported** by this module. We highly recommend you to migrate over the flat config to be future-proof. If you still want to use the legacy format, you might need to manually config with [`@nuxt/eslint-config`](/packages/config), which will missing some features like project-aware settings tho.
The legacy `.eslintrc` config is **not supported** by this module. We highly recommend you to migrate over the flat config to be future-proof.
:::

::read-more
Expand Down
63 changes: 8 additions & 55 deletions docs/content/1.packages/1.config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ Source code on GitHub
::


## Config Formats
## Configurations

This package provides two different ESLint configs:

- [Flat Config](#flat-config-format) - Customizable future-proof config for the [new flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new).
- [Legacy Config](#legacy-config-format) - Unopinionated static config for the legacy `.eslintrc` format.

## Flat Config Format

The flat config format is the future of ESLint and is designed to be more flexible and project-aware. The entry `@nuxt/eslint-config/flat` provides a factory function to create a project-aware ESLint config for Nuxt 3 projects. It is unopinionated by default but customizable by passing options to the factory function. Used by [`@nuxt/eslint`](/packages/module) module to generate project-aware ESLint config.
Since version v1.0, we provide in the flat config format. The entry `@nuxt/eslint-config` provides a factory function to create a project-aware ESLint config for Nuxt 3 projects. It is unopinionated by default but customizable by passing options to the factory function. Used by [`@nuxt/eslint`](/packages/module) module to generate project-aware ESLint config.

1. Install this package and `eslint` in your `devDependencies`.

Expand All @@ -46,10 +39,10 @@ bun add -D @nuxt/eslint-config eslint
```
::

2. Import the config factory function from `@nuxt/eslint-config/flat` entry in your `eslint.config.mjs`:
2. Import the config factory function from `@nuxt/eslint-config` entry in your `eslint.config.mjs`:

```js [eslint.config.mjs]
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { createConfigForNuxt } from '@nuxt/eslint-config'

export default createConfigForNuxt({
// options here
Expand All @@ -71,7 +64,7 @@ You might also want to add a script entry to your `package.json`:
Note that `createConfigForNuxt()` returns a chainable [`FlatConfigComposer` instance](https://github.com/antfu/eslint-flat-config-utils#composer) from [`eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils) which allows you to manipulate the ESLint flat config with ease. If you want to combine with other configs, you can use the `.append()` method:

```js [eslint.config.mjs]
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { createConfigForNuxt } from '@nuxt/eslint-config'

export default createConfigForNuxt({
// options here
Expand Down Expand Up @@ -100,7 +93,7 @@ This feature is experimental and may change in the future.
:::

```js [eslint.config.mjs]
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { createConfigForNuxt } from '@nuxt/eslint-config'

export default createConfigForNuxt({
features: {
Expand All @@ -114,7 +107,7 @@ This will enable rules with `unicorn`, `regexp` and `jsdoc` plugins, to ensure y
You can also turn them off individually by providing an object with the rule names set to `false`:

```js [eslint.config.mjs]
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { createConfigForNuxt } from '@nuxt/eslint-config'

export default createConfigForNuxt({
features: {
Expand All @@ -125,52 +118,12 @@ export default createConfigForNuxt({
})
```

## Legacy Config Format

The legacy config configures TypeScript and Vue integration for ESLint. It is unopinionated and static, and does not contains stylistic rules or project-aware settings.

1. Install this package and `eslint` in your `devDependencies`.

::code-group
```bash [yarn]
yarn add --dev @nuxt/eslint-config eslint
```
```bash [npm]
npm install --save-dev @nuxt/eslint-config eslint
```
```bash [pnpm]
pnpm add -D @nuxt/eslint-config eslint
```
```bash [bun]
bun add -D @nuxt/eslint-config eslint
```
::

2. Extend the default Nuxt config by creating an `.eslintrc.cjs`:

```js [.eslintrc.cjs]
module.exports = {
root: true,
extends: ["@nuxt/eslint-config"],
};
```

You might also want to add a script entry to your `package.json`:

```json [package.json]
{
"scripts": {
"lint": "eslint ."
}
}
```

## ESLint Stylistic

Similar to the [ESLint Module](https://eslint.nuxt.com/packages/module#eslint-stylistic), you can opt-in by setting `stylistic` to `true` in the `features` module options.

```js [eslint.config.mjs]
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { createConfigForNuxt } from '@nuxt/eslint-config'

export default createConfigForNuxt({
features: {
Expand Down
5 changes: 0 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export default createConfigForNuxt({
},
})
.append(
{
ignores: [
'packages-legacy/**',
],
},
{
files: ['docs/**/*.vue'],
rules: {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"build": "pnpm run -r build",
"stub": "pnpm run -r stub",
"release": "bumpp \"package.json\" \"packages/**/package.json\" && pnpm publish -r",
"release:legacy": "bumpp \"packages-legacy/**/package.json\" --commit \"chore: release @nuxtjs/eslint-config@%s\" --no-tag && pnpm publish -r",
"test": "vitest run",
"play": "pnpm -C playground run play:dev",
"lint": "eslint .",
Expand Down
196 changes: 0 additions & 196 deletions packages-legacy/nuxt2-eslint-config-typescript/CHANGELOG.md

This file was deleted.

9 changes: 0 additions & 9 deletions packages-legacy/nuxt2-eslint-config-typescript/README.md

This file was deleted.

47 changes: 0 additions & 47 deletions packages-legacy/nuxt2-eslint-config-typescript/index.js

This file was deleted.

Loading

0 comments on commit cbcd674

Please sign in to comment.