fix(linter): enable useOptionalChain in Astro templates#9688
fix(linter): enable useOptionalChain in Astro templates#9688raashish1601 wants to merge 1 commit intobiomejs:mainfrom
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
WalkthroughThe PR extends JavaScript semantic-model support to Astro template expressions by refactoring the HTML file handler's logic for when to enable semantic services during embedded JS parsing. It introduces a test case that verifies the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // Astro template expressions need semantic services for JS rules such as | ||
| // `useOptionalChain`, even though they aren't source-level snippets. | ||
| let js_services = if should_build_semantic_model | ||
| && (is_source_level || ctx.host_file_source.is_astro()) |
There was a problem hiding this comment.
This is wrong and unsafe. Instead you should update the semantics of is_source_level to enable the semantic model for text expressions
| } | ||
|
|
||
| #[test] | ||
| fn check_astro_template_use_optional_chain_write_unsafe() { |
There was a problem hiding this comment.
There's no need for a cli test. Use a linter test, since it's a lint rule we're fixing
Summary
Closes #9179.
Testing
ustfmt --check crates/biome_service/src/file_handlers/html.rs crates/biome_cli/tests/cases/handle_astro_files.rs