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

Docs: Update eslint document for Script Component on strategy 'beforeInteractive' #50096

Closed
devjiwonchoi opened this issue May 20, 2023 · 2 comments · Fixed by #50261
Closed
Labels
Documentation Related to Next.js' official documentation.

Comments

@devjiwonchoi
Copy link
Member

devjiwonchoi commented May 20, 2023

What is the improvement or update you wish to see?

Since we moved on from Page Router to App Router, eslint should not show a lint about pages/_document.js if it is on App Router.

When using the Script component inside page.tsx with strategy beforeInteractive,

next/script's beforeInteractive strategy should not be used outside of pages/_document.js.

The example from the docs for Script Components in App Router shows that the Script Component is in the page.tsx.

Is there any context that might help us understand?

Screenshot 2023-05-20 at 11 44 28 PM

Screenshot 2023-05-20 at 11 02 55 PM

Screenshot 2023-05-20 at 11 02 25 PM

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/components/script#strategy

@devjiwonchoi devjiwonchoi added the Documentation Related to Next.js' official documentation. label May 20, 2023
@devjiwonchoi devjiwonchoi reopened this May 20, 2023
@devjiwonchoi
Copy link
Member Author

Found this PR has been merged but the lint is still on going.

@kodiakhq kodiakhq bot closed this as completed in #50261 May 26, 2023
kodiakhq bot pushed a commit that referenced this issue May 26, 2023
## Why?
```
src/app/layout.tsx
```
![code](https://github.com/vercel/next.js/assets/120007119/3cc991f8-a96d-4ffb-9f84-4dfdbcac5318)

**eslint[@next/next/no-before-interactive-script-outside-document](https://nextjs.org/docs/messages/no-before-interactive-script-outside-document)**
> `next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. 

## How?
- Possibility of pathname starts with "/" on OS X and Linux, so added condition to check file path starting with "/"
- e.g. "/src/app" or "/app"
- Added test code



Passed 
- `pnpm build && pnpm lint`
- `pnpm jest test/unit/eslint-plugin-next/no-before-interactive-script-outside-document.test.ts`

Extends #46609
Fixes #50096
Fixes NEXT-1230
hydRAnger pushed a commit to hydRAnger/next.js that referenced this issue Jun 12, 2023
## Why?
```
src/app/layout.tsx
```
![code](https://github.com/vercel/next.js/assets/120007119/3cc991f8-a96d-4ffb-9f84-4dfdbcac5318)

**eslint[@next/next/no-before-interactive-script-outside-document](https://nextjs.org/docs/messages/no-before-interactive-script-outside-document)**
> `next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. 

## How?
- Possibility of pathname starts with "/" on OS X and Linux, so added condition to check file path starting with "/"
- e.g. "/src/app" or "/app"
- Added test code



Passed 
- `pnpm build && pnpm lint`
- `pnpm jest test/unit/eslint-plugin-next/no-before-interactive-script-outside-document.test.ts`

Extends vercel#46609
Fixes vercel#50096
Fixes NEXT-1230
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant