Skip to content

Commit ca2f719

Browse files
committed
docs: update
1 parent 89fcd25 commit ca2f719

File tree

18 files changed

+354
-33
lines changed

18 files changed

+354
-33
lines changed

docs/app.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
<script setup>
2+
import './style.css'
3+
24
useServerSeoMeta({
35
ogSiteName: 'Nuxt ESLint',
46
twitterCard: 'summary_large_image',
57
})
8+
69
useHead({
710
htmlAttrs: {
811
lang: 'en',
912
},
1013
})
11-
const links = [{
12-
label: 'Documentation',
13-
to: '/guide/getting-started',
14-
}, {
15-
label: 'Releases',
16-
to: 'https://github.com/nuxt/eslint/releases',
17-
target: '_blank',
18-
}]
14+
const links = [
15+
{
16+
label: 'Documentation',
17+
to: '/packages/module',
18+
},
19+
{
20+
label: 'FAQ',
21+
to: '/guide/faq',
22+
},
23+
{
24+
label: 'Releases',
25+
to: 'https://github.com/nuxt/eslint/releases',
26+
target: '_blank',
27+
},
28+
]
1929
const { data: files } = useLazyFetch('/api/search.json', {
2030
default: () => [],
2131
server: false,

docs/content/1.guide/0.getting-started.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: ESLint Module
3+
---
4+
5+
This module that generates project-aware [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) for Nuxt.
6+
7+
:::callout{icon="i-heroicons-light-bulb"}
8+
This module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new), which will be as default in ESLint v9.
9+
The legacy `.eslintrc` config is **not supported**. We highly recommand 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/configs), which will also lost some features like project-aware settings.
10+
:::
11+
12+
## Features
13+
14+
- [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), future-proof
15+
- Project-aware Nuxt-specific settings, [supports layers](https://nuxt.com/docs/getting-started/layers).
16+
- [Nuxt DevTools](https://github.com/nuxt/devtools) integration powered by [`eslint-flat-config-viewer`](https://github.com/antfu/eslint-flat-config-viewer)
17+
18+
## Quick Setup
19+
20+
```bash
21+
npm i -D @nuxt/eslint
22+
```
23+
24+
```ts [nuxt.config.ts]
25+
export default defineNuxtConfig({
26+
modules: [
27+
'@nuxt/eslint'
28+
],
29+
eslint: {
30+
// options here
31+
}
32+
})
33+
```
34+
35+
And create an `eslint.config.js` file under **your project root**, with the following content:
36+
37+
```js [eslint.config.js]
38+
import nuxt from './.nuxt/eslint.config.mjs'
39+
40+
export default [
41+
...nuxt,
42+
// your custom flat config here.
43+
]
44+
```
45+
46+
## Receipts
47+
48+
### Work with VS Code
49+
50+
Note that ESLint Flat config is not yet enabled by default in the [ESLint VS Code extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint), you will need to enable it via the `eslint.experimental.useFlatConfig` to get ESLint working in VS Code. (This is likely not needed after ESLint v9).
51+
52+
```json
53+
// .vscode/settings.json
54+
{
55+
// Enable the ESlint flat config support
56+
"eslint.experimental.useFlatConfig": true
57+
}
58+
```
59+
60+
### Use with Prettier
61+
62+
This module does not enable any stylistic/formatting rules by default. You can use Prettier alongside directly.
63+
64+
### Use with ESLint Stylistic
65+
66+
If instead, you prefer to use ESLint for formatting as well, we also integrated [ESLint Stylistic](https://eslint.style/) to make it easy. You can opt-in by setting `config.stylistic` to `true` in the `eslint` module options.
67+
68+
```ts [nuxt.config.ts]
69+
export default defineNuxtConfig({
70+
modules: [
71+
'@nuxt/eslint'
72+
],
73+
eslint: {
74+
config: {
75+
stylistic: true // <---
76+
}
77+
}
78+
})
79+
```
80+
81+
You can also pass an object to customize the rules:
82+
83+
```ts [nuxt.config.ts]
84+
export default defineNuxtConfig({
85+
modules: [
86+
'@nuxt/eslint'
87+
],
88+
eslint: {
89+
config: {
90+
stylistic: {
91+
indent: 'tab',
92+
semi: true,
93+
// ...
94+
}
95+
}
96+
}
97+
})
98+
```
99+
100+
Learn more about all the available options in the [ESLint Stylistic documentation](https://eslint.style/guide/config-presets#configuration-factory).
101+
102+
### Dev Server Checker
103+
104+
// TODO:
105+
106+
### Use with Custom Config Presets
107+
108+
By default, this module installs the JS, TS and Vue plugins with their recommended rules. This might already been covered by your config presets. You can disable the default setup by disable `standalone` option.
109+
110+
```ts [nuxt.config.ts]
111+
export default defineNuxtConfig({
112+
modules: [
113+
'@nuxt/eslint'
114+
],
115+
eslint: {
116+
config: {
117+
standalone: false // <---
118+
}
119+
}
120+
})
121+
```
122+
123+
This will make this module only generate the Nuxt-specific rules and disables, so that you can merge it with your own config presets.
124+
125+
For example, with [`@antfu/eslint-config`](https://github.com/antfu/eslint-config):
126+
127+
```js
128+
// eslint.config.js
129+
import antfu from '@antfu/eslint-config'
130+
import nuxt from './.nuxt/eslint.config.mjs'
131+
132+
export default antfu(
133+
{
134+
// ...@antfu/eslint-config options,
135+
},
136+
// Add the Nuxt rules
137+
nuxt,
138+
// ...your other rules
139+
)
140+
```
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: '@nuxt/eslint-config'
3+
---
4+
5+
A shared ESLint config for Nuxt 3 projects.
6+
7+
:::callout{icon="i-heroicons-light-bulb"}
8+
We recommand to use directly the [ESLint Module](/packages/module) that will provide project-aware ESLint config and Nuxt DevTools integration on top of this config.
9+
:::
10+
11+
## Config Formats
12+
13+
This package provides two different ESLint configs:
14+
15+
- [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).
16+
- [Legacy Config](#legacy-config-format) - Opinionated, Static, config for the legacy `.eslintrc` format.
17+
18+
## Flat Config Format
19+
20+
1. Install this package and `eslint` in your `devDependencies`.
21+
22+
```bash
23+
npm i -D @nuxt/eslint-plugin eslint
24+
yarn add -D @nuxt/eslint-plugin eslint
25+
pnpm add -D @nuxt/eslint-plugin eslint
26+
```
27+
28+
2. Import the config factory function from `@nuxt/eslint-plugin/flat` entry in your `eslint.config.js`:
29+
30+
```js
31+
// eslint.config.js
32+
import createConfigForNuxt from '@nuxt/eslint-plugin/flat'
33+
34+
export default createConfigForNuxt({
35+
// options here
36+
})
37+
```
38+
39+
40+
You might also want to add a script entry to your `package.json:
41+
42+
```json
43+
{
44+
"scripts": {
45+
"lint": "eslint ."
46+
}
47+
}
48+
```
49+
50+
## Legacy Config Format
51+
52+
1. Install this package and `eslint` in your `devDependencies`.
53+
54+
```bash
55+
npm i -D @nuxt/eslint-plugin eslint
56+
yarn add -D @nuxt/eslint-plugin eslint
57+
pnpm add -D @nuxt/eslint-plugin eslint
58+
```
59+
60+
2. Extend the default Nuxt config by creating an `.eslintrc.cjs`:
61+
62+
```js
63+
module.exports = {
64+
root: true,
65+
extends: ["@nuxt/eslint-plugin"],
66+
};
67+
```
68+
69+
You might also want to add a script entry to your `package.json`:
70+
71+
```json
72+
{
73+
"scripts": {
74+
"lint": "eslint ."
75+
}
76+
}
77+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: '@nuxt/eslint-plugin'
3+
---
4+
5+
ESLint plugin of additional rules for Nuxt 3.
6+
7+
:::callout{icon="i-heroicons-light-bulb"}
8+
Usually, you don't need to use this package directly. It's already included in the [ESLint Module](/packages/module) and the [ESLint Config](/packages/config).
9+
:::
10+
11+
## Rules
12+
13+
### `nuxt/no-env-in-hooks`

docs/content/1.packages/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
navigation.title: Packages
2+
navigation.icon: i-ph-package-duotone

docs/content/2.guide/0.faq.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: FAQ
3+
description: Frequently asked questions about ESLint integration in Nuxt
4+
---
5+
6+
This project is composed of multiple packages for different level of ESLint integration.
7+
8+
### What to use?
9+
10+
For new projects, we highly recommend using the [ESLint Module](/packages/module) which provides a project-aware ESLint flat config and being future-proof.
11+
12+
If you still use the legacy `.eslintrc` format, you can use the [ESLint Config](/packages/config) package to manually configure your ESLint settings. We would recommend you to migrate to the flat config format if possible.
13+
14+
If you are maintaining your custom ESLint config and want a low-level setup, you can use the [ESLint Plugin](/packages/plugin) package enable some Nuxt-specific rules to your config.
15+
16+
### Packages Disambiguation
17+
18+
Due to the historical reasons, we have quite a few packages for different ESLint integration.
19+
20+
Here's a table to help you understand the differences:
21+
22+
<div class="packages-disambiguation-table">
23+
24+
| Package | Tags |
25+
| --- | --- |
26+
| [`@nuxt/eslint`](/packages/module) <br> All-in-one ESLint module for Nuxt 3 | [`nuxt3`]{.badge-nuxt3} [`flat-config`]{.badge-flat} [`recommended`]{.badge-recommend} |
27+
| [`@nuxt/eslint-config`](/packages/config) <br> Shared config for Nuxt 3, for both flat config and legacy config. <br>Unopinionated but customizable. | [`nuxt3`]{.badge-nuxt3} [`flat-config`]{.badge-flat} [`legacy-config`]{.badge-legacy} |
28+
| [`@nuxt/eslint-plugin`](/packages/plugin) <br> Low-level ESLint plugin for Nuxt 3. | [`nuxt3`]{.badge-nuxt3} |
29+
| [`@nuxtjs/eslint-module`](/packages/module) <br> Runs ESLint check along the dev server. <br> Now merged into `@nuxt/eslint` module. | [`nuxt3`]{.badge-nuxt3} [`nuxt2`]{.badge-nuxt2} [`deprecated`]{.badge-legacy} |
30+
| [`@nuxtjs/eslint-config`](/packages/config) <span class="opacity-50">(note the `@nuxtjs` scope)</span> <br> Shared config for Nuxt 2, opinionated with stylistic rules.<br> Maintainance mode, no long have active developments. | [`nuxt2`]{.badge-nuxt2} [`legacy-config`]{.badge-legacy} |
31+
| [`@nuxtjs/eslint-plugin-typescript`](/packages/plugin) <span class="opacity-50">(note the `@nuxtjs` scope)</span> <br> TypeScript integrations for `@nuxtjs/eslint-config`.<br> Maintainance mode, no long have active developments. | [`nuxt2`]{.badge-nuxt2} [`legacy-config`]{.badge-legacy} |
32+
33+
</div>

docs/content/2.guide/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
navigation.title: Guide
2+
navigation.icon: i-ph-book-bookmark-duotone
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: '@nuxtjs/eslint-config'
3+
---

docs/content/3.legacy/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
navigation.title: Legacy Packages
2+
navigation.icon: i-ph-archive-duotone

0 commit comments

Comments
 (0)