prettier 3.2.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -2
  3. data/README.md +23 -59
  4. data/lib/prettier.rb +7 -5
  5. data/node_modules/prettier/LICENSE +5205 -0
  6. data/node_modules/prettier/README.md +109 -0
  7. data/node_modules/prettier/{bin-prettier.js → bin/prettier.cjs} +10 -5
  8. data/node_modules/prettier/doc.d.ts +240 -0
  9. data/node_modules/prettier/doc.js +1257 -1309
  10. data/node_modules/prettier/doc.mjs +1312 -0
  11. data/node_modules/prettier/index.cjs +655 -0
  12. data/node_modules/prettier/index.d.ts +915 -0
  13. data/node_modules/prettier/index.mjs +21845 -0
  14. data/node_modules/prettier/internal/cli.mjs +6978 -0
  15. data/node_modules/prettier/internal/internal.mjs +6531 -0
  16. data/node_modules/prettier/package.json +179 -6
  17. data/node_modules/prettier/plugins/acorn.d.ts +6 -0
  18. data/node_modules/prettier/plugins/acorn.js +13 -0
  19. data/node_modules/prettier/plugins/acorn.mjs +13 -0
  20. data/node_modules/prettier/plugins/angular.d.ts +8 -0
  21. data/node_modules/prettier/plugins/angular.js +2 -0
  22. data/node_modules/prettier/plugins/angular.mjs +2 -0
  23. data/node_modules/prettier/plugins/babel.d.ts +17 -0
  24. data/node_modules/prettier/plugins/babel.js +16 -0
  25. data/node_modules/prettier/plugins/babel.mjs +16 -0
  26. data/node_modules/prettier/plugins/estree.d.ts +0 -0
  27. data/node_modules/prettier/plugins/estree.js +35 -0
  28. data/node_modules/prettier/plugins/estree.mjs +35 -0
  29. data/node_modules/prettier/plugins/flow.d.ts +5 -0
  30. data/node_modules/prettier/plugins/flow.js +21 -0
  31. data/node_modules/prettier/plugins/flow.mjs +21 -0
  32. data/node_modules/prettier/plugins/glimmer.d.ts +5 -0
  33. data/node_modules/prettier/plugins/glimmer.js +30 -0
  34. data/node_modules/prettier/plugins/glimmer.mjs +30 -0
  35. data/node_modules/prettier/plugins/graphql.d.ts +5 -0
  36. data/node_modules/prettier/plugins/graphql.js +29 -0
  37. data/node_modules/prettier/plugins/graphql.mjs +29 -0
  38. data/node_modules/prettier/plugins/html.d.ts +8 -0
  39. data/node_modules/prettier/plugins/html.js +19 -0
  40. data/node_modules/prettier/plugins/html.mjs +19 -0
  41. data/node_modules/prettier/plugins/markdown.d.ts +7 -0
  42. data/node_modules/prettier/plugins/markdown.js +59 -0
  43. data/node_modules/prettier/plugins/markdown.mjs +59 -0
  44. data/node_modules/prettier/plugins/meriyah.d.ts +5 -0
  45. data/node_modules/prettier/plugins/meriyah.js +5 -0
  46. data/node_modules/prettier/plugins/meriyah.mjs +5 -0
  47. data/node_modules/prettier/plugins/postcss.d.ts +7 -0
  48. data/node_modules/prettier/plugins/postcss.js +52 -0
  49. data/node_modules/prettier/plugins/postcss.mjs +52 -0
  50. data/node_modules/prettier/plugins/typescript.d.ts +5 -0
  51. data/node_modules/prettier/plugins/typescript.js +27 -0
  52. data/node_modules/prettier/plugins/typescript.mjs +27 -0
  53. data/node_modules/prettier/plugins/yaml.d.ts +5 -0
  54. data/node_modules/prettier/plugins/yaml.js +161 -0
  55. data/node_modules/prettier/plugins/yaml.mjs +161 -0
  56. data/node_modules/prettier/standalone.d.ts +33 -0
  57. data/node_modules/prettier/standalone.js +34 -0
  58. data/node_modules/prettier/standalone.mjs +34 -0
  59. data/package.json +15 -10
  60. data/src/plugin.js +210 -14
  61. data/src/server.rb +50 -85
  62. metadata +60 -28
  63. data/CONTRIBUTING.md +0 -185
  64. data/node_modules/prettier/cli.js +0 -15085
  65. data/node_modules/prettier/index.js +0 -37282
  66. data/node_modules/prettier/parser-angular.js +0 -2
  67. data/node_modules/prettier/parser-babel.js +0 -27
  68. data/node_modules/prettier/parser-espree.js +0 -26
  69. data/node_modules/prettier/parser-flow.js +0 -35
  70. data/node_modules/prettier/parser-glimmer.js +0 -27
  71. data/node_modules/prettier/parser-graphql.js +0 -15
  72. data/node_modules/prettier/parser-html.js +0 -36
  73. data/node_modules/prettier/parser-markdown.js +0 -76
  74. data/node_modules/prettier/parser-meriyah.js +0 -19
  75. data/node_modules/prettier/parser-postcss.js +0 -76
  76. data/node_modules/prettier/parser-typescript.js +0 -280
  77. data/node_modules/prettier/parser-yaml.js +0 -150
  78. data/node_modules/prettier/third-party.js +0 -8978
  79. data/src/getInfo.js +0 -23
  80. data/src/netcat.js +0 -13
  81. data/src/parseSync.js +0 -227
