1 import { DebugLevel } from '@typescript-eslint/types';
2 import { Program } from 'typescript';
3 import { TSESTree, TSNode, TSESTreeToTSNode, TSToken } from './ts-estree';
4 declare type DebugModule = 'typescript-eslint' | 'eslint' | 'typescript';
5 export interface Extra {
8 comments: TSESTree.Comment[];
9 createDefaultProgram: boolean;
10 debugLevel: Set<DebugModule>;
11 errorOnTypeScriptSyntacticAndSemanticIssues: boolean;
12 errorOnUnknownASTType: boolean;
13 extraFileExtensions: string[];
17 log: (message: string) => void;
18 preserveNodeMaps?: boolean;
22 tokens: null | TSESTree.Token[];
23 tsconfigRootDir: string;
24 useJSXTextNode: boolean;
26 interface ParseOptions {
28 * create a top-level comments array containing all comments
32 * An array of modules to turn explicit debugging on for.
33 * - 'typescript-eslint' is the same as setting the env var `DEBUG=typescript-eslint:*`
34 * - 'eslint' is the same as setting the env var `DEBUG=eslint:*`
35 * - 'typescript' is the same as setting `extendedDiagnostics: true` in your tsconfig compilerOptions
37 * For convenience, also supports a boolean:
38 * - true === ['typescript-eslint']
41 debugLevel?: DebugLevel;
43 * Cause the parser to error if it encounters an unknown AST node type (useful for testing).
44 * This case only usually occurs when TypeScript releases new features.
46 errorOnUnknownASTType?: boolean;
48 * Absolute (or relative to `cwd`) path to the file being parsed.
52 * Enable parsing of JSX.
53 * For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html
55 * NOTE: this setting does not effect known file types (.js, .jsx, .ts, .tsx, .json) because the
56 * TypeScript compiler has its own internal handling for known file extensions.
58 * For the exact behavior, see https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsecmafeaturesjsx
62 * Controls whether the `loc` information to each node.
63 * The `loc` property is an object which contains the exact line/column the node starts/ends on.
64 * This is similar to the `range` property, except it is line/column relative.
67 loggerFn?: ((message: string) => void) | false;
69 * Controls whether the `range` property is included on AST nodes.
70 * The `range` property is a [number, number] which indicates the start/end index of the node in the file contents.
71 * This is similar to the `loc` property, except this is the absolute index.
75 * Set to true to create a top-level array containing all tokens from the file.
78 useJSXTextNode?: boolean;
80 interface ParseAndGenerateServicesOptions extends ParseOptions {
82 * Causes the parser to error if the TypeScript compiler returns any unexpected syntax/semantic errors.
84 errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
86 * When `project` is provided, this controls the non-standard file extensions which will be parsed.
87 * It accepts an array of file extensions, each preceded by a `.`.
89 extraFileExtensions?: string[];
91 * Absolute (or relative to `tsconfigRootDir`) path to the file being parsed.
92 * When `project` is provided, this is required, as it is used to fetch the file from the TypeScript compiler's cache.
96 * Allows the user to control whether or not two-way AST node maps are preserved
97 * during the AST conversion process.
99 * By default: the AST node maps are NOT preserved, unless `project` has been specified,
100 * in which case the maps are made available on the returned `parserServices`.
102 * NOTE: If `preserveNodeMaps` is explicitly set by the user, it will be respected,
103 * regardless of whether or not `project` is in use.
105 preserveNodeMaps?: boolean;
107 * Absolute (or relative to `tsconfigRootDir`) paths to the tsconfig(s).
108 * If this is provided, type information will be returned.
110 project?: string | string[];
112 * If you provide a glob (or globs) to the project option, you can use this option to blacklist
113 * certain folders from being matched by the globs.
114 * Any project path that matches one or more of the provided regular expressions will be removed from the list.
116 * Accepts an array of strings that are passed to new RegExp(), or an array of regular expressions.
117 * By default, this is set to ["/node_modules/"]
119 projectFolderIgnoreList?: (string | RegExp)[];
121 * The absolute path to the root directory for all provided `project`s.
123 tsconfigRootDir?: string;
125 ***************************************************************************************
126 * IT IS RECOMMENDED THAT YOU DO NOT USE THIS OPTION, AS IT CAUSES PERFORMANCE ISSUES. *
127 ***************************************************************************************
129 * When passed with `project`, this allows the parser to create a catch-all, default program.
130 * This means that if the parser encounters a file not included in any of the provided `project`s,
131 * it will not error, but will instead parse the file and its dependencies in a new program.
133 createDefaultProgram?: boolean;
135 export declare type TSESTreeOptions = ParseAndGenerateServicesOptions;
136 export interface ParserWeakMap<TKey, TValueBase> {
137 get<TValue extends TValueBase>(key: TKey): TValue;
138 has(key: unknown): boolean;
140 export interface ParserWeakMapESTreeToTSNode<TKey extends TSESTree.Node = TSESTree.Node> {
141 get<TKeyBase extends TKey>(key: TKeyBase): TSESTreeToTSNode<TKeyBase>;
142 has(key: unknown): boolean;
144 export interface ParserServices {
146 esTreeNodeToTSNodeMap: ParserWeakMapESTreeToTSNode;
147 tsNodeToESTreeNodeMap: ParserWeakMap<TSNode | TSToken, TSESTree.Node>;
148 hasFullTypeInformation: boolean;
151 //# sourceMappingURL=parser-options.d.ts.map