-
-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathtransform.ts
More file actions
76 lines (65 loc) · 1.72 KB
/
transform.ts
File metadata and controls
76 lines (65 loc) · 1.72 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import type { AstPath, Plugin } from 'prettier'
import type { TransformerEnv } from './types'
export function defineTransform<T>(opts: TransformOptions<T>) {
return opts
}
export interface TransformOptions<T> {
/**
* Static attributes that are supported by default
*/
staticAttrs?: string[]
/**
* Dynamic / expression attributes that are supported by default
*/
dynamicAttrs?: string[]
/**
* Load the given plugins for the parsers and printers
*/
load?: Array<string | Plugin<any>>
/**
* A list of compatible, third-party plugins for this transformation step
*
* The loading of these is delayed until the actual parse call as
* using the parse() function from these plugins may cause errors
* if they haven't already been loaded by Prettier.
*/
compatible?: string[]
/**
* A list of supported parser names
*/
parsers: Record<
string,
{
/**
* Load the given plugins for the parsers and printers
*/
load?: Array<string | Plugin<any>>
/**
* Static attributes that are supported by default
*/
staticAttrs?: string[]
/**
* Dynamic / expression attributes that are supported by default
*/
dynamicAttrs?: string[]
}
>
/**
* A list of supported parser names
*/
printers?: Record<string, {}>
/**
* Transform entire ASTs
*
* @param ast The AST to transform
* @param env Provides options and mechanisms to sort classes
*/
transform?(ast: T, env: TransformerEnv): void
/**
* Transform entire ASTs
*
* @param ast The AST to transform
* @param env Provides options and mechanisms to sort classes
*/
reprint?(path: AstPath<T>, options: TransformerEnv): void
}