UNPKG

1.93 kBTypeScriptView Raw
1// Type definitions for eslint-scope 3.7
2// Project: https://github.com/eslint/eslint-scope
3// Definitions by: Toru Nagashima <https://github.com/mysticatea>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 3.8
6import * as eslint from "eslint";
7import * as estree from "estree";
8
9export const version: string;
10
11export class ScopeManager implements eslint.Scope.ScopeManager {
12 scopes: Scope[];
13 globalScope: Scope;
14 acquire(node: {}, inner?: boolean): Scope | null;
15 getDeclaredVariables(node: {}): Variable[];
16}
17
18export class Scope implements eslint.Scope.Scope {
19 type: "block" | "catch" | "class" | "for" | "function" | "function-expression-name" | "global" | "module" | "switch" | "with" | "TDZ";
20 isStrict: boolean;
21 upper: Scope | null;
22 childScopes: Scope[];
23 variableScope: Scope;
24 block: estree.Node;
25 variables: Variable[];
26 set: Map<string, Variable>;
27 references: Reference[];
28 through: Reference[];
29 functionExpressionScope: boolean;
30}
31
32export class Variable implements eslint.Scope.Variable {
33 name: string;
34 scope: Scope;
35 identifiers: estree.Identifier[];
36 references: Reference[];
37 defs: eslint.Scope.Definition[];
38}
39
40export class Reference implements eslint.Scope.Reference {
41 identifier: estree.Identifier;
42 from: Scope;
43 resolved: Variable | null;
44 writeExpr: estree.Node | null;
45 init: boolean;
46
47 isWrite(): boolean;
48 isRead(): boolean;
49 isWriteOnly(): boolean;
50 isReadOnly(): boolean;
51 isReadWrite(): boolean;
52}
53
54export interface AnalysisOptions {
55 optimistic?: boolean;
56 directive?: boolean;
57 ignoreEval?: boolean;
58 nodejsScope?: boolean;
59 impliedStrict?: boolean;
60 fallback?: string | ((node: {}) => string[]);
61 sourceType?: "script" | "module";
62 ecmaVersion?: number;
63}
64
65export function analyze(ast: {}, options?: AnalysisOptions): ScopeManager;
66
\No newline at end of file