@@ -0,0 +1,109 @@
1
+ ![Prettier Banner](https://unpkg.com/prettier-logo@1.0.3/images/prettier-banner-light.svg)
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/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square"></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).
@@ -42,7 +42,9 @@ var require_please_upgrade_node = __commonJS({
42
42
  if (opts.message) {
43
43
  console.error(opts.message(requiredVersion));
44
44
  } else {
45
- console.error(pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade");
45
+ console.error(
46
+ pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade"
47
+ );
46
48
  }
47
49
  if (opts.hasOwnProperty("exitCode")) {
48
50
  process.exit(opts.exitCode);
@@ -54,9 +56,12 @@ var require_please_upgrade_node = __commonJS({
54
56
  }
55
57
  });
56
58
 
57
- // bin/prettier.js
59
+ // bin/prettier.cjs
58
60
  var pleaseUpgradeNode = require_please_upgrade_node();
59
- var packageJson = require("./package.json");
61
+ var packageJson = require("../package.json");
60
62
  pleaseUpgradeNode(packageJson);
61
- var cli = require("./cli.js");
62
- module.exports = cli.run(process.argv.slice(2));
63
+ function runCli(cli) {
64
+ return cli.run(process.argv.slice(2));
65
+ }
66
+ var dynamicImport = new Function("module", "return import(module)");
67
+ module.exports.promise = dynamicImport("../internal/cli.mjs").then(runCli);
@@ -0,0 +1,240 @@
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
+ contents: Doc;
42
+ break: boolean;
43
+ expandedStates: Doc[];
44
+ }
45
+
46
+ interface HardlineWithoutBreakParent extends Line {
47
+ hard: true;
48
+ }
49
+
50
+ interface IfBreak {
51
+ type: "if-break";
52
+ breakContents: Doc;
53
+ flatContents: Doc;
54
+ }
55
+
56
+ interface Indent {
57
+ type: "indent";
58
+ contents: Doc;
59
+ }
60
+
61
+ interface IndentIfBreak {
62
+ type: "indent-if-break";
63
+ }
64
+
65
+ interface Label {
66
+ type: "label";
67
+ }
68
+
69
+ interface Line {
70
+ type: "line";
71
+ soft?: boolean | undefined;
72
+ hard?: boolean | undefined;
73
+ literal?: boolean | undefined;
74
+ }
75
+
76
+ interface LineSuffix {
77
+ type: "line-suffix";
78
+ contents: Doc;
79
+ }
80
+
81
+ interface LineSuffixBoundary {
82
+ type: "line-suffix-boundary";
83
+ }
84
+
85
+ interface LiterallineWithoutBreakParent extends Line {
86
+ hard: true;
87
+ literal: true;
88
+ }
89
+
90
+ type LiteralLine = [LiterallineWithoutBreakParent, BreakParent];
91
+
92
+ interface Softline extends Line {
93
+ soft: true;
94
+ }
95
+
96
+ type Hardline = [HardlineWithoutBreakParent, BreakParent];
97
+
98
+ interface Trim {
99
+ type: "trim";
100
+ }
101
+
102
+ interface GroupOptions {
103
+ shouldBreak?: boolean | undefined;
104
+ id?: symbol | undefined;
105
+ }
106
+
107
+ function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
108
+
109
+ /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
110
+ function align(widthOrString: Align["n"], doc: Doc): Align;
111
+
112
+ /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
113
+ const breakParent: BreakParent;
114
+
115
+ /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
116
+ function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
117
+
118
+ /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
119
+ function dedent(doc: Doc): Align;
120
+
121
+ /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
122
+ function dedentToRoot(doc: Doc): Align;
123
+
124
+ /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
125
+ function fill(docs: Doc[]): Fill;
126
+
127
+ /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
128
+ function group(doc: Doc, opts?: GroupOptions): Group;
129
+
130
+ /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
131
+ const hardline: Hardline;
132
+
133
+ /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
134
+ const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
135
+
136
+ /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
137
+ function ifBreak(
138
+ ifBreak: Doc,
139
+ noBreak?: Doc,
140
+ options?: { groupId?: symbol | undefined }
141
+ ): IfBreak;
142
+
143
+ /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
144
+ function indent(doc: Doc): Indent;
145
+
146
+ /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
147
+ function indentIfBreak(
148
+ doc: Doc,
149
+ opts: { groupId: symbol; negate?: boolean | undefined }
150
+ ): IndentIfBreak;
151
+
152
+ /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
153
+ function join(sep: Doc, docs: Doc[]): Doc[];
154
+
155
+ /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
156
+ function label(label: any | undefined, contents: Doc): Doc;
157
+
158
+ /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
159
+ const line: Line;
160
+
161
+ /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
162
+ function lineSuffix(suffix: Doc): LineSuffix;
163
+
164
+ /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
165
+ const lineSuffixBoundary: LineSuffixBoundary;
166
+
167
+ /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
168
+ const literalline: LiteralLine;
169
+
170
+ /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
171
+ const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
172
+
173
+ /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
174
+ function markAsRoot(doc: Doc): Align;
175
+
176
+ /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
177
+ const softline: Softline;
178
+
179
+ /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
180
+ const trim: Trim;
181
+
182
+ /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
183
+ const cursor: Cursor;
184
+ }
185
+
186
+ export namespace printer {
187
+ function printDocToString(
188
+ doc: builders.Doc,
189
+ options: Options
190
+ ): {
191
+ formatted: string;
192
+ cursorNodeStart?: number | undefined;
193
+ cursorNodeText?: string | undefined;
194
+ };
195
+ interface Options {
196
+ /**
197
+ * Specify the line length that the printer will wrap on.
198
+ * @default 80
199
+ */
200
+ printWidth: number;
201
+ /**
202
+ * Specify the number of spaces per indentation-level.
203
+ * @default 2
204
+ */
205
+ tabWidth: number;
206
+ /**
207
+ * Indent lines with tabs instead of spaces
208
+ * @default false
209
+ */
210
+ useTabs?: boolean;
211
+ parentParser?: string | undefined;
212
+ __embeddedInHtml?: boolean | undefined;
213
+ }
214
+ }
215
+
216
+ export namespace utils {
217
+ function willBreak(doc: builders.Doc): boolean;
218
+ function traverseDoc(
219
+ doc: builders.Doc,
220
+ onEnter?: (doc: builders.Doc) => void | boolean,
221
+ onExit?: (doc: builders.Doc) => void,
222
+ shouldTraverseConditionalGroups?: boolean
223
+ ): void;
224
+ function findInDoc<T = builders.Doc>(
225
+ doc: builders.Doc,
226
+ callback: (doc: builders.Doc) => T,
227
+ defaultValue: T
228
+ ): T;
229
+ function mapDoc<T = builders.Doc>(
230
+ doc: builders.Doc,
231
+ callback: (doc: builders.Doc) => T
232
+ ): T;
233
+ function removeLines(doc: builders.Doc): builders.Doc;
234
+ function stripTrailingHardline(doc: builders.Doc): builders.Doc;
235
+ function replaceEndOfLine(
236
+ doc: builders.Doc,
237
+ replacement?: builders.Doc
238
+ ): builders.Doc;
239
+ function canBreak(doc: builders.Doc): boolean;
240
+ }