diff --git a/docs/basic-features/eslint.md b/docs/basic-features/eslint.md index dc68f5faed35cfc..dc4c587de73c885 100644 --- a/docs/basic-features/eslint.md +++ b/docs/basic-features/eslint.md @@ -101,6 +101,25 @@ Next.js provides an ESLint plugin, [`eslint-plugin-next`](https://www.npmjs.com/ 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. +### Custom Settings + +#### `rootDir` + +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`: + +```json +{ + "extends": "next", + "settings": { + "next": { + "rootDir": "/packages/my-app/" + } + } +} +``` + +`rootDir` can be a path (relative or absolute), a glob (i.e. `"/packages/*/"`), or an array of paths and/or globs. + ## Linting Custom Directories 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: diff --git a/errors/no-html-link-for-pages.md b/errors/no-html-link-for-pages.md index 76c8fd8e7bd5be7..0fe1449d69a9a39 100644 --- a/errors/no-html-link-for-pages.md +++ b/errors/no-html-link-for-pages.md @@ -40,6 +40,24 @@ function Home() { export default Home ``` +### Options + +#### `pagesDir` + +This rule can normally locate your `pages` directory automatically. + +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. + +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. + +```json +{ + "rules": { + "@next/next/no-html-link-for-pages": ["error", "/my-app/pages/"] + } +} +``` + ### Useful Links - [next/link API Reference](https://nextjs.org/docs/api-reference/next/link)