Skip to content

Release 1.6.0 #416

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 2 commits into from
Jul 7, 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
2 changes: 0 additions & 2 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ Arguments:
The supported syntax is the same as for .eslintignore and .gitignore files You should quote your patterns in order to avoid shell interpretation of glob patterns
- **`--no-ignore`** —
Disables excluding of files from .eslintignore files, **`--ignore-path`** flags and **`--ignore-pattern`** flags
- **`--symlinks`** —
Follow symbolic links. Oxlint ignores symbolic links by default.

## Handle Warnings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,35 @@ Prevent importing `next/document` outside of `pages/_document.js`.

### Why is this bad?

Importing `next/document` outside of `pages/_document.js` can cause
unexpected issues in your Next.js application.

### Examples

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

```javascript
```jsx
// `components/MyDocument.jsx`
import Document from "next/document";

class MyDocument extends Document {
// ...
}

export default MyDocument;
```

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

```javascript
```jsx
// `pages/_document.jsx`
import Document from "next/document";

class MyDocument extends Document {
// ...
}

export default MyDocument;
```

## How to use
Expand Down
35 changes: 32 additions & 3 deletions src/docs/guide/usage/linter/rules/nextjs/no-head-element.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,49 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

Prevent usage of `<head>` element.
Prevents the usage of the native `<head>` element inside a Next.js application.

### Why is this bad?

A `<head>` element can cause unexpected behavior in a Next.js application.
Use Next.js' built-in `next/head` component instead.

### Examples

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

```javascript
```jsx
function Index() {
return (
<>
<head>
<title>My page title</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</head>
</>
);
}

export default Index;
```

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

```javascript
```jsx
import Head from "next/head";

function Index() {
return (
<>
<Head>
<title>My page title</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
</>
);
}

export default Index;
```

## How to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,58 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

Prevents the usage of `next/head` inside a Next.js document.

### Why is this bad?

Importing `next/head` inside `pages/_document.js` can cause
unexpected issues in your Next.js application.

### Examples

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

```javascript
```jsx
import Document, { Html, Main, NextScript } from "next/document";
import Head from "next/head";

class MyDocument extends Document {
static async getInitialProps(ctx) {
// ...
}

render() {
return (
<Html>
<Head></Head>
</Html>
);
}
}

export default MyDocument;
```

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

```javascript
```jsx
import Document, { Head, Html, Main, NextScript } from "next/document";

class MyDocument extends Document {
static async getInitialProps(ctx) {
// ...
}

render() {
return (
<Html>
<Head></Head>
</Html>
);
}
}

export default MyDocument;
```

## How to use
Expand Down
36 changes: 33 additions & 3 deletions src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,48 @@ Prevent page-only custom fonts.
### Why is this bad?

- The custom font you're adding was added to a page - this only adds the font to the specific page and not the entire application.
- The custom font you're adding was added to a separate component within pages/_document.js - this disables automatic font optimization.
- The custom font you're adding was added to a separate component within `pages/_document.js` - this disables automatic font optimization.

### Examples

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

```javascript
```jsx
// pages/index.jsx
import Head from "next/head";
function IndexPage() {
return (
<Head>
<link
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
rel="stylesheet"
/>
</Head>
);
}
export default IndexPage;
```

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

```javascript
```jsx
// pages/_document.jsx
import NextDocument, { Head, Html } from "next/document";
class Document extends NextDocument {
render() {
return (
<Html>
<Head>
<link
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
rel="stylesheet"
/>
</Head>
</Html>
);
}
}
export default Document;
```

## How to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,47 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

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.

### Examples

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

```javascript
```jsx
import Head from "next/head";
import Script from "next/script";

export default function Index() {
return (
<Head>
<title>Next.js</title>
<Script src="/my-script.js" />
</Head>
);
}
```

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

```javascript
```jsx
import Head from "next/head";
import Script from "next/script";

export default function Index() {
return (
<>
<Head>
<title>Next.js</title>
</Head>
<Script src="/my-script.js" />
</>
);
}
```

## How to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,45 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

Prevent usage of `<title>` with `Head` component from `next/document`.

### Why is this bad?

A `<title>` element should only be used for any `<head>` code that is common for all pages.
Title tags should be defined at the page-level using `next/head` instead.

### Examples

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

```javascript
import { Head } from "next/document";

export function Home() {
return (
<div>
<Head>
<title>My page title</title>
</Head>
</div>
);
}
```

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

```javascript
import Head from "next/head";

export function Home() {
return (
<div>
<Head>
<title>My page title</title>
</Head>
</div>
);
}
```

## How to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

Require or disallow the `Record` type.
Choose between requiring either `Record` type or indexed signature types.

### Why is this bad?

Inconsistent style for indexed object types can harm readability in a project.

### Examples

Examples of **incorrect** code for this rule:
Examples of **incorrect** code for this rule with the default "record":

```ts
/*eslint consistent-indexed-object-style: ["error", "record"]*/

interface Foo {
[key: string]: unknown;
}
Expand All @@ -37,9 +39,32 @@ type Foo = {
Examples of **correct** code for this rule:

```ts
/*eslint consistent-indexed-object-style: ["error", "record"]*/

type Foo = Record<string, unknown>;
```

Examples of **incorrect** code for this rule with "index-signature":

```ts
/*eslint consistent-indexed-object-style: ["error", "index-signature"]*/

type Foo = Record<string, unknown>;
```

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

```ts
/*eslint consistent-indexed-object-style: ["error", "index-signature"]*/

interface Foo {
[key: string]: unknown;
}
type Foo = {
[key: string]: unknown;
};
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
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 "d7076b31d244d4074d86aa9c7c835612766bb08b";
return "54cf5cb2536e9f9c1d00c259d04fc4bcf0007683";
},
};