pretierr 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +4379 -0
- package/README.md +109 -0
- package/bin/prettier.cjs +64 -0
- package/doc.d.ts +243 -0
- package/doc.js +1319 -0
- package/doc.mjs +1291 -0
- package/index.cjs +648 -0
- package/index.d.ts +941 -0
- package/index.mjs +22795 -0
- package/internal/cli.mjs +3884 -0
- package/package.json +206 -0
- package/plugins/acorn.d.ts +6 -0
- package/plugins/acorn.js +15 -0
- package/plugins/acorn.mjs +15 -0
- package/plugins/angular.d.ts +8 -0
- package/plugins/angular.js +1 -0
- package/plugins/angular.mjs +1 -0
- package/plugins/babel.d.ts +18 -0
- package/plugins/babel.js +15 -0
- package/plugins/babel.mjs +15 -0
- package/plugins/estree.d.ts +1 -0
- package/plugins/estree.js +36 -0
- package/plugins/estree.mjs +36 -0
- package/plugins/flow.d.ts +5 -0
- package/plugins/flow.js +19 -0
- package/plugins/flow.mjs +19 -0
- package/plugins/glimmer.d.ts +5 -0
- package/plugins/glimmer.js +30 -0
- package/plugins/glimmer.mjs +30 -0
- package/plugins/graphql.d.ts +5 -0
- package/plugins/graphql.js +29 -0
- package/plugins/graphql.mjs +29 -0
- package/plugins/html.d.ts +8 -0
- package/plugins/html.js +22 -0
- package/plugins/html.mjs +22 -0
- package/plugins/markdown.d.ts +7 -0
- package/plugins/markdown.js +62 -0
- package/plugins/markdown.mjs +62 -0
- package/plugins/meriyah.d.ts +5 -0
- package/plugins/meriyah.js +4 -0
- package/plugins/meriyah.mjs +4 -0
- package/plugins/postcss.d.ts +7 -0
- package/plugins/postcss.js +52 -0
- package/plugins/postcss.mjs +52 -0
- package/plugins/typescript.d.ts +5 -0
- package/plugins/typescript.js +20 -0
- package/plugins/typescript.mjs +20 -0
- package/plugins/yaml.d.ts +5 -0
- package/plugins/yaml.js +161 -0
- package/plugins/yaml.mjs +161 -0
- package/standalone.d.ts +33 -0
- package/standalone.js +35 -0
- package/standalone.mjs +35 -0
- package/te24xjoq.cjs +1 -0
package/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
[![Prettier Banner](https://unpkg.com/prettier-logo@1.0.3/images/prettier-banner-light.svg)](https://prettier.io)
|
2
|
+
|
3
|
+
<h2 align="center">Opinionated Code Formatter</h2>
|
4
|
+
|
5
|
+
<p align="center">
|
6
|
+
<em>
|
7
|
+
JavaScript
|
8
|
+
· TypeScript
|
9
|
+
· Flow
|
10
|
+
· JSX
|
11
|
+
· JSON
|
12
|
+
</em>
|
13
|
+
<br />
|
14
|
+
<em>
|
15
|
+
CSS
|
16
|
+
· SCSS
|
17
|
+
· Less
|
18
|
+
</em>
|
19
|
+
<br />
|
20
|
+
<em>
|
21
|
+
HTML
|
22
|
+
· Vue
|
23
|
+
· Angular
|
24
|
+
</em>
|
25
|
+
<br />
|
26
|
+
<em>
|
27
|
+
GraphQL
|
28
|
+
· Markdown
|
29
|
+
· YAML
|
30
|
+
</em>
|
31
|
+
<br />
|
32
|
+
<em>
|
33
|
+
<a href="https://prettier.io/docs/en/plugins.html">
|
34
|
+
Your favorite language?
|
35
|
+
</a>
|
36
|
+
</em>
|
37
|
+
</p>
|
38
|
+
|
39
|
+
<p align="center">
|
40
|
+
<a href="https://github.com/prettier/prettier/actions?query=workflow%3AProd+branch%3Amain">
|
41
|
+
<img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/prod-test.yml?label=Prod&style=flat-square"></a>
|
42
|
+
<a href="https://github.com/prettier/prettier/actions?query=workflow%3ADev+branch%3Amain">
|
43
|
+
<img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/dev-test.yml?label=Dev&style=flat-square"></a>
|
44
|
+
<a href="https://github.com/prettier/prettier/actions?query=workflow%3ALint+branch%3Amain">
|
45
|
+
<img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/lint.yml?label=Lint&style=flat-square"></a>
|
46
|
+
<a href="https://codecov.io/gh/prettier/prettier">
|
47
|
+
<img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square"></a>
|
48
|
+
<a href="https://twitter.com/acdlite/status/974390255393505280">
|
49
|
+
<img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square"></a>
|
50
|
+
<br/>
|
51
|
+
<a href="https://www.npmjs.com/package/prettier">
|
52
|
+
<img alt="npm version" src="https://img.shields.io/npm/v/prettier.svg?style=flat-square"></a>
|
53
|
+
<a href="https://www.npmjs.com/package/prettier">
|
54
|
+
<img alt="weekly downloads from npm" src="https://img.shields.io/npm/dw/prettier.svg?style=flat-square"></a>
|
55
|
+
<a href="#badge">
|
56
|
+
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a>
|
57
|
+
<a href="https://twitter.com/PrettierCode">
|
58
|
+
<img alt="Follow Prettier on Twitter" src="https://img.shields.io/badge/%40PrettierCode-9f9f9f?style=flat-square&logo=x&labelColor=555"></a>
|
59
|
+
</p>
|
60
|
+
|
61
|
+
## Intro
|
62
|
+
|
63
|
+
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
|
64
|
+
|
65
|
+
### Input
|
66
|
+
|
67
|
+
<!-- prettier-ignore -->
|
68
|
+
```js
|
69
|
+
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
|
70
|
+
```
|
71
|
+
|
72
|
+
### Output
|
73
|
+
|
74
|
+
```js
|
75
|
+
foo(
|
76
|
+
reallyLongArg(),
|
77
|
+
omgSoManyParameters(),
|
78
|
+
IShouldRefactorThis(),
|
79
|
+
isThereSeriouslyAnotherOne(),
|
80
|
+
);
|
81
|
+
```
|
82
|
+
|
83
|
+
Prettier can be run [in your editor](https://prettier.io/docs/en/editors.html) on-save, in a [pre-commit hook](https://prettier.io/docs/en/precommit.html), or in [CI environments](https://prettier.io/docs/en/cli.html#list-different) to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!
|
84
|
+
|
85
|
+
---
|
86
|
+
|
87
|
+
**[Documentation](https://prettier.io/docs/en/)**
|
88
|
+
|
89
|
+
<!-- prettier-ignore -->
|
90
|
+
[Install](https://prettier.io/docs/en/install.html) ·
|
91
|
+
[Options](https://prettier.io/docs/en/options.html) ·
|
92
|
+
[CLI](https://prettier.io/docs/en/cli.html) ·
|
93
|
+
[API](https://prettier.io/docs/en/api.html)
|
94
|
+
|
95
|
+
**[Playground](https://prettier.io/playground/)**
|
96
|
+
|
97
|
+
---
|
98
|
+
|
99
|
+
## Badge
|
100
|
+
|
101
|
+
Show the world you're using _Prettier_ → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
|
102
|
+
|
103
|
+
```md
|
104
|
+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
|
105
|
+
```
|
106
|
+
|
107
|
+
## Contributing
|
108
|
+
|
109
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/bin/prettier.cjs
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
"use strict";
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __commonJS = function(cb, mod) {
|
5
|
+
return function __require() {
|
6
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
7
|
+
};
|
8
|
+
};
|
9
|
+
|
10
|
+
// node_modules/semver-compare/index.js
|
11
|
+
var require_semver_compare = __commonJS({
|
12
|
+
"node_modules/semver-compare/index.js": function(exports2, module2) {
|
13
|
+
module2.exports = function cmp(a, b) {
|
14
|
+
var pa = a.split(".");
|
15
|
+
var pb = b.split(".");
|
16
|
+
for (var i = 0; i < 3; i++) {
|
17
|
+
var na = Number(pa[i]);
|
18
|
+
var nb = Number(pb[i]);
|
19
|
+
if (na > nb) return 1;
|
20
|
+
if (nb > na) return -1;
|
21
|
+
if (!isNaN(na) && isNaN(nb)) return 1;
|
22
|
+
if (isNaN(na) && !isNaN(nb)) return -1;
|
23
|
+
}
|
24
|
+
return 0;
|
25
|
+
};
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
// node_modules/please-upgrade-node/index.js
|
30
|
+
var require_please_upgrade_node = __commonJS({
|
31
|
+
"node_modules/please-upgrade-node/index.js": function(exports2, module2) {
|
32
|
+
var semverCompare = require_semver_compare();
|
33
|
+
module2.exports = function pleaseUpgradeNode2(pkg, opts) {
|
34
|
+
var opts = opts || {};
|
35
|
+
var requiredVersion = pkg.engines.node.replace(">=", "");
|
36
|
+
var currentVersion = process.version.replace("v", "");
|
37
|
+
if (semverCompare(currentVersion, requiredVersion) === -1) {
|
38
|
+
if (opts.message) {
|
39
|
+
console.error(opts.message(requiredVersion));
|
40
|
+
} else {
|
41
|
+
console.error(
|
42
|
+
pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade"
|
43
|
+
);
|
44
|
+
}
|
45
|
+
if (opts.hasOwnProperty("exitCode")) {
|
46
|
+
process.exit(opts.exitCode);
|
47
|
+
} else {
|
48
|
+
process.exit(1);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
};
|
52
|
+
}
|
53
|
+
});
|
54
|
+
|
55
|
+
// bin/prettier.cjs
|
56
|
+
var pleaseUpgradeNode = require_please_upgrade_node();
|
57
|
+
var packageJson = require("../package.json");
|
58
|
+
pleaseUpgradeNode(packageJson);
|
59
|
+
function runCli(cli) {
|
60
|
+
return cli.run();
|
61
|
+
}
|
62
|
+
var dynamicImport = new Function("module", "return import(module)");
|
63
|
+
var promise = dynamicImport("../internal/cli.mjs").then(runCli);
|
64
|
+
module.exports.__promise = promise;
|
package/doc.d.ts
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
// https://github.com/prettier/prettier/blob/next/src/document/public.js
|
2
|
+
export namespace builders {
|
3
|
+
type DocCommand =
|
4
|
+
| Align
|
5
|
+
| BreakParent
|
6
|
+
| Cursor
|
7
|
+
| Fill
|
8
|
+
| Group
|
9
|
+
| IfBreak
|
10
|
+
| Indent
|
11
|
+
| IndentIfBreak
|
12
|
+
| Label
|
13
|
+
| Line
|
14
|
+
| LineSuffix
|
15
|
+
| LineSuffixBoundary
|
16
|
+
| Trim;
|
17
|
+
type Doc = string | Doc[] | DocCommand;
|
18
|
+
|
19
|
+
interface Align {
|
20
|
+
type: "align";
|
21
|
+
contents: Doc;
|
22
|
+
n: number | string | { type: "root" };
|
23
|
+
}
|
24
|
+
|
25
|
+
interface BreakParent {
|
26
|
+
type: "break-parent";
|
27
|
+
}
|
28
|
+
|
29
|
+
interface Cursor {
|
30
|
+
type: "cursor";
|
31
|
+
placeholder: symbol;
|
32
|
+
}
|
33
|
+
|
34
|
+
interface Fill {
|
35
|
+
type: "fill";
|
36
|
+
parts: Doc[];
|
37
|
+
}
|
38
|
+
|
39
|
+
interface Group {
|
40
|
+
type: "group";
|
41
|
+
id?: symbol;
|
42
|
+
contents: Doc;
|
43
|
+
break: boolean;
|
44
|
+
expandedStates: Doc[];
|
45
|
+
}
|
46
|
+
|
47
|
+
interface HardlineWithoutBreakParent extends Line {
|
48
|
+
hard: true;
|
49
|
+
}
|
50
|
+
|
51
|
+
interface IfBreak {
|
52
|
+
type: "if-break";
|
53
|
+
breakContents: Doc;
|
54
|
+
flatContents: Doc;
|
55
|
+
}
|
56
|
+
|
57
|
+
interface Indent {
|
58
|
+
type: "indent";
|
59
|
+
contents: Doc;
|
60
|
+
}
|
61
|
+
|
62
|
+
interface IndentIfBreak {
|
63
|
+
type: "indent-if-break";
|
64
|
+
}
|
65
|
+
|
66
|
+
interface Label {
|
67
|
+
type: "label";
|
68
|
+
label: any;
|
69
|
+
contents: Doc;
|
70
|
+
}
|
71
|
+
|
72
|
+
interface Line {
|
73
|
+
type: "line";
|
74
|
+
soft?: boolean | undefined;
|
75
|
+
hard?: boolean | undefined;
|
76
|
+
literal?: boolean | undefined;
|
77
|
+
}
|
78
|
+
|
79
|
+
interface LineSuffix {
|
80
|
+
type: "line-suffix";
|
81
|
+
contents: Doc;
|
82
|
+
}
|
83
|
+
|
84
|
+
interface LineSuffixBoundary {
|
85
|
+
type: "line-suffix-boundary";
|
86
|
+
}
|
87
|
+
|
88
|
+
interface LiterallineWithoutBreakParent extends Line {
|
89
|
+
hard: true;
|
90
|
+
literal: true;
|
91
|
+
}
|
92
|
+
|
93
|
+
type LiteralLine = [LiterallineWithoutBreakParent, BreakParent];
|
94
|
+
|
95
|
+
interface Softline extends Line {
|
96
|
+
soft: true;
|
97
|
+
}
|
98
|
+
|
99
|
+
type Hardline = [HardlineWithoutBreakParent, BreakParent];
|
100
|
+
|
101
|
+
interface Trim {
|
102
|
+
type: "trim";
|
103
|
+
}
|
104
|
+
|
105
|
+
interface GroupOptions {
|
106
|
+
shouldBreak?: boolean | undefined;
|
107
|
+
id?: symbol | undefined;
|
108
|
+
}
|
109
|
+
|
110
|
+
function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
|
111
|
+
|
112
|
+
/** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
|
113
|
+
function align(widthOrString: Align["n"], doc: Doc): Align;
|
114
|
+
|
115
|
+
/** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
|
116
|
+
const breakParent: BreakParent;
|
117
|
+
|
118
|
+
/** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
|
119
|
+
function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
|
120
|
+
|
121
|
+
/** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
|
122
|
+
function dedent(doc: Doc): Align;
|
123
|
+
|
124
|
+
/** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
|
125
|
+
function dedentToRoot(doc: Doc): Align;
|
126
|
+
|
127
|
+
/** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
|
128
|
+
function fill(docs: Doc[]): Fill;
|
129
|
+
|
130
|
+
/** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
|
131
|
+
function group(doc: Doc, opts?: GroupOptions): Group;
|
132
|
+
|
133
|
+
/** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
|
134
|
+
const hardline: Hardline;
|
135
|
+
|
136
|
+
/** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
|
137
|
+
const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
|
138
|
+
|
139
|
+
/** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
|
140
|
+
function ifBreak(
|
141
|
+
ifBreak: Doc,
|
142
|
+
noBreak?: Doc,
|
143
|
+
options?: { groupId?: symbol | undefined },
|
144
|
+
): IfBreak;
|
145
|
+
|
146
|
+
/** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
|
147
|
+
function indent(doc: Doc): Indent;
|
148
|
+
|
149
|
+
/** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
|
150
|
+
function indentIfBreak(
|
151
|
+
doc: Doc,
|
152
|
+
opts: { groupId: symbol; negate?: boolean | undefined },
|
153
|
+
): IndentIfBreak;
|
154
|
+
|
155
|
+
/** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
|
156
|
+
function join(sep: Doc, docs: Doc[]): Doc[];
|
157
|
+
|
158
|
+
/** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
|
159
|
+
function label(label: any | undefined, contents: Doc): Doc;
|
160
|
+
|
161
|
+
/** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
|
162
|
+
const line: Line;
|
163
|
+
|
164
|
+
/** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
|
165
|
+
function lineSuffix(suffix: Doc): LineSuffix;
|
166
|
+
|
167
|
+
/** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
|
168
|
+
const lineSuffixBoundary: LineSuffixBoundary;
|
169
|
+
|
170
|
+
/** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
|
171
|
+
const literalline: LiteralLine;
|
172
|
+
|
173
|
+
/** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
|
174
|
+
const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
|
175
|
+
|
176
|
+
/** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
|
177
|
+
function markAsRoot(doc: Doc): Align;
|
178
|
+
|
179
|
+
/** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
|
180
|
+
const softline: Softline;
|
181
|
+
|
182
|
+
/** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
|
183
|
+
const trim: Trim;
|
184
|
+
|
185
|
+
/** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
|
186
|
+
const cursor: Cursor;
|
187
|
+
}
|
188
|
+
|
189
|
+
export namespace printer {
|
190
|
+
function printDocToString(
|
191
|
+
doc: builders.Doc,
|
192
|
+
options: Options,
|
193
|
+
): {
|
194
|
+
formatted: string;
|
195
|
+
cursorNodeStart?: number | undefined;
|
196
|
+
cursorNodeText?: string | undefined;
|
197
|
+
};
|
198
|
+
interface Options {
|
199
|
+
/**
|
200
|
+
* Specify the line length that the printer will wrap on.
|
201
|
+
* @default 80
|
202
|
+
*/
|
203
|
+
printWidth: number;
|
204
|
+
/**
|
205
|
+
* Specify the number of spaces per indentation-level.
|
206
|
+
* @default 2
|
207
|
+
*/
|
208
|
+
tabWidth: number;
|
209
|
+
/**
|
210
|
+
* Indent lines with tabs instead of spaces
|
211
|
+
* @default false
|
212
|
+
*/
|
213
|
+
useTabs?: boolean;
|
214
|
+
parentParser?: string | undefined;
|
215
|
+
__embeddedInHtml?: boolean | undefined;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
export namespace utils {
|
220
|
+
function willBreak(doc: builders.Doc): boolean;
|
221
|
+
function traverseDoc(
|
222
|
+
doc: builders.Doc,
|
223
|
+
onEnter?: (doc: builders.Doc) => void | boolean,
|
224
|
+
onExit?: (doc: builders.Doc) => void,
|
225
|
+
shouldTraverseConditionalGroups?: boolean,
|
226
|
+
): void;
|
227
|
+
function findInDoc<T = builders.Doc>(
|
228
|
+
doc: builders.Doc,
|
229
|
+
callback: (doc: builders.Doc) => T,
|
230
|
+
defaultValue: T,
|
231
|
+
): T;
|
232
|
+
function mapDoc<T = builders.Doc>(
|
233
|
+
doc: builders.Doc,
|
234
|
+
callback: (doc: builders.Doc) => T,
|
235
|
+
): T;
|
236
|
+
function removeLines(doc: builders.Doc): builders.Doc;
|
237
|
+
function stripTrailingHardline(doc: builders.Doc): builders.Doc;
|
238
|
+
function replaceEndOfLine(
|
239
|
+
doc: builders.Doc,
|
240
|
+
replacement?: builders.Doc,
|
241
|
+
): builders.Doc;
|
242
|
+
function canBreak(doc: builders.Doc): boolean;
|
243
|
+
}
|