forked from OKEAMAH/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublic.js
More file actions
111 lines (103 loc) · 3.69 KB
/
public.js
File metadata and controls
111 lines (103 loc) · 3.69 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import getNextNonSpaceNonCommentCharacterIndexWithStartIndex from "./get-next-non-space-non-comment-character-index.js";
import isNextLineEmptyAfterIndex from "./is-next-line-empty.js";
import isPreviousLineEmptyWithStartIndex from "./is-previous-line-empty.js";
// Legacy version of `getNextNonSpaceNonCommentCharacterIndex`
/**
* @template N
* @param {string} text
* @param {N} node
* @param {(node: N) => number} locEnd
* @returns {number | false}
*/
function legacyGetNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(
text,
locEnd(node),
);
}
// TODO: export `getNextNonSpaceNonCommentCharacterIndex` directly in v4
/**
* @param {string} text
* @param {number} startIndex
* @returns {number | false}
*/
export function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
return arguments.length === 2 || typeof startIndex === "number"
? getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, startIndex)
: // @ts-expect-error -- expected
// eslint-disable-next-line prefer-rest-params
legacyGetNextNonSpaceNonCommentCharacterIndex(...arguments);
}
// Legacy version of `isPreviousLineEmpty`
/**
* @template N
* @param {string} text
* @param {N} node
* @param {(node: N) => number} locStart
*/
function legacyIsPreviousLineEmpty(text, node, locStart) {
return isPreviousLineEmptyWithStartIndex(text, locStart(node));
}
// TODO: export `isPreviousLineEmpty` directly in v4
/**
* @param {string} text
* @param {number} startIndex
* @returns {boolean}
*/
export function isPreviousLineEmpty(text, startIndex) {
return arguments.length === 2 || typeof startIndex === "number"
? isPreviousLineEmptyWithStartIndex(text, startIndex)
: // @ts-expect-error -- expected
// eslint-disable-next-line prefer-rest-params
legacyIsPreviousLineEmpty(...arguments);
}
// Legacy version of `isNextLineEmpty`
/**
* @template N
* @param {string} text
* @param {N} node
* @param {(node: N) => number} locEnd
* @returns {boolean}
*/
function legacyIsNextLineEmpty(text, node, locEnd) {
return isNextLineEmptyAfterIndex(text, locEnd(node));
}
// TODO: export `isNextLineEmpty` directly in v4
/**
* @param {string} text
* @param {number} startIndex
* @returns {boolean}
*/
export function isNextLineEmpty(text, startIndex) {
return arguments.length === 2 || typeof startIndex === "number"
? isNextLineEmptyAfterIndex(text, startIndex)
: // @ts-expect-error -- expected
// eslint-disable-next-line prefer-rest-params
legacyIsNextLineEmpty(...arguments);
}
export {
addDanglingComment,
addLeadingComment,
addTrailingComment,
} from "../main/comments/utils.js";
export { default as getAlignmentSize } from "./get-alignment-size.js";
export { default as getIndentSize } from "./get-indent-size.js";
export { default as getMaxContinuousCount } from "./get-max-continuous-count.js";
export { default as getNextNonSpaceNonCommentCharacter } from "./get-next-non-space-non-comment-character.js";
export { default as getStringWidth } from "./get-string-width.js";
export { default as hasNewline } from "./has-newline.js";
export { default as hasNewlineInRange } from "./has-newline-in-range.js";
export { default as hasSpaces } from "./has-spaces.js";
export { default as makeString } from "./make-string.js";
export {
skip,
skipEverythingButNewLine,
skipSpaces,
skipToLineEnd,
skipWhitespace,
} from "./skip.js";
export { default as skipInlineComment } from "./skip-inline-comment.js";
export { default as skipNewline } from "./skip-newline.js";
export { default as skipTrailingComment } from "./skip-trailing-comment.js";
// TODO: Remove this in v4
export { isNextLineEmptyAfterIndex };