-
-
Notifications
You must be signed in to change notification settings - Fork 794
fix(noUnknownTypeSelectors): allow root when under ViewTransitions pseudo elements #8382
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
Conversation
🦋 Changeset detectedLatest commit: d34bb30 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
Caution Review failedThe pull request is closed. WalkthroughAdds logic to skip the correctness/noUnknownTypeSelector lint when the Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Comment |
There was a problem hiding this 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 tweaksThe overall approach—special-casing
rootunder view transition pseudo-element functions and short-circuiting inrun()—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"andVIEW_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 likeeq_ignore_ascii_caseon 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()andis_root_in_view_transition_pseudo_elementboth walkident() -> 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 thenoUnknown*naming convention.Also applies to: 12-46, 106-113
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_css_analyze/tests/specs/correctness/noUnknownTypeSelector/valid.css.snapis excluded by!**/*.snapand 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 thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust 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 usingjust 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 adiffcode 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.csscrates/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 Transitionrootselectors covered nicelyThe 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
rootappears outside any view transition pseudo-element and still triggers the diagnostic.
CodSpeed Performance ReportMerging #8382 will improve performances by 19.31%Comparing Summary
Benchmarks breakdown
Footnotes
|
…eudo elements (#8382) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Emanuele Stoppa <[email protected]>
…eudo elements (#8382) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Emanuele Stoppa <[email protected]>
…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]>
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 meetsrootas simple selector, judge the simple selector if it's under a view transition pseudo elements, like the case:Test Plan
I add test case.
Docs