-
-
Couldn't load subscription status.
- Fork 705
feat(linter): generic interface for Vue, Svelte, and Astro globals #15005
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces a generic interface for framework-provided globals, enabling the linter to recognize framework-specific identifiers (like Vue's defineProps or Svelte's $state) without requiring framework-specific parsing infrastructure. This prevents false positives in no-undef and no-redeclare rules when using framework compiler macros.
Key Changes:
- Added
FrameworkOptionsenum variants for Svelte (Svelte,SvelteModule) and Astro (AstroFrontmatter) contexts - Implemented
has_global()method to check if a variable is a framework-specific global - Updated
no-undefandno-redeclarerules to recognize framework globals viactx.frameworks_options().has_global()
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_linter/src/rules/eslint/no_undef.rs |
Added framework globals check to skip undefined variable errors |
crates/oxc_linter/src/rules/eslint/no_redeclare.rs |
Extended built-in globals detection to include framework-provided globals |
crates/oxc_linter/src/loader/partial_loader/svelte.rs |
Added detection of <script module> context and passes appropriate framework options |
crates/oxc_linter/src/loader/partial_loader/astro.rs |
Updated to pass framework options (currently Default) for Astro frontmatter |
crates/oxc_linter/src/frameworks.rs |
Defined framework-specific global arrays and implemented has_global() logic with comprehensive tests |
Comments suppressed due to low confidence (1)
crates/oxc_linter/src/frameworks.rs:1
- Comparing boolean expressions with
== trueor== falseis redundant. Remove the explicit comparisons and use the boolean values directly:assert!(options.has_global(\"defineProps\"))andassert!(!options.has_global(\"console\")).
use std::{hash, path::Path};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
11caf48 to
4239a7e
Compare
CodSpeed Performance ReportMerging #15005 will not alter performanceComparing Summary
Footnotes
|
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.
Thank you for all your contributions and for looking at this, but I need to think about this more + possibly discuss with @ overlookmotel . I just worry about maintenance burden when we mix more and more different frameworks + different framework versions etc.
fyi, i'm OOO til wednesday, so probably won't get to this till towards the end of the week.
|
Thanks. I realise that a more proper solution is possible here. It will definitely benefit from discussion with overlookmotel as it touches on whether the entire framework support needs to be abstracted differently for milestone 2. I'm happy to help where I can. |
|
Thank you for all the work ❤️ Some ideas: |
eslint-plugin-vuedepends onvue-eslint-parserto manage parsing and scopes.FrameworkOptionsenum.ctx.frameworks_options().has_global(name)to check if the effective framework provides a global variable by that name.parserOptionsfor linter milestone 2, which may touch on frameworks.Tasks
no-undefno-redeclare