Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fireairforce
Copy link
Member

Summary

Closes: #8338

Ignore unknownTypeSelector check when root under view transition pseudo elements.

The fix just add a judge for the rule NoUnkownTypeSelector, when it meets root as simple selector, judge the simple selector if it's under a view transition pseudo elements, like the case:

::view-transition-old(root) {}

Test Plan

I add test case.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2025

🦋 Changeset detected

Latest commit: d34bb30

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 L-CSS Language: CSS labels Dec 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds logic to skip the correctness/noUnknownTypeSelector lint when the root type selector appears as a parameter inside view-transition pseudo-element functions. Introduces a VIEW_TRANSITION_PSEUDO_ELEMENTS constant and an is_root_in_view_transition_pseudo_element helper that inspects the AST path and pseudo-element name. The rule returns early when that helper matches. A CSS test demonstrating ::view-transition-old(root) and ::view-transition-new(root) with z-index: 1 was added. No public API changes.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: allowing the root selector when used under View Transition pseudo-elements in the noUnknownTypeSelectors rule.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix for issue #8338 and detailing how the noUnknownTypeSelector rule now ignores validation for 'root' under view-transition pseudo-elements.
Linked Issues check ✅ Passed The PR successfully addresses issue #8338 by implementing logic to detect and skip the noUnknownTypeSelector check when 'root' appears under view-transition pseudo-elements like ::view-transition-old(root) and ::view-transition-new(root), with appropriate test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the noUnknownTypeSelector rule for View Transition pseudo-elements: implementation logic, helper function, test cases, and changelog entry are all aligned with issue #8338 objectives.

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b29d935 and d34bb30.

📒 Files selected for processing (1)
  • .changeset/young-hoops-arrive.md (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs (1)

5-6: View Transition handling looks good; consider small robustness tweaks

The overall approach—special-casing root under view transition pseudo-element functions and short-circuiting in run()—fits the rule nicely and keeps the change tightly scoped. A couple of polish points you might consider:

  • Case sensitivity: CSS pseudo-element names and identifiers are effectively ASCII case-insensitive in practice. The current checks (type_selector_text != "root" and VIEW_TRANSITION_PSEUDO_ELEMENTS.contains(&name_text.as_str())) only match lower-case source. If someone writes ::VIEW-TRANSITION-OLD(root) or ::view-transition-old(ROOT), they’ll still get a false positive. Using something like eq_ignore_ascii_case on the token text (or normalising to lower-case once) would make this more robust.
  • Avoiding allocations: Both the type selector text and the pseudo-element name are converted to Strings just to compare. You could work directly on the trimmed token text (borrowing &str) to avoid per-node allocations, since you only need equality checks.
  • Reuse of ident extraction: run() and is_root_in_view_transition_pseudo_element both walk ident() -> value_token(). Not a big deal, but if this grows, factoring that into a small helper returning the trimmed token text might simplify things.

None of these are blockers—the current implementation is clear and will solve the reported false positive—but they’d make the rule a bit more future-proof and efficient.

If you want to double-check behaviour, it’s worth adding a couple of fixtures like ::VIEW-TRANSITION-OLD(root) and ::view-transition-old(ROOT) to confirm whether the parser already normalises case for you or whether the extra case-insensitive handling is needed. Based on learnings, this also keeps the rule nicely aligned with the noUnknown* naming convention.

Also applies to: 12-46, 106-113

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc2a62e and b6aeeed.

⛔ Files ignored due to path filters (1)
  • crates/biome_css_analyze/tests/specs/correctness/noUnknownTypeSelector/valid.css.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • .changeset/young-hoops-arrive.md (1 hunks)
  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs (2 hunks)
  • crates/biome_css_analyze/tests/specs/correctness/noUnknownTypeSelector/valid.css (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
.changeset/**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/**/*.md: Create changesets for user-facing changes using just new-changeset; use headers with #### or ##### only; keep descriptions concise (1-3 sentences) and focus on user-facing changes
Use past tense when describing what was done ('Added new feature'), present tense when describing Biome behavior ('Biome now supports'); end sentences with a full stop
For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a diff code block

Files:

  • .changeset/young-hoops-arrive.md
🧠 Learnings (12)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)

Applied to files:

  • crates/biome_css_analyze/tests/specs/correctness/noUnknownTypeSelector/valid.css
  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noInvalid` prefix for rules that report runtime errors from mistyping (e.g., `noInvalidConstructorSuper`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnused` prefix for rules that report unused entities (e.g., `noUnusedVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRestricted` prefix for rules that report user-banned entities (e.g., `noRestrictedGlobals`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Framework-specific rules should be named using the `use` or `no` prefix followed by the framework name (e.g., `noVueReservedProps`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules must be implemented using the `Rule` trait with type parameters: `Query` (node type to analyze), `State` (information for signals), `Signals` (return type from run function), and `Options` (rule configuration)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rules should use the `use` prefix naming convention when the sole intention is to mandate a single concept (e.g., `useValidLang` to enforce valid HTML lang attribute values)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs
🧬 Code graph analysis (1)
crates/biome_css_analyze/src/lint/correctness/no_unknown_type_selector.rs (1)
crates/biome_css_analyze/src/utils.rs (1)
  • is_known_type_selector (137-143)
🪛 LanguageTool
.changeset/young-hoops-arrive.md

[misspelling] ~5-~5: This word is normally spelled with a hyphen.
Context: ...r check when root under view transition pseudo elements. #### Example ```css ::view-transitio...

(EN_COMPOUNDS_PSEUDO_ELEMENTS)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: autofix
🔇 Additional comments (1)
crates/biome_css_analyze/tests/specs/correctness/noUnknownTypeSelector/valid.css (1)

23-27: View Transition root selectors covered nicely

The new ::view-transition-old(root), ::view-transition-new(root) block is a good, minimal fixture to exercise the new exemption path in the rule; looks spot on.

It’s worth double-checking that we also still have (or add) a negative test where root appears outside any view transition pseudo-element and still triggers the diagnostic.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 7, 2025

CodSpeed Performance Report

Merging #8382 will improve performances by 19.31%

Comparing fix-8338 (d34bb30) with main (cc2a62e)

Summary

⚡ 5 improvements
✅ 24 untouched
⏩ 126 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
css_analyzer[bootstrap_18416142857265205439.css] 512 ms 478 ms +7.09%
css_analyzer[bulma_5641719244145477318.css] 1.2 s 1.1 s +10.56%
css_analyzer[tachyons_11778168428173736564.css] 141.2 ms 123 ms +14.77%
css_analyzer[foundation_11602414662825430680.css] 189.2 ms 164.6 ms +14.96%
css_analyzer[pure_9395922602181450299.css] 20.3 ms 17 ms +19.31%

Footnotes

  1. 126 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.

@ematipico ematipico merged commit 7409cba into main Dec 8, 2025
16 of 17 checks passed
@ematipico ematipico deleted the fix-8338 branch December 8, 2025 06:19
@github-actions github-actions bot mentioned this pull request Dec 8, 2025
ematipico added a commit that referenced this pull request Dec 8, 2025
…eudo elements (#8382)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <[email protected]>
ematipico added a commit that referenced this pull request Dec 8, 2025
…eudo elements (#8382)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <[email protected]>
This was referenced Dec 15, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
…eudo elements (biomejs#8382)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Unknown type selector for View Transitions pseudo-elements

3 participants