1 | /**
|
2 | * All Recast API functions take second parameter with configuration options,
|
3 | * documented in options.js
|
4 | */
|
5 | export interface Options extends DeprecatedOptions {
|
6 | /**
|
7 | * If you want to use a different branch of esprima, or any other module
|
8 | * that supports a .parse function, pass that module object to
|
9 | * recast.parse as options.parser (legacy synonym: options.esprima).
|
10 | * @default require("recast/parsers/esprima")
|
11 | */
|
12 | parser?: any;
|
13 | /**
|
14 | * Number of spaces the pretty-printer should use per tab for
|
15 | * indentation. If you do not pass this option explicitly, it will be
|
16 | * (quite reliably!) inferred from the original code.
|
17 | * @default 4
|
18 | */
|
19 | tabWidth?: number;
|
20 | /**
|
21 | * If you really want the pretty-printer to use tabs instead of spaces,
|
22 | * make this option true.
|
23 | * @default false
|
24 | */
|
25 | useTabs?: boolean;
|
26 | /**
|
27 | * The reprinting code leaves leading whitespace untouched unless it has
|
28 | * to reindent a line, or you pass false for this option.
|
29 | * @default true
|
30 | */
|
31 | reuseWhitespace?: boolean;
|
32 | /**
|
33 | * Override this option to use a different line terminator, e.g. \r\n.
|
34 | * @default require("os").EOL || "\n"
|
35 | */
|
36 | lineTerminator?: string;
|
37 | /**
|
38 | * Some of the pretty-printer code (such as that for printing function
|
39 | * parameter lists) makes a valiant attempt to prevent really long
|
40 | * lines. You can adjust the limit by changing this option; however,
|
41 | * there is no guarantee that line length will fit inside this limit.
|
42 | * @default 74
|
43 | */
|
44 | wrapColumn?: number;
|
45 | /**
|
46 | * Pass a string as options.sourceFileName to recast.parse to tell the
|
47 | * reprinter to keep track of reused code so that it can construct a
|
48 | * source map automatically.
|
49 | * @default null
|
50 | */
|
51 | sourceFileName?: string | null;
|
52 | /**
|
53 | * Pass a string as options.sourceMapName to recast.print, and (provided
|
54 | * you passed options.sourceFileName earlier) the PrintResult of
|
55 | * recast.print will have a .map property for the generated source map.
|
56 | * @default null
|
57 | */
|
58 | sourceMapName?: string | null;
|
59 | /**
|
60 | * If provided, this option will be passed along to the source map
|
61 | * generator as a root directory for relative source file paths.
|
62 | * @default null
|
63 | */
|
64 | sourceRoot?: string | null;
|
65 | /**
|
66 | * If you provide a source map that was generated from a previous call
|
67 | * to recast.print as options.inputSourceMap, the old source map will be
|
68 | * composed with the new source map.
|
69 | * @default null
|
70 | */
|
71 | inputSourceMap?: string | null;
|
72 | /**
|
73 | * If you want esprima to generate .range information (recast only uses
|
74 | * .loc internally), pass true for this option.
|
75 | * @default false
|
76 | */
|
77 | range?: boolean;
|
78 | /**
|
79 | * If you want esprima not to throw exceptions when it encounters
|
80 | * non-fatal errors, keep this option true.
|
81 | * @default true
|
82 | */
|
83 | tolerant?: boolean;
|
84 | /**
|
85 | * If you want to override the quotes used in string literals, specify
|
86 | * either "single", "double", or "auto" here ("auto" will select the one
|
87 | * which results in the shorter literal) Otherwise, use double quotes.
|
88 | * @default null
|
89 | */
|
90 | quote?: "single" | "double" | "auto" | null;
|
91 | /**
|
92 | * Controls the printing of trailing commas in object literals, array
|
93 | * expressions and function parameters.
|
94 | *
|
95 | * This option could either be:
|
96 | * * Boolean - enable/disable in all contexts (objects, arrays and function params).
|
97 | * * Object - enable/disable per context.
|
98 | *
|
99 | * Example:
|
100 | * trailingComma: {
|
101 | * objects: true,
|
102 | * arrays: true,
|
103 | * parameters: false,
|
104 | * }
|
105 | *
|
106 | * @default false
|
107 | */
|
108 | trailingComma?: boolean;
|
109 | /**
|
110 | * Controls the printing of spaces inside array brackets.
|
111 | * See: http://eslint.org/docs/rules/array-bracket-spacing
|
112 | * @default false
|
113 | */
|
114 | arrayBracketSpacing?: boolean;
|
115 | /**
|
116 | * Controls the printing of spaces inside object literals,
|
117 | * destructuring assignments, and import/export specifiers.
|
118 | * See: http://eslint.org/docs/rules/object-curly-spacing
|
119 | * @default true
|
120 | */
|
121 | objectCurlySpacing?: boolean;
|
122 | /**
|
123 | * If you want parenthesis to wrap single-argument arrow function
|
124 | * parameter lists, pass true for this option.
|
125 | * @default false
|
126 | */
|
127 | arrowParensAlways?: boolean;
|
128 | /**
|
129 | * There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
|
130 | * The use of commas is in line with the more popular style and matches
|
131 | * how objects are defined in JS, making it a bit more natural to write.
|
132 | * @default true
|
133 | */
|
134 | flowObjectCommas?: boolean;
|
135 | /**
|
136 | * Whether to return an array of .tokens on the root AST node.
|
137 | * @default true
|
138 | */
|
139 | tokens?: boolean;
|
140 | }
|
141 | interface DeprecatedOptions {
|
142 | /** @deprecated */
|
143 | esprima?: any;
|
144 | }
|
145 | export type NormalizedOptions = Required<Omit<Options, keyof DeprecatedOptions>>;
|
146 | export declare function normalize(opts?: Options): NormalizedOptions;
|
147 | export {};
|