UNPKG

1.91 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 identifiers: estree.Identifier[];
35 references: Reference[];
36 defs: eslint.Scope.Definition[];
37}
38
39export class Reference implements eslint.Scope.Reference {
40 identifier: estree.Identifier;
41 from: Scope;
42 resolved: Variable | null;
43 writeExpr: estree.Node | null;
44 init: boolean;
45
46 isWrite(): boolean;
47 isRead(): boolean;
48 isWriteOnly(): boolean;
49 isReadOnly(): boolean;
50 isReadWrite(): boolean;
51}
52
53export interface AnalysisOptions {
54 optimistic?: boolean;
55 directive?: boolean;
56 ignoreEval?: boolean;
57 nodejsScope?: boolean;
58 impliedStrict?: boolean;
59 fallback?: string | ((node: {}) => string[]);
60 sourceType?: "script" | "module";
61 ecmaVersion?: number;
62}
63
64export function analyze(ast: {}, options?: AnalysisOptions): ScopeManager;
65
\No newline at end of file