Skip to content

Commit 7e52c77

Browse files
Merge pull request #127 from jcamp-code/master
Update for Prettier v3.7.0 Co-authored-by: John Campion Jr <[email protected]>
2 parents 850573d + 67b1a8c commit 7e52c77

File tree

25 files changed

+117
-101
lines changed

25 files changed

+117
-101
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"lint": "biome lint --max-diagnostics=none src/ tests/",
3030
"preview": "pnpm run build:plain && npm version prerelease --preid=alpha --git-tag-version=false && npm pack",
3131
"preview:minor": "pnpm run build:plain && npm version preminor --preid=alpha --git-tag-version=false && npm pack",
32-
"test": "vitest run --passWithNoTests"
32+
"test": "vitest run --passWithNoTests",
33+
"snapshot": "vitest -u"
3334
},
3435
"dependencies": {
3536
"zod": "3.22.4"
@@ -39,7 +40,7 @@
3940
"@trivago/prettier-plugin-sort-imports": "4.2.1",
4041
"@types/node": "20.17.46",
4142
"esbuild": "0.25.0",
42-
"prettier": "3.1.0",
43+
"prettier": "3.7.3",
4344
"prettier-plugin-astro": "0.11.0",
4445
"prettier-plugin-svelte": "3.0.0",
4546
"rimraf": "5.0.1",

pnpm-lock.yaml

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core-parts/finder.ts

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,14 +1499,23 @@ export function findTargetClassNameNodesForHtml(
14991499
*/
15001500
const classNameNodes: ClassNameNode[] = [];
15011501

1502-
function recursion(node: unknown, parentNode?: { type?: unknown }): void {
1503-
if (!isTypeof(node, z.object({ type: z.string() }))) {
1502+
function recursion(
1503+
node: unknown,
1504+
parentNode?: { kind: string; type?: undefined } | { kind?: undefined; type: string },
1505+
): void {
1506+
if (
1507+
!isTypeof(node, z.object({ kind: z.string() })) &&
1508+
!isTypeof(node, z.object({ type: z.string() }))
1509+
) {
15041510
return;
15051511
}
15061512

1513+
const nodeType = isTypeof(node, z.object({ kind: z.string() })) ? node.kind : node.type;
1514+
const parentNodeType = parentNode?.kind ?? parentNode?.type;
1515+
15071516
let recursiveProps: string[] = [];
15081517

1509-
switch (node.type) {
1518+
switch (nodeType) {
15101519
case 'element': {
15111520
recursiveProps = ['attrs', 'children'];
15121521
break;
@@ -1558,11 +1567,11 @@ export function findTargetClassNameNodesForHtml(
15581567
node.sourceSpan.end.offset,
15591568
];
15601569
const currentASTNode: ASTNode = {
1561-
type: node.type,
1570+
type: nodeType,
15621571
range: [currentNodeRangeStart, currentNodeRangeEnd],
15631572
};
15641573

1565-
switch (node.type) {
1574+
switch (nodeType) {
15661575
case 'attribute': {
15671576
nonCommentNodes.push(currentASTNode);
15681577

@@ -1578,7 +1587,7 @@ export function findTargetClassNameNodesForHtml(
15781587
name: z.string(),
15791588
}),
15801589
) &&
1581-
parentNode.type === 'element' &&
1590+
parentNodeType === 'element' &&
15821591
isTypeof(
15831592
node,
15841593
z.object({
@@ -1779,14 +1788,23 @@ export function findTargetClassNameNodesForVue(
17791788
*/
17801789
const classNameNodes: ClassNameNode[] = [];
17811790

1782-
function recursion(node: unknown, parentNode?: { type?: unknown }): void {
1783-
if (!isTypeof(node, z.object({ type: z.string() }))) {
1791+
function recursion(
1792+
node: unknown,
1793+
parentNode?: { kind: string; type?: undefined } | { kind?: undefined; type: string },
1794+
): void {
1795+
if (
1796+
!isTypeof(node, z.object({ kind: z.string() })) &&
1797+
!isTypeof(node, z.object({ type: z.string() }))
1798+
) {
17841799
return;
17851800
}
17861801

1802+
const nodeType = isTypeof(node, z.object({ kind: z.string() })) ? node.kind : node.type;
1803+
const parentNodeType = parentNode?.kind ?? parentNode?.type;
1804+
17871805
let recursiveProps: string[] = [];
17881806

1789-
switch (node.type) {
1807+
switch (nodeType) {
17901808
case 'element': {
17911809
recursiveProps = ['attrs', 'children'];
17921810
break;
@@ -1838,11 +1856,11 @@ export function findTargetClassNameNodesForVue(
18381856
node.sourceSpan.end.offset,
18391857
];
18401858
const currentASTNode: ASTNode = {
1841-
type: node.type,
1859+
type: nodeType,
18421860
range: [currentNodeRangeStart, currentNodeRangeEnd],
18431861
};
18441862

1845-
switch (node.type) {
1863+
switch (nodeType) {
18461864
case 'attribute': {
18471865
nonCommentNodes.push(currentASTNode);
18481866

@@ -1860,7 +1878,7 @@ export function findTargetClassNameNodesForVue(
18601878
name: z.string(),
18611879
}),
18621880
) &&
1863-
parentNode.type === 'element' &&
1881+
parentNodeType === 'element' &&
18641882
isTypeof(
18651883
node,
18661884
z.object({
@@ -2074,14 +2092,23 @@ export function findTargetClassNameNodesForAngular(
20742092
*/
20752093
const classNameNodes: ClassNameNode[] = [];
20762094

2077-
function recursion(node: unknown, parentNode?: { type?: unknown }): void {
2078-
if (!isTypeof(node, z.object({ type: z.string() }))) {
2095+
function recursion(
2096+
node: unknown,
2097+
parentNode?: { kind: string; type?: undefined } | { kind?: undefined; type: string },
2098+
): void {
2099+
if (
2100+
!isTypeof(node, z.object({ kind: z.string() })) &&
2101+
!isTypeof(node, z.object({ type: z.string() }))
2102+
) {
20792103
return;
20802104
}
20812105

2106+
const nodeType = isTypeof(node, z.object({ kind: z.string() })) ? node.kind : node.type;
2107+
const parentNodeType = parentNode?.kind ?? parentNode?.type;
2108+
20822109
let recursiveProps: string[] = [];
20832110

2084-
switch (node.type) {
2111+
switch (nodeType) {
20852112
case 'angularControlFlowBlock':
20862113
case 'root': {
20872114
recursiveProps = ['children'];
@@ -2134,11 +2161,11 @@ export function findTargetClassNameNodesForAngular(
21342161
node.sourceSpan.end.offset,
21352162
];
21362163
const currentASTNode: ASTNode = {
2137-
type: node.type,
2164+
type: nodeType,
21382165
range: [currentNodeRangeStart, currentNodeRangeEnd],
21392166
};
21402167

2141-
switch (node.type) {
2168+
switch (nodeType) {
21422169
case 'attribute': {
21432170
nonCommentNodes.push(currentASTNode);
21442171

@@ -2156,7 +2183,7 @@ export function findTargetClassNameNodesForAngular(
21562183
name: z.string(),
21572184
}),
21582185
) &&
2159-
parentNode.type === 'element' &&
2186+
parentNodeType === 'element' &&
21602187
isTypeof(
21612188
node,
21622189
z.object({

src/parsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ async function advancedParse(
2323
defaultParser: Parser,
2424
options: ResolvedOptions,
2525
): Promise<AST> {
26-
const preprocessedText = defaultParser.preprocess
26+
const preprocessedText = await (defaultParser.preprocess
2727
? defaultParser.preprocess(text, options)
28-
: text;
28+
: text);
2929
let ast = await defaultParser.parse(preprocessedText, options);
3030

3131
if (parserName === 'svelte') {

tests/angular/string-literal-property/absolute.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const fixtures: Fixture[] = [
5151
<div
5252
[class]="
5353
classNames({
54-
' lorem ipsum dolor sit amet ': true
54+
' lorem ipsum dolor sit amet ': true,
5555
})
5656
"
5757
>
@@ -80,7 +80,7 @@ const fixtures: Fixture[] = [
8080
<div
8181
[class]="
8282
classNames({
83-
'lorem ipsum dolor sit amet': true
83+
'lorem ipsum dolor sit amet': true,
8484
})
8585
"
8686
>
@@ -107,7 +107,7 @@ const fixtures: Fixture[] = [
107107
[class]="
108108
classNames({
109109
'lorem ipsum dolor sit amet consectetur adipiscing
110-
elit proin': true
110+
elit proin': true,
111111
})
112112
"
113113
>
@@ -134,7 +134,7 @@ const fixtures: Fixture[] = [
134134
[class]="
135135
classNames({
136136
' lorem ipsum dolor sit amet consectetur
137-
adipiscing elit proin ': true
137+
adipiscing elit proin ': true,
138138
})
139139
"
140140
>
@@ -166,7 +166,7 @@ const fixtures: Fixture[] = [
166166
[class]="
167167
classNames({
168168
'lorem ipsum dolor sit amet consectetur adipiscing
169-
elit proin': true
169+
elit proin': true,
170170
})
171171
"
172172
>
@@ -194,7 +194,7 @@ const fixtures: Fixture[] = [
194194
classNames({
195195
'lorem ipsum dolor sit amet consectetur adipiscing
196196
elit proin ex massa hendrerit eu posuere eu
197-
volutpat id neque pellentesque': true
197+
volutpat id neque pellentesque': true,
198198
})
199199
"
200200
>
@@ -222,7 +222,7 @@ const fixtures: Fixture[] = [
222222
classNames({
223223
' lorem ipsum dolor sit amet consectetur
224224
adipiscing elit proin ex massa hendrerit eu
225-
posuere eu volutpat id neque pellentesque ': true
225+
posuere eu volutpat id neque pellentesque ': true,
226226
})
227227
"
228228
>
@@ -255,7 +255,7 @@ const fixtures: Fixture[] = [
255255
classNames({
256256
'lorem ipsum dolor sit amet consectetur adipiscing
257257
elit proin ex massa hendrerit eu posuere eu
258-
volutpat id neque pellentesque': true
258+
volutpat id neque pellentesque': true,
259259
})
260260
"
261261
>
@@ -282,7 +282,7 @@ const fixtures: Fixture[] = [
282282
[class]="
283283
classNames({
284284
'lorem ipsum dolor sit amet consectetur adipiscing
285-
elit proin ex massa hendrerit eu posuere': true
285+
elit proin ex massa hendrerit eu posuere': true,
286286
})
287287
"
288288
>
@@ -309,7 +309,7 @@ const fixtures: Fixture[] = [
309309
[className]="
310310
classNames({
311311
'lorem ipsum dolor sit amet consectetur adipiscing
312-
elit proin ex massa hendrerit eu posuere': true
312+
elit proin ex massa hendrerit eu posuere': true,
313313
})
314314
"
315315
>
@@ -336,7 +336,7 @@ const fixtures: Fixture[] = [
336336
[attr.class]="
337337
classNames({
338338
'lorem ipsum dolor sit amet consectetur adipiscing
339-
elit proin ex massa hendrerit eu posuere': true
339+
elit proin ex massa hendrerit eu posuere': true,
340340
})
341341
"
342342
>
@@ -363,7 +363,7 @@ const fixtures: Fixture[] = [
363363
[ngClass]="
364364
classNames({
365365
'lorem ipsum dolor sit amet consectetur adipiscing
366-
elit proin ex massa hendrerit eu posuere': true
366+
elit proin ex massa hendrerit eu posuere': true,
367367
})
368368
"
369369
>

0 commit comments

Comments
 (0)