putout 42.7.4 → 42.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +10 -0
- package/lib/index.d.ts +23 -27
- package/package.json +1 -1
- package/types/operator.ts +1 -0
- package/types/plugins.ts +24 -8
package/ChangeLog
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Program,
|
|
4
|
-
Node,
|
|
5
|
-
} from '@putout/babel';
|
|
1
|
+
import {Program, Node} from '@putout/babel';
|
|
2
|
+
import {PrinterOptions, ParseOptions} from '@putout/engine-parser';
|
|
6
3
|
import {PutoutPlugin} from '../types/plugins.ts';
|
|
7
|
-
|
|
4
|
+
export type * from '../types/plugins.ts';
|
|
8
5
|
export * as operator from '../types/operator.ts';
|
|
9
6
|
|
|
10
|
-
export
|
|
7
|
+
export type {
|
|
8
|
+
PrinterOptions,
|
|
9
|
+
ParseOptions,
|
|
10
|
+
};
|
|
11
11
|
export {traverse, types} from '@putout/babel';
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export function parse(source: string, options?: ParseOptions): Program;
|
|
14
|
+
|
|
15
|
+
export function template(source: string, options?: Record<string, unknown>): (...args: unknown[]) => Node;
|
|
14
16
|
export declare namespace template {
|
|
15
17
|
export function ast(source: string, options?: Record<string, unknown>): Node;
|
|
16
18
|
export function program(source: string, options?: Record<string, unknown>): (...args: unknown[]) => Node;
|
|
17
19
|
export function extractExpression(node: Node): Node;
|
|
18
|
-
}
|
|
20
|
+
}
|
|
21
|
+
export function generate(node: Node, options?: Record<string, unknown>, sourceMaps?: Record<string, unknown>): string;
|
|
19
22
|
|
|
20
23
|
type PutoutReturn = {
|
|
21
24
|
code: string;
|
|
22
25
|
places: Place[];
|
|
23
26
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
isJSX?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
27
|
+
type PrinterConfig =
|
|
28
|
+
| 'putout'
|
|
29
|
+
| 'babel'
|
|
30
|
+
| ['putout', PrinterOptions?]
|
|
31
|
+
| ['babel', Record<string, unknown>?];
|
|
32
32
|
type RuleState = 'on' | 'off' | boolean;
|
|
33
33
|
type RuleOptions = Record<string, unknown>;
|
|
34
34
|
type RuleTuple = [
|
|
@@ -47,7 +47,7 @@ export type TransformOptions = {
|
|
|
47
47
|
fix?: boolean;
|
|
48
48
|
fixCount?: number;
|
|
49
49
|
parser?: string;
|
|
50
|
-
printer?:
|
|
50
|
+
printer?: PrinterConfig;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
type Options = ParseOptions & TransformOptions;
|
|
@@ -56,11 +56,7 @@ export default function putout(source: string, options: Options): PutoutReturn;
|
|
|
56
56
|
|
|
57
57
|
export function putoutAsync(source: string, options: Options): Promise<PutoutReturn>;
|
|
58
58
|
|
|
59
|
-
export
|
|
60
|
-
printer?: 'putout' | 'babel' | [string, Record<string, unknown>];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function print(ast: File, options?: PrintOptions): string;
|
|
59
|
+
export function print(ast: Node, options?: PrinterOptions): string;
|
|
64
60
|
|
|
65
61
|
export interface Place {
|
|
66
62
|
rule: string;
|
|
@@ -71,10 +67,10 @@ export interface Place {
|
|
|
71
67
|
};
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
export function transform(ast:
|
|
75
|
-
export function transformAsync(ast:
|
|
76
|
-
export function findPlaces(ast:
|
|
77
|
-
export function findPlacesAsync(ast:
|
|
70
|
+
export function transform(ast: Node, options?: TransformOptions): Place[];
|
|
71
|
+
export function transformAsync(ast: Node, options?: TransformOptions): Promise<Place[]>;
|
|
72
|
+
export function findPlaces(ast: Node, options?: TransformOptions): Place[];
|
|
73
|
+
export function findPlacesAsync(ast: Node, options?: TransformOptions): Promise<Place[]>;
|
|
78
74
|
|
|
79
75
|
export function codeframe(args: {
|
|
80
76
|
source: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "42.7.
|
|
3
|
+
"version": "42.7.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
|
package/types/operator.ts
CHANGED
package/types/plugins.ts
CHANGED
|
@@ -7,15 +7,27 @@ export type Traverse = (helpers: {
|
|
|
7
7
|
pathStore: (path?: NodePath) => NodePath[];
|
|
8
8
|
}) => Record<string, (path: NodePath) => void>;
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export type Traverser = {
|
|
11
11
|
report: Report;
|
|
12
|
-
|
|
13
|
-
fix
|
|
14
|
-
|
|
12
|
+
traverse: Traverse;
|
|
13
|
+
fix: Fix;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type Replacer = {
|
|
17
|
+
report: Report;
|
|
18
|
+
replace: Replace;
|
|
19
|
+
match?: Match;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type Includer = {
|
|
23
|
+
report: Report;
|
|
24
|
+
fix: Fix;
|
|
25
|
+
include: Include;
|
|
15
26
|
exclude?: Exclude;
|
|
16
27
|
filter?: Filter;
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type PutoutPlugin = Replacer | Includer | Traverser;
|
|
19
31
|
|
|
20
32
|
export type Report = () => string;
|
|
21
33
|
|
|
@@ -23,9 +35,9 @@ export type Include = () => string[];
|
|
|
23
35
|
|
|
24
36
|
export type Exclude = () => string[] | (() => boolean);
|
|
25
37
|
|
|
26
|
-
export
|
|
38
|
+
export type PluginOptions = {
|
|
27
39
|
options?: Record<string, unknown>;
|
|
28
|
-
}
|
|
40
|
+
};
|
|
29
41
|
|
|
30
42
|
export type Filter = (path: NodePath, options: PluginOptions) => boolean;
|
|
31
43
|
|
|
@@ -34,3 +46,7 @@ export type Fix = (path: NodePath, options: PluginOptions) => void;
|
|
|
34
46
|
type ReplaceResolver = (vars: Record<string, Node>, path: NodePath) => string | NodePath | '';
|
|
35
47
|
|
|
36
48
|
export type Replace = () => Record<string, string | ReplaceResolver>;
|
|
49
|
+
|
|
50
|
+
type MatchResolver = (vars: Record<string, Node>, path: NodePath) => boolean;
|
|
51
|
+
|
|
52
|
+
export type Match = () => Record<string, MatchResolver>;
|