1 | import { Scope, SourceCode, Rule } from 'eslint';
|
2 | import * as ESTree from 'estree';
|
3 |
|
4 | type LegacyContext = {
|
5 | getFilename: () => string,
|
6 | getPhysicalFilename: () => string,
|
7 | getSourceCode: () => SourceCode,
|
8 | getScope: never,
|
9 | getAncestors: never,
|
10 | getDeclaredVariables: never,
|
11 | };
|
12 |
|
13 | type NewContext = {
|
14 | filename: string,
|
15 | sourceCode: SourceCode,
|
16 | getPhysicalFilename?: () => string,
|
17 | getScope: () => Scope.Scope,
|
18 | getAncestors: () => ESTree.Node[],
|
19 | getDeclaredVariables: (node: ESTree.Node) => Scope.Variable[],
|
20 | };
|
21 |
|
22 | export type Context = LegacyContext | NewContext | Rule.RuleContext;
|
23 |
|
24 | declare function getAncestors(context: Context, node: ESTree.Node): ESTree.Node[];
|
25 | declare function getDeclaredVariables(context: Context, node: ESTree.Node): Scope.Variable[];
|
26 | declare function getFilename(context: Context): string;
|
27 | declare function getPhysicalFilename(context: Context): string;
|
28 | declare function getScope(context: Context, node: ESTree.Node): Scope.Scope;
|
29 | declare function getSourceCode(context: Context): SourceCode;
|
30 |
|
31 | export {
|
32 | getAncestors,
|
33 | getDeclaredVariables,
|
34 | getFilename,
|
35 | getPhysicalFilename,
|
36 | getScope,
|
37 | getSourceCode,
|
38 | };
|