UNPKG

2.67 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/eslint-scope`
3
4# Summary
5This package contains type definitions for eslint-scope (https://github.com/eslint/eslint-scope).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint-scope.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint-scope/index.d.ts)
10````ts
11// Type definitions for eslint-scope 3.7
12// Project: https://github.com/eslint/eslint-scope
13// Definitions by: Toru Nagashima <https://github.com/mysticatea>
14// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
15// TypeScript Version: 3.8
16import * as eslint from "eslint";
17import * as estree from "estree";
18
19export const version: string;
20
21export class ScopeManager implements eslint.Scope.ScopeManager {
22 scopes: Scope[];
23 globalScope: Scope;
24 acquire(node: {}, inner?: boolean): Scope | null;
25 getDeclaredVariables(node: {}): Variable[];
26}
27
28export class Scope implements eslint.Scope.Scope {
29 type: "block" | "catch" | "class" | "for" | "function" | "function-expression-name" | "global" | "module" | "switch" | "with" | "TDZ";
30 isStrict: boolean;
31 upper: Scope | null;
32 childScopes: Scope[];
33 variableScope: Scope;
34 block: estree.Node;
35 variables: Variable[];
36 set: Map<string, Variable>;
37 references: Reference[];
38 through: Reference[];
39 functionExpressionScope: boolean;
40}
41
42export class Variable implements eslint.Scope.Variable {
43 name: string;
44 scope: Scope;
45 identifiers: estree.Identifier[];
46 references: Reference[];
47 defs: eslint.Scope.Definition[];
48}
49
50export class Reference implements eslint.Scope.Reference {
51 identifier: estree.Identifier;
52 from: Scope;
53 resolved: Variable | null;
54 writeExpr: estree.Node | null;
55 init: boolean;
56
57 isWrite(): boolean;
58 isRead(): boolean;
59 isWriteOnly(): boolean;
60 isReadOnly(): boolean;
61 isReadWrite(): boolean;
62}
63
64export interface AnalysisOptions {
65 optimistic?: boolean;
66 directive?: boolean;
67 ignoreEval?: boolean;
68 nodejsScope?: boolean;
69 impliedStrict?: boolean;
70 fallback?: string | ((node: {}) => string[]);
71 sourceType?: "script" | "module";
72 ecmaVersion?: number;
73}
74
75export function analyze(ast: {}, options?: AnalysisOptions): ScopeManager;
76
77````
78
79### Additional Details
80 * Last updated: Thu, 30 Jun 2022 19:02:28 GMT
81 * Dependencies: [@types/eslint](https://npmjs.com/package/@types/eslint), [@types/estree](https://npmjs.com/package/@types/estree)
82 * Global values: none
83
84# Credits
85These definitions were written by [Toru Nagashima](https://github.com/mysticatea).
86
\No newline at end of file