Skip to content

Commit e574bfb

Browse files
committed
docs(linter/plugins): reformat and clarify ScopeManager JSDoc comments
1 parent 75a6a13 commit e574bfb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

apps/oxlint/src-js/plugins/scope.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function resetScopeManager() {
7575
// Freeze the object to prevent user mutating it.
7676
export const SCOPE_MANAGER = Object.freeze({
7777
/**
78-
* All scopes
78+
* All scopes.
7979
*/
8080
get scopes(): Scope[] {
8181
if (tsScopeManager === null) initTsScopeManager();
@@ -84,7 +84,7 @@ export const SCOPE_MANAGER = Object.freeze({
8484
},
8585

8686
/**
87-
* The root scope
87+
* The root scope.
8888
*/
8989
get globalScope(): Scope | null {
9090
if (tsScopeManager === null) initTsScopeManager();
@@ -93,9 +93,10 @@ export const SCOPE_MANAGER = Object.freeze({
9393
},
9494

9595
/**
96-
* Get the variables that a given AST node defines. The gotten variables' `def[].node`/`def[].parent` property is the node.
96+
* Get the variables that a given AST node defines.
97+
* The returned variables' `def[].node` / `def[].parent` property is the node.
9798
* If the node does not define any variable, this returns an empty array.
98-
* @param node An AST node to get their variables.
99+
* @param node AST node to get variables of.
99100
*/
100101
getDeclaredVariables(node: ESTree.Node): Variable[] {
101102
if (tsScopeManager === null) initTsScopeManager();
@@ -104,12 +105,13 @@ export const SCOPE_MANAGER = Object.freeze({
104105
},
105106

106107
/**
107-
* Get the scope of a given AST node. The gotten scope's `block` property is the node.
108-
* This method never returns `function-expression-name` scope. If the node does not have their scope, this returns `null`.
108+
* Get the scope of a given AST node. The returned scope's `block` property is the node.
109+
* This method never returns `function-expression-name` scope.
110+
* If the node does not have a scope, returns `null`.
109111
*
110112
* @param node An AST node to get their scope.
111113
* @param inner If the node has multiple scopes, this returns the outermost scope normally.
112-
* If `inner` is `true` then this returns the innermost scope.
114+
* If `inner` is `true` then this returns the innermost scope.
113115
*/
114116
acquire(node: ESTree.Node, inner?: boolean): Scope | null {
115117
if (tsScopeManager === null) initTsScopeManager();
@@ -213,15 +215,16 @@ export function isGlobalReference(node: ESTree.Node): boolean {
213215
const globalScope = tsScopeManager.scopes[0];
214216
if (!globalScope) return false;
215217

216-
// If the identifier is a reference to a global variable, the global scope should have a variable with the name.
218+
// If the identifier is a reference to a global variable, the global scope should have a variable with the name
217219
const variable = globalScope.set.get(name);
218220

219-
// Global variables are not defined by any node, so they should have no definitions.
221+
// Global variables are not defined by any node, so they should have no definitions
220222
if (!variable || variable.defs.length > 0) {
221223
return false;
222224
}
223225

224-
// If there is a variable by the same name exists in the global scope, we need to check our node is one of its references.
226+
// If there is a variable by the same name exists in the global scope,
227+
// we need to check our node is one of its references
225228
const { references } = variable;
226229

227230
for (let i = 0; i < references.length; i++) {
@@ -236,7 +239,7 @@ export function isGlobalReference(node: ESTree.Node): boolean {
236239

237240
/**
238241
* Get the variables that `node` defines.
239-
* This is a convenience method that passes through to the same method on the `scopeManager`.
242+
* This is a convenience method that passes through to the same method on the `ScopeManager`.
240243
* @param node - The node for which the variables are obtained.
241244
* @returns An array of variable nodes representing the variables that `node` defines.
242245
*/
@@ -248,7 +251,7 @@ export function getDeclaredVariables(node: ESTree.Node): Variable[] {
248251
}
249252

250253
/**
251-
* Get the scope for the given node
254+
* Get the scope for the given node.
252255
* @param node - The node to get the scope of.
253256
* @returns The scope information for this node.
254257
*/

0 commit comments

Comments
 (0)