From 7224a49802f9006e3fb7213dd53a66e3de3eaf0d Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Fri, 13 Aug 2021 12:52:13 +0300 Subject: [PATCH 1/5] Add docs for ESLint plugin settings and rule options --- docs/basic-features/eslint.md | 19 +++++++++++++++++++ errors/no-html-link-for-pages.md | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/docs/basic-features/eslint.md b/docs/basic-features/eslint.md index a08fdc7e78821..c2111e3adc696 100644 --- a/docs/basic-features/eslint.md +++ b/docs/basic-features/eslint.md @@ -100,6 +100,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 using the `settings` property in your `.eslintrc`: + +```json +{ + "extends": "next", + "settings": { + "next": { + "rootDir": "/packages/my-app/" + } + } +} +``` + +We've designed `rootDir` to support a variety of configurations. The value 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 76c8fd8e7bd5b..b0f999092a08d 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`](https://nextjs.org/docs/basic-features/eslint.md#rootDir) setting in `eslint-plugin-next`, which this rule 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) From e23918808eddbe031faebffc39473b1549b6f2fe Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Tue, 17 Aug 2021 15:58:07 +0300 Subject: [PATCH 2/5] Update docs/basic-features/eslint.md Co-authored-by: Lee Robinson --- docs/basic-features/eslint.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-features/eslint.md b/docs/basic-features/eslint.md index c2111e3adc696..91964751c6e21 100644 --- a/docs/basic-features/eslint.md +++ b/docs/basic-features/eslint.md @@ -104,7 +104,7 @@ If you already have ESLint configured in your application, we recommend extendin #### `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 using the `settings` property in your `.eslintrc`: +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 { From 7671e1dbae83d4906249efd3194eb97f4de403a1 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Tue, 17 Aug 2021 15:58:12 +0300 Subject: [PATCH 3/5] Update docs/basic-features/eslint.md Co-authored-by: Lee Robinson --- docs/basic-features/eslint.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-features/eslint.md b/docs/basic-features/eslint.md index 91964751c6e21..0c026e58b9745 100644 --- a/docs/basic-features/eslint.md +++ b/docs/basic-features/eslint.md @@ -117,7 +117,7 @@ If you're using `eslint-plugin-next` in a project where Next.js isn't installed } ``` -We've designed `rootDir` to support a variety of configurations. The value can be a path (relative or absolute), a glob (i.e. `"/packages/*/"`), or an array of paths and/or globs. +`rootDir` can be a path (relative or absolute), a glob (i.e. `"/packages/*/"`), or an array of paths and/or globs. ## Linting Custom Directories From adc61bf036008da7aecf5d364f167b5ef5217fdc Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Tue, 17 Aug 2021 15:58:32 +0300 Subject: [PATCH 4/5] Update errors/no-html-link-for-pages.md Co-authored-by: Lee Robinson --- errors/no-html-link-for-pages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/errors/no-html-link-for-pages.md b/errors/no-html-link-for-pages.md index b0f999092a08d..87d4684724a45 100644 --- a/errors/no-html-link-for-pages.md +++ b/errors/no-html-link-for-pages.md @@ -48,7 +48,7 @@ This rule can normally locate your `pages` directory automatically. If you're working in a monorepo, we recommend configuring the [`rootDir`](https://nextjs.org/docs/basic-features/eslint.md#rootDir) setting in `eslint-plugin-next`, which this rule 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. +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 { From fcfd5784592a2b4035539a56ed412621cd69794d Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Tue, 17 Aug 2021 15:59:20 +0300 Subject: [PATCH 5/5] Update errors/no-html-link-for-pages.md Co-authored-by: Lee Robinson --- errors/no-html-link-for-pages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/errors/no-html-link-for-pages.md b/errors/no-html-link-for-pages.md index 87d4684724a45..0fe1449d69a9a 100644 --- a/errors/no-html-link-for-pages.md +++ b/errors/no-html-link-for-pages.md @@ -46,7 +46,7 @@ export default Home This rule can normally locate your `pages` directory automatically. -If you're working in a monorepo, we recommend configuring the [`rootDir`](https://nextjs.org/docs/basic-features/eslint.md#rootDir) setting in `eslint-plugin-next`, which this rule will use to locate your `pages` directory. +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.