Skip to content

Conversation

@Netail
Copy link
Member

@Netail Netail commented Nov 18, 2025

Summary

script tags with type="module" are non-blocking; https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#blocking

Closes #8144

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: c4c53c0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages L-HTML Language: HTML and super languages labels Nov 18, 2025
@Netail Netail force-pushed the fix/no-sync-scripts-type branch from c6741e6 to ff17ff3 Compare November 18, 2025 13:19
"@biomejs/biome": patch
---

Improve noSyncScripts, ignore script tags with `type="module"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link the issue that this is fixing

@Netail Netail force-pushed the fix/no-sync-scripts-type branch from ff17ff3 to 341bd21 Compare November 18, 2025 13:27
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 18, 2025

CodSpeed Performance Report

Merging #8149 will not alter performance

Comparing Netail:fix/no-sync-scripts-type (c4c53c0) with main (2dd38cf)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

  1. No successful run was found on main (1fbdff5) during the generation of this report, so 2dd38cf was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 95 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks alright, but I think we may need to be a bit more careful with the implementation.

attribute.initializer().is_some_and(|initializer| {
initializer.value().ok().is_some_and(|value| {
value.as_html_string().is_some_and(|html_string| {
html_string.inner_string_text().unwrap().text() == "module"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unwrap() safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a check

}

/// Create a new string literal token with no attached trivia
pub fn html_string_literal(text: &str) -> HtmlSyntaxToken {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get used anywhere in the PR?

Copy link
Member Author

@Netail Netail Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in the example of inner_string_text. The CI seemed to fail on that implementation missing even tho it's it's only in the docs

/// .with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]));
/// assert_eq!(string.inner_string_text().unwrap().text(), "button");
/// ```
pub fn inner_string_text(&self) -> SyntaxResult<TokenText> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this wrapper function?

Copy link
Member Author

@Netail Netail Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it easier to access the inner string text; js, json, css also have such wrapper function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much easier is it if we already have one?

Copy link
Member Author

@Netail Netail Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The css, json, css wrapper functions are not available on the HtmlString

inner_string_text(html_string.value_token()?).ok()?.text() vs
html_string.inner_string_text?.text()

basically continued the pattern that was already in place, to make inner_string_text a function of a syntax String, but missing for HtmlString

Copy link
Member Author

@Netail Netail Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhm thoughts? @ematipico @dyc3

attribute.initializer().is_some_and(|initializer| {
initializer.value().ok().is_some_and(|value| {
value.as_jsx_string().is_some_and(|jsx_string| {
jsx_string.inner_string_text().unwrap().text() == "module"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also mind this unwrap() please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a check

@Netail Netail merged commit e0a02bf into biomejs:main Nov 19, 2025
17 checks passed
@Netail Netail deleted the fix/no-sync-scripts-type branch November 19, 2025 08:32
@github-actions github-actions bot mentioned this pull request Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Parser Area: parser L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Improve noSyncScripts rule

5 participants