-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
scopeAnalysis.ts
28 lines (24 loc) · 988 Bytes
/
scopeAnalysis.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as eslintUtils from '@eslint-community/eslint-utils';
import type * as TSESLint from '../../ts-eslint';
import type { TSESTree } from '../../ts-estree';
/**
* Get the variable of a given name.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#findvariable}
*/
const findVariable = eslintUtils.findVariable as (
initialScope: TSESLint.Scope.Scope,
nameOrNode: string | TSESTree.Identifier,
) => TSESLint.Scope.Variable | null;
/**
* Get the innermost scope which contains a given node.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#getinnermostscope}
* @returns The innermost scope which contains the given node.
* If such scope doesn't exist then it returns the 1st argument `initialScope`.
*/
const getInnermostScope = eslintUtils.getInnermostScope as (
initialScope: TSESLint.Scope.Scope,
node: TSESTree.Node,
) => TSESLint.Scope.Scope;
export { findVariable, getInnermostScope };