refactor(linter): extract ambient TypeScript declaration helper#22572
Conversation
41193ce to
0c15ef9
Compare
Merge activity
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the linter’s TypeScript-related logic by extracting a shared helper for detecting whether an AST node is inside an ambient TypeScript declaration context (e.g. declare module, declare namespace, declare global), and reusing it across multiple rules.
Changes:
- Added
utils::has_ambient_typescript_ancestoras a shared utility. - Replaced per-rule ambient-context checks in
no_namespace,vars_on_top, andno_varwith the shared helper. - Extended
init_declarationstests to coverglobal {}nested within an ambient module.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_linter/src/utils/typescript.rs | Adds shared ambient TypeScript ancestor detection helper. |
| crates/oxc_linter/src/rules/typescript/no_namespace.rs | Replaces local ambient-ancestor check with shared helper. |
| crates/oxc_linter/src/rules/eslint/vars_on_top.rs | Uses shared helper to skip ambient TS contexts. |
| crates/oxc_linter/src/rules/eslint/no_var.rs | Uses shared helper to skip ambient TS contexts. |
| crates/oxc_linter/src/rules/eslint/init_declarations.rs | Uses shared helper and adds a regression test for nested global {}. |
Merging this PR will not alter performance
Comparing Footnotes
|
0c15ef9 to
6dba588
Compare
No description provided.