-
-
Notifications
You must be signed in to change notification settings - Fork 715
feat(linter/plugins): scope manager API #14890
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
Merged
camc314
merged 17 commits into
oxc-project:main
from
lilnasy:feat/linter/plugins/scope-manager
Oct 29, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fbb2565
feat(linter/plugins): scope manager API
lilnasy 825451d
`test.only()` -> `test()`
lilnasy 5ab2ad5
wrapper class for ScopeManager
lilnasy 7a00ba5
ignore errors in test file
lilnasy a38878d
[autofix.ci] apply automated fixes
autofix-ci[bot] c90b1f4
re-enable test for fixture plugins
lilnasy f0d6bc9
implement `isGlobalReference`, `getDeclaredVariables`, `getScope`, `m…
lilnasy 9d7008a
use `ESTree.Node` union wherever base `Node` interface was incorrectl…
lilnasy fc55bf2
add test for scope helper methods for sourceCode
lilnasy 8a1bcc6
remove duplicate docs comment
lilnasy 078a3ef
format
lilnasy ce4a9e8
Apply suggestion from code review
lilnasy 4407492
add clarifying comments to `isGlobalReference()` code
lilnasy 1b4cfa3
remove `markVariableAsUsed`
lilnasy 591616e
handle null `globalScope`
lilnasy 4ad77b7
[autofix.ci] apply automated fixes
autofix-ci[bot] ac24f7a
use ts-expect-error so we can identify when ts breaks/changes;
camc314 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "jsPlugins": ["./plugin.ts"], | ||
| "categories": { | ||
| "correctness": "off" | ||
| }, | ||
| "rules": { | ||
| "scope-manager-plugin/scope": "error" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| const { a, b, c } = {}; | ||
|
|
||
| let x = 1; | ||
| var y = 'hello'; | ||
| z = 'world'; | ||
|
|
||
| function topLevelFunction(param: number) { | ||
| const localVar = param + x; | ||
| { | ||
| const deepestVar = y + localVar; | ||
| return deepestVar; | ||
| } | ||
| return localVar; | ||
| } | ||
|
|
||
| export module TopLevelModule { | ||
| interface ConcreteInterface { | ||
| concreteVar: number; | ||
| } | ||
| export interface GenericInterface<T> extends ConcreteInterface { | ||
| genericVar: T; | ||
| } | ||
| export const x: GenericInterface<string> = { | ||
| concreteVar: 42, | ||
| genericVar: 'string', | ||
| }; | ||
| } | ||
|
|
||
| const concreteValue: TopLevelModule.GenericInterface<string> = { | ||
| concreteVar: TopLevelModule.x.concreteVar, | ||
| genericVar: 'string', | ||
| }; | ||
|
|
||
| class TestClass { | ||
| instanceVar: string; | ||
| #privateVar: string; | ||
| static { | ||
| const privateVar = 'private'; | ||
| this.prototype.#privateVar = arrowFunc(privateVar); | ||
|
|
||
| const arrowFunc = (param: string) => { | ||
| const arrowVar = param; | ||
| return arrowVar + y; | ||
| }; | ||
| } | ||
|
|
||
| constructor(x: string) { | ||
| if (x) { | ||
| this.instanceVar = x; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| label: { | ||
| const blockVar = 'block'; | ||
| console.log(blockVar); | ||
| } | ||
|
|
||
| const unusedVar = 'should be detected'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.