Skip to content

Commit c47a6c3

Browse files
authored
Release 1.6.0 (#416)
1 parent 7a02f71 commit c47a6c3

9 files changed

+214
-17
lines changed

src/docs/guide/usage/linter/generated-cli.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ Arguments:
8989
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
9090
- **`--no-ignore`** —
9191
Disables excluding of files from .eslintignore files, **`--ignore-path`** flags and **`--ignore-pattern`** flags
92-
- **`--symlinks`** —
93-
Follow symbolic links. Oxlint ignores symbolic links by default.
9492

9593
## Handle Warnings
9694

src/docs/guide/usage/linter/rules/nextjs/no-document-import-in-page.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,35 @@ Prevent importing `next/document` outside of `pages/_document.js`.
1919

2020
### Why is this bad?
2121

22+
Importing `next/document` outside of `pages/_document.js` can cause
23+
unexpected issues in your Next.js application.
24+
2225
### Examples
2326

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

26-
```javascript
29+
```jsx
30+
// `components/MyDocument.jsx`
31+
import Document from "next/document";
32+
33+
class MyDocument extends Document {
34+
// ...
35+
}
36+
37+
export default MyDocument;
2738
```
2839

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

31-
```javascript
42+
```jsx
43+
// `pages/_document.jsx`
44+
import Document from "next/document";
45+
46+
class MyDocument extends Document {
47+
// ...
48+
}
49+
50+
export default MyDocument;
3251
```
3352

3453
## How to use

src/docs/guide/usage/linter/rules/nextjs/no-head-element.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,49 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

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

2020
### Why is this bad?
2121

22+
A `<head>` element can cause unexpected behavior in a Next.js application.
23+
Use Next.js' built-in `next/head` component instead.
24+
2225
### Examples
2326

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

26-
```javascript
29+
```jsx
30+
function Index() {
31+
return (
32+
<>
33+
<head>
34+
<title>My page title</title>
35+
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
36+
</head>
37+
</>
38+
);
39+
}
40+
41+
export default Index;
2742
```
2843

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

31-
```javascript
46+
```jsx
47+
import Head from "next/head";
48+
49+
function Index() {
50+
return (
51+
<>
52+
<Head>
53+
<title>My page title</title>
54+
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
55+
</Head>
56+
</>
57+
);
58+
}
59+
60+
export default Index;
3261
```
3362

3463
## How to use

src/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,58 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

18+
Prevents the usage of `next/head` inside a Next.js document.
19+
1820
### Why is this bad?
1921

22+
Importing `next/head` inside `pages/_document.js` can cause
23+
unexpected issues in your Next.js application.
24+
2025
### Examples
2126

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

24-
```javascript
29+
```jsx
30+
import Document, { Html, Main, NextScript } from "next/document";
31+
import Head from "next/head";
32+
33+
class MyDocument extends Document {
34+
static async getInitialProps(ctx) {
35+
// ...
36+
}
37+
38+
render() {
39+
return (
40+
<Html>
41+
<Head></Head>
42+
</Html>
43+
);
44+
}
45+
}
46+
47+
export default MyDocument;
2548
```
2649

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

29-
```javascript
52+
```jsx
53+
import Document, { Head, Html, Main, NextScript } from "next/document";
54+
55+
class MyDocument extends Document {
56+
static async getInitialProps(ctx) {
57+
// ...
58+
}
59+
60+
render() {
61+
return (
62+
<Html>
63+
<Head></Head>
64+
</Html>
65+
);
66+
}
67+
}
68+
69+
export default MyDocument;
3070
```
3171

3272
## How to use

src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,48 @@ Prevent page-only custom fonts.
2020
### Why is this bad?
2121

2222
- 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.
23-
- The custom font you're adding was added to a separate component within pages/_document.js - this disables automatic font optimization.
23+
- The custom font you're adding was added to a separate component within `pages/_document.js` - this disables automatic font optimization.
2424

2525
### Examples
2626

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

29-
```javascript
29+
```jsx
30+
// pages/index.jsx
31+
import Head from "next/head";
32+
function IndexPage() {
33+
return (
34+
<Head>
35+
<link
36+
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
37+
rel="stylesheet"
38+
/>
39+
</Head>
40+
);
41+
}
42+
export default IndexPage;
3043
```
3144

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

34-
```javascript
47+
```jsx
48+
// pages/_document.jsx
49+
import NextDocument, { Head, Html } from "next/document";
50+
class Document extends NextDocument {
51+
render() {
52+
return (
53+
<Html>
54+
<Head>
55+
<link
56+
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
57+
rel="stylesheet"
58+
/>
59+
</Head>
60+
</Html>
61+
);
62+
}
63+
}
64+
export default Document;
3565
```
3666

3767
## How to use

src/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,47 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

18+
Prevent usage of `next/script` in `next/head` component.
19+
1820
### Why is this bad?
1921

22+
The `next/script` component should not be used in a `next/head` component.
23+
Instead move the`<Script />`component outside of`<Head>` instead.
24+
2025
### Examples
2126

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

24-
```javascript
29+
```jsx
30+
import Head from "next/head";
31+
import Script from "next/script";
32+
33+
export default function Index() {
34+
return (
35+
<Head>
36+
<title>Next.js</title>
37+
<Script src="/my-script.js" />
38+
</Head>
39+
);
40+
}
2541
```
2642

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

29-
```javascript
45+
```jsx
46+
import Head from "next/head";
47+
import Script from "next/script";
48+
49+
export default function Index() {
50+
return (
51+
<>
52+
<Head>
53+
<title>Next.js</title>
54+
</Head>
55+
<Script src="/my-script.js" />
56+
</>
57+
);
58+
}
3059
```
3160

3261
## How to use

src/docs/guide/usage/linter/rules/nextjs/no-title-in-document-head.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,45 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

18+
Prevent usage of `<title>` with `Head` component from `next/document`.
19+
1820
### Why is this bad?
1921

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

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

2429
```javascript
30+
import { Head } from "next/document";
31+
32+
export function Home() {
33+
return (
34+
<div>
35+
<Head>
36+
<title>My page title</title>
37+
</Head>
38+
</div>
39+
);
40+
}
2541
```
2642

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

2945
```javascript
46+
import Head from "next/head";
47+
48+
export function Home() {
49+
return (
50+
<div>
51+
<Head>
52+
<title>My page title</title>
53+
</Head>
54+
</div>
55+
);
56+
}
3057
```
3158

3259
## How to use

src/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

18-
Require or disallow the `Record` type.
18+
Choose between requiring either `Record` type or indexed signature types.
1919

2020
### Why is this bad?
2121

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

2424
### Examples
2525

26-
Examples of **incorrect** code for this rule:
26+
Examples of **incorrect** code for this rule with the default "record":
2727

2828
```ts
29+
/*eslint consistent-indexed-object-style: ["error", "record"]*/
30+
2931
interface Foo {
3032
[key: string]: unknown;
3133
}
@@ -37,9 +39,32 @@ type Foo = {
3739
Examples of **correct** code for this rule:
3840

3941
```ts
42+
/*eslint consistent-indexed-object-style: ["error", "record"]*/
43+
44+
type Foo = Record<string, unknown>;
45+
```
46+
47+
Examples of **incorrect** code for this rule with "index-signature":
48+
49+
```ts
50+
/*eslint consistent-indexed-object-style: ["error", "index-signature"]*/
51+
4052
type Foo = Record<string, unknown>;
4153
```
4254

55+
Examples of **correct** code for this rule:
56+
57+
```ts
58+
/*eslint consistent-indexed-object-style: ["error", "index-signature"]*/
59+
60+
interface Foo {
61+
[key: string]: unknown;
62+
}
63+
type Foo = {
64+
[key: string]: unknown;
65+
};
66+
```
67+
4368
## How to use
4469

4570
To **enable** this rule in the CLI or using the config file, you can use:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
load() {
3-
return "d7076b31d244d4074d86aa9c7c835612766bb08b";
3+
return "54cf5cb2536e9f9c1d00c259d04fc4bcf0007683";
44
},
55
};

0 commit comments

Comments
 (0)