diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index 1addaa0b69..bba097ffb3 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -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 diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-document-import-in-page.md b/src/docs/guide/usage/linter/rules/nextjs/no-document-import-in-page.md index 66a5c336dd..3beb7e0a00 100644 --- a/src/docs/guide/usage/linter/rules/nextjs/no-document-import-in-page.md +++ b/src/docs/guide/usage/linter/rules/nextjs/no-document-import-in-page.md @@ -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 diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-head-element.md b/src/docs/guide/usage/linter/rules/nextjs/no-head-element.md index 62725af81a..df3544527c 100644 --- a/src/docs/guide/usage/linter/rules/nextjs/no-head-element.md +++ b/src/docs/guide/usage/linter/rules/nextjs/no-head-element.md @@ -15,20 +15,49 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin ### What it does -Prevent usage of `` element. +Prevents the usage of the native `` element inside a Next.js application. ### Why is this bad? +A `` 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 ( + <> + + My page title + + + + ); +} + +export default Index; ``` Examples of **correct** code for this rule: -```javascript +```jsx +import Head from "next/head"; + +function Index() { + return ( + <> + + My page title + + + + ); +} + +export default Index; ``` ## How to use diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.md b/src/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.md index 4f95f211be..183dcff55b 100644 --- a/src/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.md +++ b/src/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.md @@ -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 ( + + + + ); + } +} + +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 ( + + + + ); + } +} + +export default MyDocument; ``` ## How to use diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md b/src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md index fb0c31b0aa..8f75b3d167 100644 --- a/src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md +++ b/src/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.md @@ -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 ( + + + + ); +} +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 ( + + + + + + ); + } +} +export default Document; ``` ## How to use 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 ce21560559..c3bd000b46 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 @@ -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`