@sweetener/prettier-plugin 0.1.0-alpha.0
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 +21 -0
- package/README.md +16 -0
- package/dist/src/format.d.ts +18 -0
- package/dist/src/format.d.ts.map +1 -0
- package/dist/src/format.js +129 -0
- package/dist/src/format.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +48 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/typescript-format.d.ts +3 -0
- package/dist/src/typescript-format.d.ts.map +1 -0
- package/dist/src/typescript-format.js +322 -0
- package/dist/src/typescript-format.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jimmy Miller
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @sweetener/prettier-plugin
|
|
2
|
+
|
|
3
|
+
Format `.sts` and `.stsx` with Prettier 3.
|
|
4
|
+
|
|
5
|
+
Part of [Sweetener](https://github.com/sweetener-ts/sweetener), hygienic
|
|
6
|
+
declarative macros for TypeScript. Alpha: the language version is 1 and the
|
|
7
|
+
package interfaces may still change.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// prettier.config.mjs
|
|
13
|
+
import sweetener from "@sweetener/prettier-plugin";
|
|
14
|
+
|
|
15
|
+
export default { plugins: [sweetener] };
|
|
16
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RootSyntax } from "@sweetener/compiler/syntax";
|
|
2
|
+
export interface SweetenerFormatOptions {
|
|
3
|
+
readonly filepath?: string | undefined;
|
|
4
|
+
readonly printWidth?: number | undefined;
|
|
5
|
+
readonly tabWidth?: number | undefined;
|
|
6
|
+
readonly useTabs?: boolean | undefined;
|
|
7
|
+
readonly semi?: boolean | undefined;
|
|
8
|
+
readonly singleQuote?: boolean | undefined;
|
|
9
|
+
readonly jsxSingleQuote?: boolean | undefined;
|
|
10
|
+
readonly quoteProps?: "as-needed" | "consistent" | "preserve" | undefined;
|
|
11
|
+
readonly bracketSpacing?: boolean | undefined;
|
|
12
|
+
readonly bracketSameLine?: boolean | undefined;
|
|
13
|
+
readonly arrowParens?: "always" | "avoid" | undefined;
|
|
14
|
+
readonly endOfLine?: "lf" | "crlf" | "cr" | "auto" | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function readSweetenerSyntax(source: string, options: SweetenerFormatOptions): RootSyntax;
|
|
17
|
+
export declare function formatSweetener(source: string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nC,MAAM,CAQR"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { readSyntax } from "@sweetener/compiler/reader";
|
|
2
|
+
const sourceId = 0;
|
|
3
|
+
const scopes = 0;
|
|
4
|
+
function lineEnding(source, option) {
|
|
5
|
+
switch (option) {
|
|
6
|
+
case "cr":
|
|
7
|
+
return "\r";
|
|
8
|
+
case "crlf":
|
|
9
|
+
return "\r\n";
|
|
10
|
+
case "auto":
|
|
11
|
+
return source.includes("\r\n")
|
|
12
|
+
? "\r\n"
|
|
13
|
+
: source.includes("\r")
|
|
14
|
+
? "\r"
|
|
15
|
+
: "\n";
|
|
16
|
+
case "lf":
|
|
17
|
+
case undefined:
|
|
18
|
+
return "\n";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function indentation(depth, options) {
|
|
22
|
+
if (options.useTabs === true)
|
|
23
|
+
return "\t".repeat(depth);
|
|
24
|
+
return " ".repeat(depth * (options.tabWidth ?? 2));
|
|
25
|
+
}
|
|
26
|
+
function formatMultilineWhitespace(raw, depth, options, eol) {
|
|
27
|
+
const breaks = raw.match(/\r\n|[\n\r\u2028\u2029]/gu)?.length ?? 0;
|
|
28
|
+
return eol.repeat(Math.min(breaks, 2)) + indentation(depth, options);
|
|
29
|
+
}
|
|
30
|
+
function collectTrivia(trivia, depth, options, eol, replacements) {
|
|
31
|
+
let followsLineBreak = false;
|
|
32
|
+
for (let index = 0; index < trivia.length; index += 1) {
|
|
33
|
+
const item = trivia[index];
|
|
34
|
+
if (item.kind === "whitespace") {
|
|
35
|
+
if (item.hasLineBreak) {
|
|
36
|
+
let anotherLineBreakFollows = false;
|
|
37
|
+
for (const following of trivia.slice(index + 1)) {
|
|
38
|
+
if (following.kind !== "whitespace")
|
|
39
|
+
break;
|
|
40
|
+
if (following.hasLineBreak) {
|
|
41
|
+
anotherLineBreakFollows = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
replacements.push({
|
|
46
|
+
start: item.span.start,
|
|
47
|
+
end: item.span.end,
|
|
48
|
+
text: anotherLineBreakFollows
|
|
49
|
+
? eol.repeat(Math.min(item.raw.match(/\r\n|[\n\r\u2028\u2029]/gu)?.length ?? 0, 2))
|
|
50
|
+
: formatMultilineWhitespace(item.raw, depth, options, eol),
|
|
51
|
+
});
|
|
52
|
+
followsLineBreak = true;
|
|
53
|
+
}
|
|
54
|
+
else if (followsLineBreak) {
|
|
55
|
+
replacements.push({
|
|
56
|
+
start: item.span.start,
|
|
57
|
+
end: item.span.end,
|
|
58
|
+
text: "",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
followsLineBreak = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function collectToken(token, depth, options, eol, replacements) {
|
|
67
|
+
collectTrivia(token.leadingTrivia, depth, options, eol, replacements);
|
|
68
|
+
collectTrivia(token.trailingTrivia, depth, options, eol, replacements);
|
|
69
|
+
}
|
|
70
|
+
function preservesWhitespace(group) {
|
|
71
|
+
return (group.delimiter === "template" ||
|
|
72
|
+
group.delimiter === "jsx-element" ||
|
|
73
|
+
group.delimiter === "jsx-fragment");
|
|
74
|
+
}
|
|
75
|
+
function collectSyntax(syntax, depth, options, eol, replacements) {
|
|
76
|
+
switch (syntax.tag) {
|
|
77
|
+
case "token":
|
|
78
|
+
collectToken(syntax, depth, options, eol, replacements);
|
|
79
|
+
return;
|
|
80
|
+
case "group":
|
|
81
|
+
collectToken(syntax.open, depth, options, eol, replacements);
|
|
82
|
+
if (preservesWhitespace(syntax))
|
|
83
|
+
return;
|
|
84
|
+
for (const child of syntax.children)
|
|
85
|
+
collectSyntax(child, depth + 1, options, eol, replacements);
|
|
86
|
+
if (syntax.close.tag === "token")
|
|
87
|
+
collectToken(syntax.close, depth, options, eol, replacements);
|
|
88
|
+
return;
|
|
89
|
+
case "protected":
|
|
90
|
+
case "root":
|
|
91
|
+
for (const child of syntax.children)
|
|
92
|
+
collectSyntax(child, depth, options, eol, replacements);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function applyReplacements(source, replacements) {
|
|
96
|
+
let result = source;
|
|
97
|
+
for (const replacement of [...replacements].sort((left, right) => right.start - left.start)) {
|
|
98
|
+
result =
|
|
99
|
+
result.slice(0, replacement.start) +
|
|
100
|
+
replacement.text +
|
|
101
|
+
result.slice(replacement.end);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
export function readSweetenerSyntax(source, options) {
|
|
106
|
+
const result = readSyntax(source, {
|
|
107
|
+
sourceId,
|
|
108
|
+
scopes,
|
|
109
|
+
variant: options.filepath?.endsWith("x") === true ? "jsx" : "standard",
|
|
110
|
+
});
|
|
111
|
+
if (result.diagnostics.length > 0) {
|
|
112
|
+
const first = result.diagnostics[0];
|
|
113
|
+
throw new SyntaxError(`Sweetener could not format malformed source${first === undefined
|
|
114
|
+
? ""
|
|
115
|
+
: ` at offset ${String(first.primaryOrigin.start)}`}`);
|
|
116
|
+
}
|
|
117
|
+
return result.root;
|
|
118
|
+
}
|
|
119
|
+
export function formatSweetener(source, options = {}) {
|
|
120
|
+
if (source.length === 0)
|
|
121
|
+
return "";
|
|
122
|
+
const root = readSweetenerSyntax(source, options);
|
|
123
|
+
const eol = lineEnding(source, options.endOfLine);
|
|
124
|
+
const replacements = [];
|
|
125
|
+
collectSyntax(root, 0, options, eol, replacements);
|
|
126
|
+
const formatted = applyReplacements(source, replacements);
|
|
127
|
+
return formatted.replace(/[ \t\r\n\u2028\u2029]+$/u, "") + eol;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA+B/C,MAAM,QAAQ,GAAG,CAAa,CAAC;AAC/B,MAAM,MAAM,G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M,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,UAAkC,EAAE;IAEpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,aAAa,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1D,OAAO,SAAS,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from "prettier";
|
|
2
|
+
interface SweetenerAst {
|
|
3
|
+
readonly type: "SweetenerDocument";
|
|
4
|
+
readonly source: string;
|
|
5
|
+
}
|
|
6
|
+
declare const plugin: Plugin<SweetenerAst>;
|
|
7
|
+
export { formatSweetener } from "./format.js";
|
|
8
|
+
export { formatSweetenerWithPrettier } from "./typescript-format.js";
|
|
9
|
+
export default plugin;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAW,MAAM,UAAU,CAAC;AAIxD,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AA2BD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,YAAY,CAsBhC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { formatSweetenerWithPrettier } from "./typescript-format.js";
|
|
2
|
+
const parser = {
|
|
3
|
+
astFormat: "sweetener-document",
|
|
4
|
+
async parse(text, options) {
|
|
5
|
+
return {
|
|
6
|
+
type: "SweetenerDocument",
|
|
7
|
+
source: await formatSweetenerWithPrettier(text, options),
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
locStart() {
|
|
11
|
+
return 0;
|
|
12
|
+
},
|
|
13
|
+
locEnd(node) {
|
|
14
|
+
return node.source.length;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const printer = {
|
|
18
|
+
print(path) {
|
|
19
|
+
return path.node.source;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const plugin = {
|
|
23
|
+
languages: [
|
|
24
|
+
{
|
|
25
|
+
name: "Sweetener TypeScript",
|
|
26
|
+
parsers: ["sweetener"],
|
|
27
|
+
extensions: [".sts"],
|
|
28
|
+
vscodeLanguageIds: ["sweetener-typescript"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "Sweetener TSX",
|
|
32
|
+
parsers: ["sweetener-tsx"],
|
|
33
|
+
extensions: [".stsx"],
|
|
34
|
+
vscodeLanguageIds: ["sweetener-typescriptreact"],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
parsers: {
|
|
38
|
+
sweetener: parser,
|
|
39
|
+
"sweetener-tsx": parser,
|
|
40
|
+
},
|
|
41
|
+
printers: {
|
|
42
|
+
"sweetener-document": printer,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export { formatSweetener } from "./format.js";
|
|
46
|
+
export { formatSweetenerWithPrettier } from "./typescript-format.js";
|
|
47
|
+
export default plugin;
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAOrE,MAAM,MAAM,GAAyB;IACnC,SAAS,EAAE,oBAAoB;IAC/B,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO;QACvB,OAAO;YACL,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,MAAM,2BAA2B,CACvC,IAAI,EACJ,OAAiC,CAClC;SACF,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF,CAAC;AAEF,MAAM,OAAO,GAA0B;IACrC,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,GAAyB;IACnC,SAAS,EAAE;QACT;YACE,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,CAAC,WAAW,CAAC;YACtB,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,iBAAiB,EAAE,CAAC,sBAAsB,CAAC;SAC5C;QACD;YACE,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,CAAC,eAAe,CAAC;YAC1B,UAAU,EAAE,CAAC,OAAO,CAAC;YACrB,iBAAiB,EAAE,CAAC,2BAA2B,CAAC;SACjD;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAE,MAAM;QACjB,eAAe,EAAE,MAAM;KACxB;IACD,QAAQ,EAAE;QACR,oBAAoB,EAAE,OAAO;KAC9B;CACF,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-format.d.ts","sourceRoot":"","sources":["../../src/typescript-format.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AAwVrB,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,MAAM,CAAC,CAkEjB"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { formatSweetener, readSweetenerSyntax, } from "./format.js";
|
|
2
|
+
function literalPattern(text) {
|
|
3
|
+
return new RegExp(text.replaceAll(/[$()*+.?[\\\]^{|}]/gu, "\\$&"), "gu");
|
|
4
|
+
}
|
|
5
|
+
function isMultilineJsxLayout(syntax) {
|
|
6
|
+
return (syntax.tag === "token" &&
|
|
7
|
+
syntax.kind === "jsx-text" &&
|
|
8
|
+
/^[\t\n\r\u2028\u2029 ]+$/u.test(syntax.raw) &&
|
|
9
|
+
/[\n\r\u2028\u2029]/u.test(syntax.raw));
|
|
10
|
+
}
|
|
11
|
+
function jsxLayoutSpans(syntax) {
|
|
12
|
+
if (isMultilineJsxLayout(syntax))
|
|
13
|
+
return [syntax.span];
|
|
14
|
+
switch (syntax.tag) {
|
|
15
|
+
case "token":
|
|
16
|
+
return [];
|
|
17
|
+
case "group":
|
|
18
|
+
case "protected":
|
|
19
|
+
case "root":
|
|
20
|
+
return syntax.children.flatMap(jsxLayoutSpans);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function removeInsertedJsxLayout(source, before, after) {
|
|
24
|
+
// If the source has no JSX layout text, any such tokens in Prettier's output
|
|
25
|
+
// came solely from line wrapping. Remove them so literal macro patterns see
|
|
26
|
+
// the same tree. Existing JSX text is never rewritten or guessed at.
|
|
27
|
+
if (jsxLayoutSpans(before).length > 0)
|
|
28
|
+
return source;
|
|
29
|
+
let result = source;
|
|
30
|
+
for (const span of [...jsxLayoutSpans(after)].sort((left, right) => right.start - left.start))
|
|
31
|
+
result = result.slice(0, span.start) + result.slice(span.end);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Tokens that must survive formatting, in order.
|
|
36
|
+
*
|
|
37
|
+
* Every token counts, semicolons included. A semicolon is a real token to a
|
|
38
|
+
* macro matcher, and a macro can match on one not being there: the
|
|
39
|
+
* implicit-return example returns a function's final expression, and telling
|
|
40
|
+
* it from an expression statement is exactly the absence of a `;`. Prettier
|
|
41
|
+
* adding one there changes what the program means, so formatting that changes
|
|
42
|
+
* any token is not applied.
|
|
43
|
+
*/
|
|
44
|
+
function tokenFingerprint(syntax) {
|
|
45
|
+
switch (syntax.tag) {
|
|
46
|
+
case "token":
|
|
47
|
+
return [{ kind: syntax.kind, raw: syntax.raw }];
|
|
48
|
+
case "group":
|
|
49
|
+
return [
|
|
50
|
+
{ kind: syntax.open.kind, raw: syntax.open.raw },
|
|
51
|
+
...syntax.children.flatMap(tokenFingerprint),
|
|
52
|
+
...(syntax.close.tag === "token"
|
|
53
|
+
? [{ kind: syntax.close.kind, raw: syntax.close.raw }]
|
|
54
|
+
: []),
|
|
55
|
+
];
|
|
56
|
+
case "protected":
|
|
57
|
+
case "root":
|
|
58
|
+
return syntax.children.flatMap(tokenFingerprint);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function preservesTokens(before, after) {
|
|
62
|
+
const left = tokenFingerprint(before);
|
|
63
|
+
const right = tokenFingerprint(after);
|
|
64
|
+
return (left.length === right.length &&
|
|
65
|
+
left.every((token, index) => token.kind === right[index]?.kind && token.raw === right[index]?.raw));
|
|
66
|
+
}
|
|
67
|
+
/** The options that are set, so an absent one keeps Prettier's own default. */
|
|
68
|
+
function pick(options, keys) {
|
|
69
|
+
const chosen = {};
|
|
70
|
+
for (const key of keys)
|
|
71
|
+
if (options[key] !== undefined)
|
|
72
|
+
chosen[key] = options[key];
|
|
73
|
+
return chosen;
|
|
74
|
+
}
|
|
75
|
+
/** Whether a node begins a line, which ends the statement before it. */
|
|
76
|
+
function startsNewLine(syntax) {
|
|
77
|
+
if (syntax === undefined)
|
|
78
|
+
return false;
|
|
79
|
+
const first = syntax.tag === "group" ? syntax.open : syntax;
|
|
80
|
+
return (first.tag === "token" &&
|
|
81
|
+
first.leadingTrivia.some((trivia) => trivia.hasLineBreak));
|
|
82
|
+
}
|
|
83
|
+
function tokenRaw(syntax) {
|
|
84
|
+
return syntax?.tag === "token" ? syntax.raw : undefined;
|
|
85
|
+
}
|
|
86
|
+
function importedIdentifiers(group) {
|
|
87
|
+
if (group.delimiter !== "brace")
|
|
88
|
+
return [];
|
|
89
|
+
return group.children.flatMap((child) => child.tag === "token" && child.kind === "identifier" ? [child.raw] : []);
|
|
90
|
+
}
|
|
91
|
+
function nextMarker(source, index) {
|
|
92
|
+
let suffix = index;
|
|
93
|
+
for (;;) {
|
|
94
|
+
const marker = `/*__SWEETENER_FORMAT_${String(suffix)}__*/`;
|
|
95
|
+
if (!source.includes(marker))
|
|
96
|
+
return marker;
|
|
97
|
+
suffix += 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function nextBindingMarker(source, index) {
|
|
101
|
+
let suffix = index;
|
|
102
|
+
for (;;) {
|
|
103
|
+
// Short on purpose: a long stand-in changes where Prettier wraps the
|
|
104
|
+
// import, and the wrap survives the shorter original going back in.
|
|
105
|
+
const marker = `__sw${String(suffix)}__`;
|
|
106
|
+
if (!source.includes(marker))
|
|
107
|
+
return marker;
|
|
108
|
+
suffix += 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A binding that TypeScript cannot spell in an import clause.
|
|
113
|
+
*
|
|
114
|
+
* Sweetener imports a macro by whatever it is called, and two of the things it
|
|
115
|
+
* can be called are not identifiers: an operator, written `(|>)`, and a core
|
|
116
|
+
* form being shadowed, written `typeof`. Prettier parses what is left after
|
|
117
|
+
* the compile-time tail is masked, and `import { (|>) }` is not TypeScript, so
|
|
118
|
+
* it failed to parse and returned the file untouched — silently, and for the
|
|
119
|
+
* headline example in the README among others.
|
|
120
|
+
*/
|
|
121
|
+
function unspellableBinding(syntax) {
|
|
122
|
+
if (syntax.tag === "group")
|
|
123
|
+
return syntax.delimiter === "parenthesis";
|
|
124
|
+
return syntax.tag === "token" && syntax.kind === "keyword";
|
|
125
|
+
}
|
|
126
|
+
/** A mask whose marker Prettier prints back exactly as it was given. */
|
|
127
|
+
function textMask(marker, source, span) {
|
|
128
|
+
return {
|
|
129
|
+
marker,
|
|
130
|
+
pattern: literalPattern(marker),
|
|
131
|
+
original: source.slice(span.start, span.end),
|
|
132
|
+
start: span.start,
|
|
133
|
+
end: span.end,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function maskSweetenerSyntax(source, root) {
|
|
137
|
+
const children = root.children;
|
|
138
|
+
const imports = new Set();
|
|
139
|
+
const masks = [];
|
|
140
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
141
|
+
if (tokenRaw(children[index]) !== "import")
|
|
142
|
+
continue;
|
|
143
|
+
let end = index + 1;
|
|
144
|
+
// The import ends at its semicolon, or where the next line starts. It used
|
|
145
|
+
// to look only for the semicolon, so a `for syntax` import written without
|
|
146
|
+
// one — which the compiler accepts, as it does for any other statement —
|
|
147
|
+
// was never masked, Prettier could not parse what it was handed, and the
|
|
148
|
+
// whole file came back unformatted.
|
|
149
|
+
for (; end < children.length &&
|
|
150
|
+
tokenRaw(children[end]) !== ";" &&
|
|
151
|
+
!startsNewLine(children[end]); end += 1) {
|
|
152
|
+
const child = children[end];
|
|
153
|
+
if (child?.tag === "group")
|
|
154
|
+
for (const name of importedIdentifiers(child))
|
|
155
|
+
imports.add(name);
|
|
156
|
+
}
|
|
157
|
+
const terminator = tokenRaw(children[end]) === ";" ? children[end] : children[end - 1];
|
|
158
|
+
for (let cursor = index + 1; cursor < end; cursor += 1) {
|
|
159
|
+
if (tokenRaw(children[cursor]) !== "for" ||
|
|
160
|
+
tokenRaw(children[cursor + 1]) !== "syntax")
|
|
161
|
+
continue;
|
|
162
|
+
const firstNode = children[cursor];
|
|
163
|
+
const lastNode = terminator;
|
|
164
|
+
if (firstNode === undefined || lastNode === undefined)
|
|
165
|
+
continue;
|
|
166
|
+
// Each binding Prettier could not read stands in as an identifier while
|
|
167
|
+
// it formats, and goes back as written afterwards.
|
|
168
|
+
const clause = children[index + 1];
|
|
169
|
+
if (clause?.tag === "group" && clause.delimiter === "brace")
|
|
170
|
+
for (const binding of clause.children)
|
|
171
|
+
if (unspellableBinding(binding))
|
|
172
|
+
masks.push(textMask(nextBindingMarker(source, masks.length), source, binding.span));
|
|
173
|
+
// The replacement keeps a semicolon whether or not the source had one:
|
|
174
|
+
// it stands in for an import in a position where TypeScript expects a
|
|
175
|
+
// statement, and the original text goes back verbatim afterwards.
|
|
176
|
+
// Kept short for the same reason the binding stand-ins are: it occupies
|
|
177
|
+
// the width of `for syntax;` while Prettier decides where to wrap.
|
|
178
|
+
const name = `__swi${String(masks.length)}__`;
|
|
179
|
+
const marker = `with { type: "${name}" };`;
|
|
180
|
+
masks.push({
|
|
181
|
+
marker,
|
|
182
|
+
pattern: new RegExp(
|
|
183
|
+
// Horizontal space only before the optional semicolon: \s* would
|
|
184
|
+
// swallow the line break after it, and putting the original back
|
|
185
|
+
// then joined the import to the statement below it.
|
|
186
|
+
`with\\s*\\{\\s*type\\s*:\\s*['"]${name}['"]\\s*,?\\s*\\}[^\\S\\n]*;?`, "gu"),
|
|
187
|
+
original: source.slice(firstNode.span.start, lastNode.span.end),
|
|
188
|
+
start: firstNode.span.start,
|
|
189
|
+
end: lastNode.span.end,
|
|
190
|
+
});
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
index = end;
|
|
194
|
+
}
|
|
195
|
+
const declarations = new Set([
|
|
196
|
+
"abstract",
|
|
197
|
+
"async",
|
|
198
|
+
"class",
|
|
199
|
+
"const",
|
|
200
|
+
"enum",
|
|
201
|
+
"function",
|
|
202
|
+
"interface",
|
|
203
|
+
"let",
|
|
204
|
+
"namespace",
|
|
205
|
+
"type",
|
|
206
|
+
"var",
|
|
207
|
+
]);
|
|
208
|
+
for (let index = 0; index + 1 < children.length; index += 1) {
|
|
209
|
+
const prefix = children[index];
|
|
210
|
+
const declaration = children[index + 1];
|
|
211
|
+
if (prefix?.tag !== "token" ||
|
|
212
|
+
!imports.has(prefix.raw) ||
|
|
213
|
+
!declarations.has(tokenRaw(declaration) ?? ""))
|
|
214
|
+
continue;
|
|
215
|
+
masks.push(textMask(nextMarker(source, masks.length), source, prefix.span));
|
|
216
|
+
}
|
|
217
|
+
let masked = source;
|
|
218
|
+
for (const mask of [...masks].sort((left, right) => right.start - left.start))
|
|
219
|
+
masked = masked.slice(0, mask.start) + mask.marker + masked.slice(mask.end);
|
|
220
|
+
return { source: masked, masks };
|
|
221
|
+
}
|
|
222
|
+
function restoreSweetenerSyntax(formatted, masks) {
|
|
223
|
+
let restored = formatted;
|
|
224
|
+
for (const mask of masks) {
|
|
225
|
+
mask.pattern.lastIndex = 0;
|
|
226
|
+
const found = [...restored.matchAll(mask.pattern)];
|
|
227
|
+
// Exactly one, or the text this puts back would land somewhere it was
|
|
228
|
+
// never taken from.
|
|
229
|
+
const match = found.length === 1 ? found[0] : undefined;
|
|
230
|
+
if (match?.index === undefined)
|
|
231
|
+
return undefined;
|
|
232
|
+
restored =
|
|
233
|
+
restored.slice(0, match.index) +
|
|
234
|
+
mask.original +
|
|
235
|
+
restored.slice(match.index + match[0].length);
|
|
236
|
+
}
|
|
237
|
+
return restored;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The printing choices to try, in order.
|
|
241
|
+
*
|
|
242
|
+
* Prettier normalizes semicolons and quotes, and both are real tokens to a
|
|
243
|
+
* macro matcher, so whichever the project asked for may be the one that
|
|
244
|
+
* changes the program. Rather than tolerate the difference — the
|
|
245
|
+
* implicit-return macro shows why that is not safe — the file is printed
|
|
246
|
+
* again with the other choice and the result checked. A file already written
|
|
247
|
+
* in the project's style is formatted on the first attempt; one written the
|
|
248
|
+
* other way is formatted on a later one; a file mixing both, where no single
|
|
249
|
+
* choice preserves every token, keeps its own layout.
|
|
250
|
+
*/
|
|
251
|
+
function printingAttempts(options) {
|
|
252
|
+
const semi = options.semi ?? true;
|
|
253
|
+
const singleQuote = options.singleQuote ?? false;
|
|
254
|
+
return [
|
|
255
|
+
options,
|
|
256
|
+
{ ...options, semi: !semi },
|
|
257
|
+
{ ...options, singleQuote: !singleQuote },
|
|
258
|
+
{ ...options, semi: !semi, singleQuote: !singleQuote },
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
export async function formatSweetenerWithPrettier(source, options = {}) {
|
|
262
|
+
const structurallyFormatted = formatSweetener(source, options);
|
|
263
|
+
const root = readSweetenerSyntax(structurallyFormatted, options);
|
|
264
|
+
const masked = maskSweetenerSyntax(structurallyFormatted, root);
|
|
265
|
+
const [{ format }, typescriptPlugin, estreePlugin] = await Promise.all([
|
|
266
|
+
import("prettier/standalone"),
|
|
267
|
+
import("prettier/plugins/typescript"),
|
|
268
|
+
import("prettier/plugins/estree"),
|
|
269
|
+
]);
|
|
270
|
+
for (const attempt of printingAttempts(options)) {
|
|
271
|
+
const printed = await printOnce(attempt);
|
|
272
|
+
if (printed !== undefined)
|
|
273
|
+
return printed;
|
|
274
|
+
}
|
|
275
|
+
return structurallyFormatted;
|
|
276
|
+
/** One printing, or nothing when it did not survive the token check. */
|
|
277
|
+
async function printOnce(attempt) {
|
|
278
|
+
let formatted;
|
|
279
|
+
try {
|
|
280
|
+
formatted = await format(masked.source, {
|
|
281
|
+
parser: "typescript",
|
|
282
|
+
plugins: [typescriptPlugin, estreePlugin],
|
|
283
|
+
// A trailing comma is a real token to a macro matcher. Prettier's
|
|
284
|
+
// default (`all`) would therefore change which macro rules accept an
|
|
285
|
+
// invocation even though it appears to be a layout-only operation.
|
|
286
|
+
trailingComma: "none",
|
|
287
|
+
// The project's own settings otherwise, so a `.sts` is formatted the
|
|
288
|
+
// way every other file in the repository is.
|
|
289
|
+
...pick(attempt, [
|
|
290
|
+
"filepath",
|
|
291
|
+
"printWidth",
|
|
292
|
+
"tabWidth",
|
|
293
|
+
"useTabs",
|
|
294
|
+
"semi",
|
|
295
|
+
"singleQuote",
|
|
296
|
+
"jsxSingleQuote",
|
|
297
|
+
"quoteProps",
|
|
298
|
+
"bracketSpacing",
|
|
299
|
+
"bracketSameLine",
|
|
300
|
+
"arrowParens",
|
|
301
|
+
"endOfLine",
|
|
302
|
+
]),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
const restored = restoreSweetenerSyntax(formatted, masked.masks);
|
|
309
|
+
if (restored === undefined)
|
|
310
|
+
return undefined;
|
|
311
|
+
// Sweetener macros match token trees, so formatting may change trivia and
|
|
312
|
+
// nothing else. This is what refuses a printing that would have changed
|
|
313
|
+
// the program, whichever option produced it.
|
|
314
|
+
const formattedRoot = readSweetenerSyntax(restored, options);
|
|
315
|
+
const withoutInsertedJsxLayout = removeInsertedJsxLayout(restored, root, formattedRoot);
|
|
316
|
+
const safeRoot = readSweetenerSyntax(withoutInsertedJsxLayout, options);
|
|
317
|
+
return preservesTokens(root, safeRoot)
|
|
318
|
+
? withoutInsertedJsxLayout
|
|
319
|
+
: undefined;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=typescript-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-format.js","sourceRoot":"","sources":["../../src/typescript-format.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AAoBrB,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,EAAE,MAAM,CAAC,EAAE,I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AC;aACH,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACjE,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAE7C,0EAA0E;QAC1E,wEAAwE;QACxE,6CAA6C;QAC7C,MAAM,aAAa,GAAG,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,wBAAwB,GAAG,uBAAuB,CACtD,QAAQ,EACR,IAAI,EACJ,aAAa,CACd,CAAC;QACF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QACxE,OAAO,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC;YACpC,CAAC,CAAC,wBAAwB;YAC1B,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sweetener/prettier-plugin",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Sweetener alpha package: prettier-plugin",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/src/index.d.ts",
|
|
9
|
+
"import": "./dist/src/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"prettier": ">=3.0.0"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Jimmy Miller <jimmyhmiller@gmail.com>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sweetener-ts/sweetener.git",
|
|
20
|
+
"directory": "packages/prettier-plugin"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/sweetener-ts/sweetener/tree/main/packages/prettier-plugin#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/sweetener-ts/sweetener/issues"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"sweetener",
|
|
28
|
+
"macros",
|
|
29
|
+
"typescript",
|
|
30
|
+
"hygienic",
|
|
31
|
+
"syntax",
|
|
32
|
+
"prettier",
|
|
33
|
+
"formatter",
|
|
34
|
+
"plugin"
|
|
35
|
+
],
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@sweetener/compiler": "0.1.0-alpha.0"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|