-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathcontextCompat.d.ts
38 lines (33 loc) · 1.13 KB
/
contextCompat.d.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
29
30
31
32
33
34
35
36
37
38
import { Scope, SourceCode, Rule } from 'eslint';
import * as ESTree from 'estree';
type LegacyContext = {
getFilename: () => string,
getPhysicalFilename: () => string,
getSourceCode: () => SourceCode,
getScope: never,
getAncestors: never,
getDeclaredVariables: never,
};
type NewContext = {
filename: string,
sourceCode: SourceCode,
getPhysicalFilename?: () => string,
getScope: () => Scope.Scope,
getAncestors: () => ESTree.Node[],
getDeclaredVariables: (node: ESTree.Node) => Scope.Variable[],
};
export type Context = LegacyContext | NewContext | Rule.RuleContext;
declare function getAncestors(context: Context, node: ESTree.Node): ESTree.Node[];
declare function getDeclaredVariables(context: Context, node: ESTree.Node): Scope.Variable[];
declare function getFilename(context: Context): string;
declare function getPhysicalFilename(context: Context): string;
declare function getScope(context: Context, node: ESTree.Node): Scope.Scope;
declare function getSourceCode(context: Context): SourceCode;
export {
getAncestors,
getDeclaredVariables,
getFilename,
getPhysicalFilename,
getScope,
getSourceCode,
};