You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basic-features/eslint.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,25 @@ Next.js provides an ESLint plugin, [`eslint-plugin-next`](https://www.npmjs.com/
101
101
102
102
If you already have ESLint configured in your application, we recommend extending from this plugin directly instead of including `eslint-config-next` unless a few conditions are met. Refer to the [Recommended Plugin Ruleset](/docs/basic-features/eslint.md#recommended-plugin-ruleset) to learn more.
103
103
104
+
### Custom Settings
105
+
106
+
#### `rootDir`
107
+
108
+
If you're using `eslint-plugin-next` in a project where Next.js isn't installed in your root directory (such as a monorepo), you can tell `eslint-plugin-next` where to find your Next.js application using the `settings` property in your `.eslintrc`:
109
+
110
+
```json
111
+
{
112
+
"extends": "next",
113
+
"settings": {
114
+
"next": {
115
+
"rootDir": "/packages/my-app/"
116
+
}
117
+
}
118
+
}
119
+
```
120
+
121
+
`rootDir` can be a path (relative or absolute), a glob (i.e. `"/packages/*/"`), or an array of paths and/or globs.
122
+
104
123
## Linting Custom Directories
105
124
106
125
By default, Next.js will run ESLint for all files in the `pages/`, `components/`, and `lib/` directories. However, you can specify which directories using the `dirs` option in the `eslint` config in `next.config.js` for production builds:
Copy file name to clipboardExpand all lines: errors/no-html-link-for-pages.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,24 @@ function Home() {
40
40
exportdefaultHome
41
41
```
42
42
43
+
### Options
44
+
45
+
#### `pagesDir`
46
+
47
+
This rule can normally locate your `pages` directory automatically.
48
+
49
+
If you're working in a monorepo, we recommend configuring the [`rootDir`](/docs/basic-features/eslint.md#rootDir) setting in `eslint-plugin-next`, which `pagesDir` will use to locate your `pages` directory.
50
+
51
+
In some cases, you may also need to configure this rule directly by providing a `pages` directory. This can be a path or an array of paths.
0 commit comments