prettier 3.0.0-alpha.4 → 3.0.0-alpha.5
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/LICENSE +849 -415
- package/README.md +3 -3
- package/doc.d.ts +248 -0
- package/doc.js +274 -199
- package/doc.mjs +269 -194
- package/index.cjs +380 -201
- package/index.d.ts +903 -0
- package/index.mjs +7539 -5795
- package/internal/cli.mjs +2025 -3219
- package/internal/third-party.mjs +2948 -5593
- package/package.json +32 -1
- package/plugins/acorn-and-espree.d.ts +10 -0
- package/plugins/acorn-and-espree.js +12 -12
- package/plugins/acorn-and-espree.mjs +12 -12
- package/plugins/angular.d.ts +11 -0
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.d.ts +16 -0
- package/plugins/babel.js +13 -13
- package/plugins/babel.mjs +13 -13
- package/plugins/flow.d.ts +8 -0
- package/plugins/flow.js +20 -20
- package/plugins/flow.mjs +20 -20
- package/plugins/glimmer.d.ts +8 -0
- package/plugins/glimmer.js +18 -17
- package/plugins/glimmer.mjs +18 -17
- package/plugins/graphql.d.ts +8 -0
- package/plugins/graphql.js +7 -7
- package/plugins/graphql.mjs +7 -7
- package/plugins/html.d.ts +11 -0
- package/plugins/html.js +17 -28
- package/plugins/html.mjs +17 -28
- package/plugins/markdown.d.ts +10 -0
- package/plugins/markdown.js +28 -29
- package/plugins/markdown.mjs +28 -29
- package/plugins/meriyah.d.ts +8 -0
- package/plugins/meriyah.js +5 -6
- package/plugins/meriyah.mjs +5 -6
- package/plugins/postcss.d.ts +10 -0
- package/plugins/postcss.js +32 -43
- package/plugins/postcss.mjs +32 -43
- package/plugins/typescript.d.ts +8 -0
- package/plugins/typescript.js +18 -27
- package/plugins/typescript.mjs +18 -27
- package/plugins/yaml.d.ts +8 -0
- package/plugins/yaml.js +108 -108
- package/plugins/yaml.mjs +108 -108
- package/standalone.d.ts +33 -0
- package/standalone.js +74 -80
- package/standalone.mjs +74 -80
package/index.cjs
CHANGED
|
@@ -24,39 +24,83 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
26
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
31
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
32
|
mod
|
|
29
33
|
));
|
|
30
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
35
|
|
|
32
|
-
//
|
|
33
|
-
function
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
+
// src/utils/skip-inline-comment.js
|
|
37
|
+
function skipInlineComment(text, startIndex) {
|
|
38
|
+
if (startIndex === false) {
|
|
39
|
+
return false;
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "*") {
|
|
42
|
+
for (let i = startIndex + 2; i < text.length; ++i) {
|
|
43
|
+
if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
|
|
44
|
+
return i + 2;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return startIndex;
|
|
38
49
|
}
|
|
39
|
-
var
|
|
40
|
-
|
|
50
|
+
var skip_inline_comment_default;
|
|
51
|
+
var init_skip_inline_comment = __esm({
|
|
52
|
+
"src/utils/skip-inline-comment.js"() {
|
|
53
|
+
skip_inline_comment_default = skipInlineComment;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// src/utils/skip-newline.js
|
|
58
|
+
function skipNewline(text, startIndex, options) {
|
|
59
|
+
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
|
60
|
+
if (startIndex === false) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const character = text.charAt(startIndex);
|
|
64
|
+
if (backwards) {
|
|
65
|
+
if (text.charAt(startIndex - 1) === "\r" && character === "\n") {
|
|
66
|
+
return startIndex - 2;
|
|
67
|
+
}
|
|
68
|
+
if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
|
|
69
|
+
return startIndex - 1;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (character === "\r" && text.charAt(startIndex + 1) === "\n") {
|
|
73
|
+
return startIndex + 2;
|
|
74
|
+
}
|
|
75
|
+
if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
|
|
76
|
+
return startIndex + 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return startIndex;
|
|
80
|
+
}
|
|
81
|
+
var skip_newline_default;
|
|
82
|
+
var init_skip_newline = __esm({
|
|
83
|
+
"src/utils/skip-newline.js"() {
|
|
84
|
+
skip_newline_default = skipNewline;
|
|
41
85
|
}
|
|
42
86
|
});
|
|
43
87
|
|
|
44
|
-
// src/utils/
|
|
45
|
-
function skip(
|
|
46
|
-
return (text,
|
|
47
|
-
const backwards =
|
|
48
|
-
if (
|
|
88
|
+
// src/utils/skip.js
|
|
89
|
+
function skip(characters) {
|
|
90
|
+
return (text, startIndex, options) => {
|
|
91
|
+
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
|
92
|
+
if (startIndex === false) {
|
|
49
93
|
return false;
|
|
50
94
|
}
|
|
51
95
|
const { length } = text;
|
|
52
|
-
let cursor =
|
|
96
|
+
let cursor = startIndex;
|
|
53
97
|
while (cursor >= 0 && cursor < length) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (!
|
|
98
|
+
const character = text.charAt(cursor);
|
|
99
|
+
if (characters instanceof RegExp) {
|
|
100
|
+
if (!characters.test(character)) {
|
|
57
101
|
return cursor;
|
|
58
102
|
}
|
|
59
|
-
} else if (!
|
|
103
|
+
} else if (!characters.includes(character)) {
|
|
60
104
|
return cursor;
|
|
61
105
|
}
|
|
62
106
|
backwards ? cursor-- : cursor++;
|
|
@@ -69,7 +113,7 @@ function skip(chars) {
|
|
|
69
113
|
}
|
|
70
114
|
var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
|
|
71
115
|
var init_skip = __esm({
|
|
72
|
-
"src/utils/
|
|
116
|
+
"src/utils/skip.js"() {
|
|
73
117
|
skipWhitespace = skip(/\s/);
|
|
74
118
|
skipSpaces = skip(" ");
|
|
75
119
|
skipToLineEnd = skip(",; ");
|
|
@@ -77,80 +121,28 @@ var init_skip = __esm({
|
|
|
77
121
|
}
|
|
78
122
|
});
|
|
79
123
|
|
|
80
|
-
// src/utils/
|
|
81
|
-
function
|
|
82
|
-
if (
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
|
|
86
|
-
for (let i = index + 2; i < text.length; ++i) {
|
|
87
|
-
if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
|
|
88
|
-
return i + 2;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return index;
|
|
93
|
-
}
|
|
94
|
-
var skip_inline_comment_default;
|
|
95
|
-
var init_skip_inline_comment = __esm({
|
|
96
|
-
"src/utils/text/skip-inline-comment.js"() {
|
|
97
|
-
skip_inline_comment_default = skipInlineComment;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// src/utils/text/skip-trailing-comment.js
|
|
102
|
-
function skipTrailingComment(text, index) {
|
|
103
|
-
if (index === false) {
|
|
124
|
+
// src/utils/skip-trailing-comment.js
|
|
125
|
+
function skipTrailingComment(text, startIndex) {
|
|
126
|
+
if (startIndex === false) {
|
|
104
127
|
return false;
|
|
105
128
|
}
|
|
106
|
-
if (text.charAt(
|
|
107
|
-
return skipEverythingButNewLine(text,
|
|
129
|
+
if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "/") {
|
|
130
|
+
return skipEverythingButNewLine(text, startIndex);
|
|
108
131
|
}
|
|
109
|
-
return
|
|
132
|
+
return startIndex;
|
|
110
133
|
}
|
|
111
134
|
var skip_trailing_comment_default;
|
|
112
135
|
var init_skip_trailing_comment = __esm({
|
|
113
|
-
"src/utils/
|
|
136
|
+
"src/utils/skip-trailing-comment.js"() {
|
|
114
137
|
init_skip();
|
|
115
138
|
skip_trailing_comment_default = skipTrailingComment;
|
|
116
139
|
}
|
|
117
140
|
});
|
|
118
141
|
|
|
119
|
-
// src/utils/
|
|
120
|
-
function
|
|
121
|
-
const backwards = opts && opts.backwards;
|
|
122
|
-
if (index === false) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
const atIndex = text.charAt(index);
|
|
126
|
-
if (backwards) {
|
|
127
|
-
if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
|
|
128
|
-
return index - 2;
|
|
129
|
-
}
|
|
130
|
-
if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
|
|
131
|
-
return index - 1;
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
|
|
135
|
-
return index + 2;
|
|
136
|
-
}
|
|
137
|
-
if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
|
|
138
|
-
return index + 1;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return index;
|
|
142
|
-
}
|
|
143
|
-
var skip_newline_default;
|
|
144
|
-
var init_skip_newline = __esm({
|
|
145
|
-
"src/utils/text/skip-newline.js"() {
|
|
146
|
-
skip_newline_default = skipNewline;
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// src/utils/text/get-next-non-space-non-comment-character-index-with-start-index.js
|
|
151
|
-
function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
|
|
142
|
+
// src/utils/get-next-non-space-non-comment-character-index.js
|
|
143
|
+
function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
|
|
152
144
|
let oldIdx = null;
|
|
153
|
-
let nextIdx =
|
|
145
|
+
let nextIdx = startIndex;
|
|
154
146
|
while (nextIdx !== oldIdx) {
|
|
155
147
|
oldIdx = nextIdx;
|
|
156
148
|
nextIdx = skipSpaces(text, nextIdx);
|
|
@@ -160,20 +152,110 @@ function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
|
|
|
160
152
|
}
|
|
161
153
|
return nextIdx;
|
|
162
154
|
}
|
|
163
|
-
var
|
|
164
|
-
var
|
|
165
|
-
"src/utils/
|
|
155
|
+
var get_next_non_space_non_comment_character_index_default;
|
|
156
|
+
var init_get_next_non_space_non_comment_character_index = __esm({
|
|
157
|
+
"src/utils/get-next-non-space-non-comment-character-index.js"() {
|
|
166
158
|
init_skip_inline_comment();
|
|
167
159
|
init_skip_newline();
|
|
168
160
|
init_skip_trailing_comment();
|
|
169
161
|
init_skip();
|
|
170
|
-
|
|
162
|
+
get_next_non_space_non_comment_character_index_default = getNextNonSpaceNonCommentCharacterIndex;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// src/utils/is-previous-line-empty.js
|
|
167
|
+
function isPreviousLineEmpty(text, startIndex) {
|
|
168
|
+
let idx = startIndex - 1;
|
|
169
|
+
idx = skipSpaces(text, idx, { backwards: true });
|
|
170
|
+
idx = skip_newline_default(text, idx, { backwards: true });
|
|
171
|
+
idx = skipSpaces(text, idx, { backwards: true });
|
|
172
|
+
const idx2 = skip_newline_default(text, idx, { backwards: true });
|
|
173
|
+
return idx !== idx2;
|
|
174
|
+
}
|
|
175
|
+
var is_previous_line_empty_default;
|
|
176
|
+
var init_is_previous_line_empty = __esm({
|
|
177
|
+
"src/utils/is-previous-line-empty.js"() {
|
|
178
|
+
init_skip_newline();
|
|
179
|
+
init_skip();
|
|
180
|
+
is_previous_line_empty_default = isPreviousLineEmpty;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// src/utils/has-newline.js
|
|
185
|
+
function hasNewline(text, startIndex, options = {}) {
|
|
186
|
+
const idx = skipSpaces(
|
|
187
|
+
text,
|
|
188
|
+
options.backwards ? startIndex - 1 : startIndex,
|
|
189
|
+
options
|
|
190
|
+
);
|
|
191
|
+
const idx2 = skip_newline_default(text, idx, options);
|
|
192
|
+
return idx !== idx2;
|
|
193
|
+
}
|
|
194
|
+
var has_newline_default;
|
|
195
|
+
var init_has_newline = __esm({
|
|
196
|
+
"src/utils/has-newline.js"() {
|
|
197
|
+
init_skip();
|
|
198
|
+
init_skip_newline();
|
|
199
|
+
has_newline_default = hasNewline;
|
|
171
200
|
}
|
|
172
201
|
});
|
|
173
202
|
|
|
174
|
-
// src/utils/is-
|
|
175
|
-
|
|
176
|
-
|
|
203
|
+
// src/utils/is-next-line-empty.js
|
|
204
|
+
function isNextLineEmpty(text, startIndex) {
|
|
205
|
+
let oldIdx = null;
|
|
206
|
+
let idx = startIndex;
|
|
207
|
+
while (idx !== oldIdx) {
|
|
208
|
+
oldIdx = idx;
|
|
209
|
+
idx = skipToLineEnd(text, idx);
|
|
210
|
+
idx = skip_inline_comment_default(text, idx);
|
|
211
|
+
idx = skipSpaces(text, idx);
|
|
212
|
+
}
|
|
213
|
+
idx = skip_trailing_comment_default(text, idx);
|
|
214
|
+
idx = skip_newline_default(text, idx);
|
|
215
|
+
return idx !== false && has_newline_default(text, idx);
|
|
216
|
+
}
|
|
217
|
+
var is_next_line_empty_default;
|
|
218
|
+
var init_is_next_line_empty = __esm({
|
|
219
|
+
"src/utils/is-next-line-empty.js"() {
|
|
220
|
+
init_skip_newline();
|
|
221
|
+
init_skip();
|
|
222
|
+
init_skip_inline_comment();
|
|
223
|
+
init_skip_trailing_comment();
|
|
224
|
+
init_has_newline();
|
|
225
|
+
is_next_line_empty_default = isNextLineEmpty;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// node_modules/escape-string-regexp/index.js
|
|
230
|
+
function escapeStringRegexp(string) {
|
|
231
|
+
if (typeof string !== "string") {
|
|
232
|
+
throw new TypeError("Expected a string");
|
|
233
|
+
}
|
|
234
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
235
|
+
}
|
|
236
|
+
var init_escape_string_regexp = __esm({
|
|
237
|
+
"node_modules/escape-string-regexp/index.js"() {
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// src/utils/get-max-continuous-count.js
|
|
242
|
+
function getMaxContinuousCount(text, searchString) {
|
|
243
|
+
const results = text.match(
|
|
244
|
+
new RegExp(`(${escapeStringRegexp(searchString)})+`, "g")
|
|
245
|
+
);
|
|
246
|
+
if (results === null) {
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
249
|
+
return results.reduce(
|
|
250
|
+
(maxCount, result) => Math.max(maxCount, result.length / searchString.length),
|
|
251
|
+
0
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
var get_max_continuous_count_default;
|
|
255
|
+
var init_get_max_continuous_count = __esm({
|
|
256
|
+
"src/utils/get-max-continuous-count.js"() {
|
|
257
|
+
init_escape_string_regexp();
|
|
258
|
+
get_max_continuous_count_default = getMaxContinuousCount;
|
|
177
259
|
}
|
|
178
260
|
});
|
|
179
261
|
|
|
@@ -208,7 +290,22 @@ function isFullwidthCodePoint(codePoint) {
|
|
|
208
290
|
if (!Number.isInteger(codePoint)) {
|
|
209
291
|
return false;
|
|
210
292
|
}
|
|
211
|
-
return codePoint >= 4352 && (codePoint <= 4447 ||
|
|
293
|
+
return codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo
|
|
294
|
+
codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET
|
|
295
|
+
codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET
|
|
296
|
+
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
|
297
|
+
11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
|
298
|
+
12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals
|
|
299
|
+
19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A
|
|
300
|
+
43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables
|
|
301
|
+
44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs
|
|
302
|
+
63744 <= codePoint && codePoint <= 64255 || // Vertical Forms
|
|
303
|
+
65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants
|
|
304
|
+
65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms
|
|
305
|
+
65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement
|
|
306
|
+
110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement
|
|
307
|
+
127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
|
308
|
+
131072 <= codePoint && codePoint <= 262141);
|
|
212
309
|
}
|
|
213
310
|
var init_is_fullwidth_code_point = __esm({
|
|
214
311
|
"node_modules/string-width/node_modules/is-fullwidth-code-point/index.js"() {
|
|
@@ -279,58 +376,11 @@ var init_get_string_width = __esm({
|
|
|
279
376
|
}
|
|
280
377
|
});
|
|
281
378
|
|
|
282
|
-
// src/
|
|
283
|
-
function
|
|
284
|
-
const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
|
|
285
|
-
const idx2 = skip_newline_default(text, idx, opts);
|
|
286
|
-
return idx !== idx2;
|
|
287
|
-
}
|
|
288
|
-
function hasNewlineInRange(text, start, end) {
|
|
289
|
-
for (let i = start; i < end; ++i) {
|
|
290
|
-
if (text.charAt(i) === "\n") {
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
function isPreviousLineEmpty(text, node, locStart) {
|
|
297
|
-
let idx = locStart(node) - 1;
|
|
298
|
-
idx = skipSpaces(text, idx, { backwards: true });
|
|
299
|
-
idx = skip_newline_default(text, idx, { backwards: true });
|
|
300
|
-
idx = skipSpaces(text, idx, { backwards: true });
|
|
301
|
-
const idx2 = skip_newline_default(text, idx, { backwards: true });
|
|
302
|
-
return idx !== idx2;
|
|
303
|
-
}
|
|
304
|
-
function isNextLineEmptyAfterIndex(text, index) {
|
|
305
|
-
let oldIdx = null;
|
|
306
|
-
let idx = index;
|
|
307
|
-
while (idx !== oldIdx) {
|
|
308
|
-
oldIdx = idx;
|
|
309
|
-
idx = skipToLineEnd(text, idx);
|
|
310
|
-
idx = skip_inline_comment_default(text, idx);
|
|
311
|
-
idx = skipSpaces(text, idx);
|
|
312
|
-
}
|
|
313
|
-
idx = skip_trailing_comment_default(text, idx);
|
|
314
|
-
idx = skip_newline_default(text, idx);
|
|
315
|
-
return idx !== false && hasNewline(text, idx);
|
|
316
|
-
}
|
|
317
|
-
function isNextLineEmpty(text, node, locEnd) {
|
|
318
|
-
return isNextLineEmptyAfterIndex(text, locEnd(node));
|
|
319
|
-
}
|
|
320
|
-
function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
|
321
|
-
return get_next_non_space_non_comment_character_index_with_start_index_default(
|
|
322
|
-
text,
|
|
323
|
-
locEnd(node)
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
function hasSpaces(text, index, opts = {}) {
|
|
327
|
-
const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
|
|
328
|
-
return idx !== index;
|
|
329
|
-
}
|
|
330
|
-
function getAlignmentSize(value, tabWidth, startIndex = 0) {
|
|
379
|
+
// src/utils/get-alignment-size.js
|
|
380
|
+
function getAlignmentSize(text, tabWidth, startIndex = 0) {
|
|
331
381
|
let size = 0;
|
|
332
|
-
for (let i = startIndex; i <
|
|
333
|
-
if (
|
|
382
|
+
for (let i = startIndex; i < text.length; ++i) {
|
|
383
|
+
if (text[i] === " ") {
|
|
334
384
|
size = size + tabWidth - size % tabWidth;
|
|
335
385
|
} else {
|
|
336
386
|
size++;
|
|
@@ -338,44 +388,141 @@ function getAlignmentSize(value, tabWidth, startIndex = 0) {
|
|
|
338
388
|
}
|
|
339
389
|
return size;
|
|
340
390
|
}
|
|
391
|
+
var get_alignment_size_default;
|
|
392
|
+
var init_get_alignment_size = __esm({
|
|
393
|
+
"src/utils/get-alignment-size.js"() {
|
|
394
|
+
get_alignment_size_default = getAlignmentSize;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// src/utils/get-indent-size.js
|
|
341
399
|
function getIndentSize(value, tabWidth) {
|
|
342
400
|
const lastNewlineIndex = value.lastIndexOf("\n");
|
|
343
401
|
if (lastNewlineIndex === -1) {
|
|
344
402
|
return 0;
|
|
345
403
|
}
|
|
346
|
-
return
|
|
404
|
+
return get_alignment_size_default(
|
|
405
|
+
// All the leading whitespaces
|
|
347
406
|
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
|
|
348
407
|
tabWidth
|
|
349
408
|
);
|
|
350
409
|
}
|
|
351
|
-
|
|
410
|
+
var get_indent_size_default;
|
|
411
|
+
var init_get_indent_size = __esm({
|
|
412
|
+
"src/utils/get-indent-size.js"() {
|
|
413
|
+
init_get_alignment_size();
|
|
414
|
+
get_indent_size_default = getIndentSize;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// src/utils/has-newline-in-range.js
|
|
419
|
+
function hasNewlineInRange(text, startIndex, endIndex) {
|
|
420
|
+
for (let i = startIndex; i < endIndex; ++i) {
|
|
421
|
+
if (text.charAt(i) === "\n") {
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
var has_newline_in_range_default;
|
|
428
|
+
var init_has_newline_in_range = __esm({
|
|
429
|
+
"src/utils/has-newline-in-range.js"() {
|
|
430
|
+
has_newline_in_range_default = hasNewlineInRange;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// src/utils/has-spaces.js
|
|
435
|
+
function hasSpaces(text, startIndex, options = {}) {
|
|
436
|
+
const idx = skipSpaces(
|
|
437
|
+
text,
|
|
438
|
+
options.backwards ? startIndex - 1 : startIndex,
|
|
439
|
+
options
|
|
440
|
+
);
|
|
441
|
+
return idx !== startIndex;
|
|
442
|
+
}
|
|
443
|
+
var has_spaces_default;
|
|
444
|
+
var init_has_spaces = __esm({
|
|
445
|
+
"src/utils/has-spaces.js"() {
|
|
446
|
+
init_skip();
|
|
447
|
+
has_spaces_default = hasSpaces;
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// src/utils/get-next-non-space-non-comment-character.js
|
|
452
|
+
function getNextNonSpaceNonCommentCharacter(text, startIndex) {
|
|
453
|
+
const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
|
|
454
|
+
return index === false ? "" : text.charAt(index);
|
|
455
|
+
}
|
|
456
|
+
var get_next_non_space_non_comment_character_default;
|
|
457
|
+
var init_get_next_non_space_non_comment_character = __esm({
|
|
458
|
+
"src/utils/get-next-non-space-non-comment-character.js"() {
|
|
459
|
+
init_get_next_non_space_non_comment_character_index();
|
|
460
|
+
get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
// scripts/build/shims/string-replace-all.js
|
|
465
|
+
var stringReplaceAll, string_replace_all_default;
|
|
466
|
+
var init_string_replace_all = __esm({
|
|
467
|
+
"scripts/build/shims/string-replace-all.js"() {
|
|
468
|
+
stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
|
|
469
|
+
if (isOptionalObject && (original === void 0 || original === null)) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (original.replaceAll) {
|
|
473
|
+
return original.replaceAll(pattern, replacement);
|
|
474
|
+
}
|
|
475
|
+
if (pattern.global) {
|
|
476
|
+
return original.replace(pattern, replacement);
|
|
477
|
+
}
|
|
478
|
+
return original.split(pattern).join(replacement);
|
|
479
|
+
};
|
|
480
|
+
string_replace_all_default = stringReplaceAll;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// src/utils/make-string.js
|
|
485
|
+
function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
352
486
|
const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
|
353
487
|
const regex = /\\(.)|(["'])/gs;
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
488
|
+
const raw = string_replace_all_default(
|
|
489
|
+
/* isOptionalObject*/
|
|
490
|
+
false,
|
|
491
|
+
rawText,
|
|
492
|
+
regex,
|
|
493
|
+
(match, escaped, quote) => {
|
|
494
|
+
if (escaped === otherQuote) {
|
|
495
|
+
return escaped;
|
|
496
|
+
}
|
|
497
|
+
if (quote === enclosingQuote) {
|
|
498
|
+
return "\\" + quote;
|
|
499
|
+
}
|
|
500
|
+
if (quote) {
|
|
501
|
+
return quote;
|
|
502
|
+
}
|
|
503
|
+
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
|
|
363
504
|
}
|
|
364
|
-
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
|
|
365
|
-
});
|
|
366
|
-
return enclosingQuote + newContent + enclosingQuote;
|
|
367
|
-
}
|
|
368
|
-
function getMaxContinuousCount(str, target) {
|
|
369
|
-
const results = str.match(
|
|
370
|
-
new RegExp(`(${escapeStringRegexp(target)})+`, "g")
|
|
371
505
|
);
|
|
372
|
-
|
|
373
|
-
|
|
506
|
+
return enclosingQuote + raw + enclosingQuote;
|
|
507
|
+
}
|
|
508
|
+
var make_string_default;
|
|
509
|
+
var init_make_string = __esm({
|
|
510
|
+
"src/utils/make-string.js"() {
|
|
511
|
+
init_string_replace_all();
|
|
512
|
+
make_string_default = makeString;
|
|
374
513
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// src/main/comments/utils.js
|
|
517
|
+
function describeNodeForDebugging(node) {
|
|
518
|
+
const nodeType = node.type || node.kind || "(unknown type)";
|
|
519
|
+
let nodeName = String(
|
|
520
|
+
node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || ""
|
|
378
521
|
);
|
|
522
|
+
if (nodeName.length > 20) {
|
|
523
|
+
nodeName = nodeName.slice(0, 19) + "\u2026";
|
|
524
|
+
}
|
|
525
|
+
return nodeType + (nodeName ? " " + nodeName : "");
|
|
379
526
|
}
|
|
380
527
|
function addCommentHelper(node, comment) {
|
|
381
528
|
const comments = node.comments ?? (node.comments = []);
|
|
@@ -401,47 +548,30 @@ function addTrailingComment(node, comment) {
|
|
|
401
548
|
comment.trailing = true;
|
|
402
549
|
addCommentHelper(node, comment);
|
|
403
550
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
let nodeName = String(
|
|
407
|
-
node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || ""
|
|
408
|
-
);
|
|
409
|
-
if (nodeName.length > 20) {
|
|
410
|
-
nodeName = nodeName.slice(0, 19) + "\u2026";
|
|
411
|
-
}
|
|
412
|
-
return nodeType + (nodeName ? " " + nodeName : "");
|
|
413
|
-
}
|
|
414
|
-
var init_util = __esm({
|
|
415
|
-
"src/common/util.js"() {
|
|
416
|
-
init_escape_string_regexp();
|
|
417
|
-
init_skip();
|
|
418
|
-
init_skip_inline_comment();
|
|
419
|
-
init_skip_trailing_comment();
|
|
420
|
-
init_skip_newline();
|
|
421
|
-
init_get_next_non_space_non_comment_character_index_with_start_index();
|
|
422
|
-
init_is_non_empty_array();
|
|
423
|
-
init_get_string_width();
|
|
551
|
+
var init_utils = __esm({
|
|
552
|
+
"src/main/comments/utils.js"() {
|
|
424
553
|
}
|
|
425
554
|
});
|
|
426
555
|
|
|
427
|
-
// src/
|
|
428
|
-
var
|
|
429
|
-
__export(
|
|
556
|
+
// src/utils/public.js
|
|
557
|
+
var public_exports = {};
|
|
558
|
+
__export(public_exports, {
|
|
430
559
|
addDanglingComment: () => addDanglingComment,
|
|
431
560
|
addLeadingComment: () => addLeadingComment,
|
|
432
561
|
addTrailingComment: () => addTrailingComment,
|
|
433
|
-
getAlignmentSize: () =>
|
|
434
|
-
getIndentSize: () =>
|
|
435
|
-
getMaxContinuousCount: () =>
|
|
436
|
-
|
|
562
|
+
getAlignmentSize: () => get_alignment_size_default,
|
|
563
|
+
getIndentSize: () => get_indent_size_default,
|
|
564
|
+
getMaxContinuousCount: () => get_max_continuous_count_default,
|
|
565
|
+
getNextNonSpaceNonCommentCharacter: () => get_next_non_space_non_comment_character_default,
|
|
566
|
+
getNextNonSpaceNonCommentCharacterIndex: () => getNextNonSpaceNonCommentCharacterIndex2,
|
|
437
567
|
getStringWidth: () => get_string_width_default,
|
|
438
|
-
hasNewline: () =>
|
|
439
|
-
hasNewlineInRange: () =>
|
|
440
|
-
hasSpaces: () =>
|
|
441
|
-
isNextLineEmpty: () =>
|
|
442
|
-
isNextLineEmptyAfterIndex: () =>
|
|
443
|
-
isPreviousLineEmpty: () =>
|
|
444
|
-
makeString: () =>
|
|
568
|
+
hasNewline: () => has_newline_default,
|
|
569
|
+
hasNewlineInRange: () => has_newline_in_range_default,
|
|
570
|
+
hasSpaces: () => has_spaces_default,
|
|
571
|
+
isNextLineEmpty: () => isNextLineEmpty2,
|
|
572
|
+
isNextLineEmptyAfterIndex: () => is_next_line_empty_default,
|
|
573
|
+
isPreviousLineEmpty: () => isPreviousLineEmpty2,
|
|
574
|
+
makeString: () => make_string_default,
|
|
445
575
|
skip: () => skip,
|
|
446
576
|
skipEverythingButNewLine: () => skipEverythingButNewLine,
|
|
447
577
|
skipInlineComment: () => skip_inline_comment_default,
|
|
@@ -451,16 +581,65 @@ __export(util_shared_exports, {
|
|
|
451
581
|
skipTrailingComment: () => skip_trailing_comment_default,
|
|
452
582
|
skipWhitespace: () => skipWhitespace
|
|
453
583
|
});
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
584
|
+
function legacyGetNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
|
585
|
+
return get_next_non_space_non_comment_character_index_default(
|
|
586
|
+
text,
|
|
587
|
+
locEnd(node)
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
function getNextNonSpaceNonCommentCharacterIndex2(text, startIndex) {
|
|
591
|
+
return arguments.length === 2 || typeof startIndex === "number" ? get_next_non_space_non_comment_character_index_default(text, startIndex) : (
|
|
592
|
+
// @ts-expect-error -- expected
|
|
593
|
+
// eslint-disable-next-line prefer-rest-params
|
|
594
|
+
legacyGetNextNonSpaceNonCommentCharacterIndex(...arguments)
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
function legacyIsPreviousLineEmpty(text, node, locStart) {
|
|
598
|
+
return is_previous_line_empty_default(text, locStart(node));
|
|
599
|
+
}
|
|
600
|
+
function isPreviousLineEmpty2(text, startIndex) {
|
|
601
|
+
return arguments.length === 2 || typeof startIndex === "number" ? is_previous_line_empty_default(text, startIndex) : (
|
|
602
|
+
// @ts-expect-error -- expected
|
|
603
|
+
// eslint-disable-next-line prefer-rest-params
|
|
604
|
+
legacyIsPreviousLineEmpty(...arguments)
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
function legacyIsNextLineEmpty(text, node, locEnd) {
|
|
608
|
+
return is_next_line_empty_default(text, locEnd(node));
|
|
609
|
+
}
|
|
610
|
+
function isNextLineEmpty2(text, startIndex) {
|
|
611
|
+
return arguments.length === 2 || typeof startIndex === "number" ? is_next_line_empty_default(text, startIndex) : (
|
|
612
|
+
// @ts-expect-error -- expected
|
|
613
|
+
// eslint-disable-next-line prefer-rest-params
|
|
614
|
+
legacyIsNextLineEmpty(...arguments)
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
var init_public = __esm({
|
|
618
|
+
"src/utils/public.js"() {
|
|
619
|
+
init_get_next_non_space_non_comment_character_index();
|
|
620
|
+
init_is_previous_line_empty();
|
|
621
|
+
init_is_next_line_empty();
|
|
622
|
+
init_get_max_continuous_count();
|
|
623
|
+
init_get_string_width();
|
|
624
|
+
init_get_alignment_size();
|
|
625
|
+
init_get_indent_size();
|
|
626
|
+
init_skip_newline();
|
|
627
|
+
init_skip_inline_comment();
|
|
628
|
+
init_skip_trailing_comment();
|
|
629
|
+
init_has_newline();
|
|
630
|
+
init_has_newline_in_range();
|
|
631
|
+
init_has_spaces();
|
|
632
|
+
init_get_next_non_space_non_comment_character();
|
|
633
|
+
init_make_string();
|
|
634
|
+
init_skip();
|
|
635
|
+
init_utils();
|
|
457
636
|
}
|
|
458
637
|
});
|
|
459
638
|
|
|
460
639
|
// src/main/version.evaluate.cjs
|
|
461
640
|
var require_version_evaluate = __commonJS({
|
|
462
641
|
"src/main/version.evaluate.cjs"(exports2, module2) {
|
|
463
|
-
module2.exports = "3.0.0-alpha.
|
|
642
|
+
module2.exports = "3.0.0-alpha.5";
|
|
464
643
|
}
|
|
465
644
|
});
|
|
466
645
|
|
|
@@ -499,7 +678,7 @@ for (const name of debugApiFunctionNames) {
|
|
|
499
678
|
}
|
|
500
679
|
prettier.__debug = debugApis;
|
|
501
680
|
if (true) {
|
|
502
|
-
prettier.util = (
|
|
681
|
+
prettier.util = (init_public(), __toCommonJS(public_exports));
|
|
503
682
|
prettier.doc = require("./doc.js");
|
|
504
683
|
} else {
|
|
505
684
|
Object.defineProperties(prettier, {
|