Skip to content

Release 1.7.0 #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand All @@ -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.

Expand Down Expand Up @@ -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 | ✅ | |
Expand Down
99 changes: 99 additions & 0 deletions src/docs/guide/usage/linter/rules/nextjs/no-html-link-for-pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/nextjs/no_html_link_for_pages.rs`;
</script>

# nextjs/no-html-link-for-pages <Badge type="info" text="Correctness" />

<div class="rule-meta">
<Alert class="default-on" type="success">
<span class="emoji">✅</span> This rule is turned on by default.
</Alert>
</div>

### What it does

Prevents the usage of `<a>` elements to navigate between Next.js pages.

### Why is this bad?

Using `<a>` 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 `<Link />` 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 (
<div>
<a href="/about">About Us</a>
<a href="/contact">Contact</a>
</div>
);
}
```

Examples of **correct** code for this rule:

```jsx
import Link from "next/link";

function HomePage() {
return (
<div>
<Link href="/about">About Us</Link>
<Link href="/contact">Contact</Link>
</div>
);
}
```

External links are allowed:

```jsx
function HomePage() {
return (
<div>
<a href="https://example.com">External Link</a>
<a href="mailto:[email protected]">Email</a>
<a href="tel:+1234567890">Phone</a>
</div>
);
}
```

## 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

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Original file line number Diff line number Diff line change
Expand Up @@ -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`<Script />`component outside of`<Head>` instead.
Instead move the `<Script />` component outside of `<Head>` instead.

### Examples

Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/version.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
load() {
return "54cf5cb2536e9f9c1d00c259d04fc4bcf0007683";
return "21e8f0a6a37f336c4a4976c308205e1cda504e5b";
},
};