Skip to content
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

refactor(linter): fix indentation in nextjs/no_script_component_in_head rule #5338

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
38 changes: 20 additions & 18 deletions crates/oxc_linter/src/rules/nextjs/no_script_component_in_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,33 @@ fn test() {
use crate::tester::Tester;

let pass = vec![
r#"import Script from "next/script";
const Head = ({children}) => children
r#"
import Script from "next/script";
const Head = ({children}) => children

export default function Index() {
return (
export default function Index() {
return (
<Head>
<Script></Script>
<Script></Script>
</Head>
);
}
"#,
);
}
"#,
];

let fail = vec![
r#"
import Head from "next/head";
import Script from "next/script";

export default function Index() {
return (
<Head>
<Script></Script>
</Head>
);
}"#,
import Head from "next/head";
import Script from "next/script";

export default function Index() {
return (
<Head>
<Script></Script>
</Head>
);
}
"#,
];

Tester::new(NoScriptComponentInHead::NAME, pass, fail).test_and_snapshot();
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_linter/src/snapshots/no_script_component_in_head.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-next(no-script-component-in-head): Prevent usage of `next/script` in `next/head` component.
╭─[no_script_component_in_head.tsx:7:17]
6 │ return (
7 │ <Head>
· ────
8 │ <Script></Script>
╭─[no_script_component_in_head.tsx:7:13]
6 │ return (
7 │ <Head>
· ────
8 │ <Script></Script>
╰────
help: See https://nextjs.org/docs/messages/no-script-component-in-head