diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index b39ae5bc06..0270a665c2 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -2,7 +2,7 @@ The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481). -- Total number of rules: 524 +- Total number of rules: 525 - Rules turned on by default: 123 **Legend for 'Fixable?' column:** @@ -13,7 +13,7 @@ The progress of all rule implementations is tracked [here](https://github.com/ox - ⚠️💡: a dangerous suggestion is available for this rule - 🚧: an auto-fix or suggestion is possible, but currently not implemented -## Correctness (176): +## Correctness (177): Code that is outright wrong or useless. @@ -130,6 +130,7 @@ Code that is outright wrong or useless. | [no-duplicate-head](/docs/guide/usage/linter/rules/nextjs/no-duplicate-head.html) | nextjs | ✅ | | | [no-head-element](/docs/guide/usage/linter/rules/nextjs/no-head-element.html) | nextjs | ✅ | | | [no-head-import-in-document](/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.html) | nextjs | ✅ | | +| [no-html-link-for-pages](/docs/guide/usage/linter/rules/nextjs/no-html-link-for-pages.html) | nextjs | ✅ | | | [no-img-element](/docs/guide/usage/linter/rules/nextjs/no-img-element.html) | nextjs | ✅ | 🚧 | | [no-page-custom-font](/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.html) | nextjs | ✅ | | | [no-script-component-in-head](/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.html) | nextjs | ✅ | | diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-html-link-for-pages.md b/src/docs/guide/usage/linter/rules/nextjs/no-html-link-for-pages.md new file mode 100644 index 0000000000..0372cb9696 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/nextjs/no-html-link-for-pages.md @@ -0,0 +1,99 @@ + + + + +# nextjs/no-html-link-for-pages + +
+ + This rule is turned on by default. + +
+ +### What it does + +Prevents the usage of `` elements to navigate between Next.js pages. + +### Why is this bad? + +Using `` elements for internal navigation in Next.js applications can cause: + +- Full page reloads instead of client-side navigation +- Loss of application state +- Slower navigation performance +- Broken prefetching capabilities + +Next.js provides the `` component from `next/link` for client-side navigation +between pages, which provides better performance and user experience. + +### Examples + +Examples of **incorrect** code for this rule: + +```jsx +function HomePage() { + return ( +
+ About Us + Contact +
+ ); +} +``` + +Examples of **correct** code for this rule: + +```jsx +import Link from "next/link"; + +function HomePage() { + return ( +
+ About Us + Contact +
+ ); +} +``` + +External links are allowed: + +```jsx +function HomePage() { + return ( +
+ External Link + Email + Phone +
+ ); +} +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny nextjs/no-html-link-for-pages --nextjs-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["nextjs"], + "rules": { + "nextjs/no-html-link-for-pages": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.md b/src/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.md index c3bd000b46..4c255db5ff 100644 --- a/src/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.md +++ b/src/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.md @@ -20,7 +20,7 @@ Prevent usage of `next/script` in `next/head` component. ### Why is this bad? The `next/script` component should not be used in a `next/head` component. -Instead move the`