Skip to content

Commit ed236b8

Browse files
committed
chore: run format
1 parent d7f404e commit ed236b8

File tree

7 files changed

+55
-118
lines changed

7 files changed

+55
-118
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
test:
1111
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
node_version: ['12.x', '14.x', '16.x', '18.x', '19.x', '20.x']
15+
node_version: ["12.x", "14.x", "16.x", "18.x", "19.x", "20.x"]
1616
os: [ubuntu-latest]
1717

1818
steps:
19-
- uses: actions/checkout@v2
20-
- name: Use Node.js ${{ matrix.node_version }}
21-
uses: actions/setup-node@v1
22-
with:
23-
node-version: ${{ matrix.node_version }}
19+
- uses: actions/checkout@v2
20+
- name: Use Node.js ${{ matrix.node_version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node_version }}
2424

25-
- name: npm install, build and test
26-
run: |
27-
npm install
28-
npm run build --if-present
29-
npm test
25+
- name: npm install, build and test
26+
run: |
27+
npm install
28+
npm run build --if-present
29+
npm test

lib/printer.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,10 +1474,7 @@ function genericPrintNoParens(path: any, options: any, print: any) {
14741474
return concat(parts);
14751475

14761476
case "ClassAccessorProperty": {
1477-
parts.push(
1478-
...printClassMemberModifiers(n),
1479-
"accessor ",
1480-
);
1477+
parts.push(...printClassMemberModifiers(n), "accessor ");
14811478

14821479
if (n.computed) {
14831480
parts.push("[", path.call(print, "key"), "]");
@@ -2236,7 +2233,7 @@ function genericPrintNoParens(path: any, options: any, print: any) {
22362233
return member.concat(";");
22372234
}
22382235
return member;
2239-
})
2236+
}),
22402237
);
22412238

22422239
if (members.isEmpty()) {
@@ -2289,8 +2286,7 @@ function genericPrintNoParens(path: any, options: any, print: any) {
22892286
return concat([path.call(print, "left"), ".", path.call(print, "right")]);
22902287

22912288
case "TSAsExpression":
2292-
case "TSSatisfiesExpression":
2293-
{
2289+
case "TSSatisfiesExpression": {
22942290
const expression = path.call(print, "expression");
22952291
parts.push(
22962292
expression,
@@ -2478,7 +2474,7 @@ function genericPrintNoParens(path: any, options: any, print: any) {
24782474
return element.concat(";");
24792475
}
24802476
return element;
2481-
})
2477+
}),
24822478
);
24832479
if (lines.isEmpty()) {
24842480
return fromString("{}", options);
@@ -2585,7 +2581,6 @@ function genericPrintNoParens(path: any, options: any, print: any) {
25852581
return concat(parts);
25862582
}
25872583

2588-
25892584
// https://github.com/babel/babel/pull/10148
25902585
case "V8IntrinsicIdentifier":
25912586
return concat(["%", path.call(print, "name")]);

test/babel.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,27 +454,32 @@ describe("Babel", function () {
454454
["class A {", " declare public readonly x;", "}"].join(eol),
455455
);
456456
});
457-
457+
458458
it("should keep braces in !(a && b)", function () {
459-
const code = '(options || !options.bidirectional) ? false : true;';
459+
const code = "(options || !options.bidirectional) ? false : true;";
460460
const ast = recast.parse(code, parseOptions);
461-
462-
ast.program.body[0].expression = b.unaryExpression('!', ast.program.body[0].expression.test);
461+
462+
ast.program.body[0].expression = b.unaryExpression(
463+
"!",
464+
ast.program.body[0].expression.test,
465+
);
463466

464467
assert.strictEqual(
465468
recast.print(ast).code,
466-
'!(options || !options.bidirectional);',
469+
"!(options || !options.bidirectional);",
467470
);
468471
});
469472

470473
it("should use single quotes", function () {
471-
const code = 'const a = 1;';
474+
const code = "const a = 1;";
472475
const ast = recast.parse(code, parseOptions);
473-
474-
ast.program.body.unshift(b.expressionStatement(b.stringLiteral('use strict')));
476+
477+
ast.program.body.unshift(
478+
b.expressionStatement(b.stringLiteral("use strict")),
479+
);
475480

476481
assert.strictEqual(
477-
recast.print(ast, {quote: 'single'}).code,
482+
recast.print(ast, { quote: "single" }).code,
478483
`'use strict';\nconst a = 1;`,
479484
);
480485
});
@@ -490,9 +495,6 @@ describe("Babel", function () {
490495
];
491496
const ast = recast.parse(code.join(eol), parseOptions);
492497

493-
assert.strictEqual(
494-
recast.prettyPrint(ast).code,
495-
code.join(eol),
496-
);
498+
assert.strictEqual(recast.prettyPrint(ast).code, code.join(eol));
497499
});
498500
});

test/printer.ts

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,11 +1174,7 @@ describe("printer", function () {
11741174
});
11751175

11761176
it("prints class property initializers with type annotations correctly", function () {
1177-
const code = [
1178-
"class A {",
1179-
" foo = (a: b): void => {};",
1180-
"}",
1181-
].join(eol);
1177+
const code = ["class A {", " foo = (a: b): void => {};", "}"].join(eol);
11821178

11831179
const arg = b.identifier("a");
11841180
arg.typeAnnotation = b.typeAnnotation(
@@ -1204,11 +1200,7 @@ describe("printer", function () {
12041200
});
12051201

12061202
it("prints ClassProperty correctly", function () {
1207-
const code = [
1208-
"class A {",
1209-
" foo: Type = Bar;",
1210-
"}",
1211-
].join(eol);
1203+
const code = ["class A {", " foo: Type = Bar;", "}"].join(eol);
12121204

12131205
const ast = b.program([
12141206
b.classDeclaration(
@@ -1234,11 +1226,7 @@ describe("printer", function () {
12341226
});
12351227

12361228
it("prints 'definite' ClassProperty correctly", function () {
1237-
const code = [
1238-
"class A {",
1239-
" foo!: string;",
1240-
"}",
1241-
].join(eol);
1229+
const code = ["class A {", " foo!: string;", "}"].join(eol);
12421230

12431231
const ast = b.program([
12441232
b.classDeclaration(
@@ -1265,11 +1253,7 @@ describe("printer", function () {
12651253
});
12661254

12671255
it("prints static ClassProperty correctly", function () {
1268-
const code = [
1269-
"class A {",
1270-
" static foo = Bar;",
1271-
"}",
1272-
].join(eol);
1256+
const code = ["class A {", " static foo = Bar;", "}"].join(eol);
12731257

12741258
const ast = b.program([
12751259
b.classDeclaration(
@@ -1289,11 +1273,7 @@ describe("printer", function () {
12891273
});
12901274

12911275
it("prints ClassAccessorProperty correctly", function () {
1292-
const code = [
1293-
"class A {",
1294-
" accessor foo: Type = Bar;",
1295-
"}",
1296-
].join(eol);
1276+
const code = ["class A {", " accessor foo: Type = Bar;", "}"].join(eol);
12971277

12981278
const ast = b.program([
12991279
b.classDeclaration(
@@ -1304,8 +1284,8 @@ describe("printer", function () {
13041284
value: b.identifier("Bar"),
13051285
typeAnnotation: b.tsTypeAnnotation(
13061286
b.tsTypeReference(b.identifier("Type")),
1307-
)
1308-
})
1287+
),
1288+
}),
13091289
]),
13101290
),
13111291
]);
@@ -1319,11 +1299,7 @@ describe("printer", function () {
13191299
});
13201300

13211301
it("prints 'definite' ClassAccessorProperty correctly", function () {
1322-
const code = [
1323-
"class A {",
1324-
" accessor foo!: string;",
1325-
"}",
1326-
].join(eol);
1302+
const code = ["class A {", " accessor foo!: string;", "}"].join(eol);
13271303

13281304
const ast = b.program([
13291305
b.classDeclaration(
@@ -1347,11 +1323,7 @@ describe("printer", function () {
13471323
});
13481324

13491325
it("prints static ClassAccessorProperty correctly", function () {
1350-
const code = [
1351-
"class A {",
1352-
" static accessor foo = Bar;",
1353-
"}",
1354-
].join(eol);
1326+
const code = ["class A {", " static accessor foo = Bar;", "}"].join(eol);
13551327

13561328
const ast = b.program([
13571329
b.classDeclaration(
@@ -1375,11 +1347,7 @@ describe("printer", function () {
13751347
});
13761348

13771349
it("prints abstract ClassAccessorProperty correctly", function () {
1378-
const code = [
1379-
"class A {",
1380-
" abstract accessor foo = Bar;",
1381-
"}",
1382-
].join(eol);
1350+
const code = ["class A {", " abstract accessor foo = Bar;", "}"].join(eol);
13831351

13841352
const ast = b.program([
13851353
b.classDeclaration(
@@ -1403,11 +1371,7 @@ describe("printer", function () {
14031371
});
14041372

14051373
it("prints override ClassAccessorProperty correctly", function () {
1406-
const code = [
1407-
"class A {",
1408-
" override accessor foo = Bar;",
1409-
"}",
1410-
].join(eol);
1374+
const code = ["class A {", " override accessor foo = Bar;", "}"].join(eol);
14111375

14121376
const ast = b.program([
14131377
b.classDeclaration(

test/syntax.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
4343
},
4444
});
4545

46-
Object.keys(types.namedTypes).forEach(name => {
46+
Object.keys(types.namedTypes).forEach((name) => {
4747
it(name, () => {
4848
assert.ok(hasOwn.call(typeNames, name), "unhandled type: " + name);
4949
assert.strictEqual(name, typeNames[name]);

test/typescript.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,13 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
278278
check([
279279
"class Dog extends Animal {",
280280
" protected override getSound() {",
281-
" return \"bark\";",
281+
' return "bark";',
282282
" }",
283283
"}",
284-
])
285-
286-
check([
287-
"export interface S {",
288-
" i(s: string): boolean;",
289-
"}"
290284
]);
291285

286+
check(["export interface S {", " i(s: string): boolean;", "}"]);
287+
292288
check([
293289
"namespace Validation {",
294290
" export interface S {",
@@ -297,17 +293,9 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
297293
"}",
298294
]);
299295

300-
check([
301-
"export interface S {",
302-
" i(j: string): boolean;",
303-
"}",
304-
]);
296+
check(["export interface S {", " i(j: string): boolean;", "}"]);
305297

306-
check([
307-
"declare namespace D3 {",
308-
" export const f: number;",
309-
"}",
310-
]);
298+
check(["declare namespace D3 {", " export const f: number;", "}"]);
311299

312300
check(["declare function foo<K, V>(arg: T = getDefault()): R"]);
313301

@@ -317,13 +305,7 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
317305
"}",
318306
]);
319307

320-
check([
321-
"function myFunction(",
322-
" {",
323-
" param1",
324-
" }: Params",
325-
") {}",
326-
]);
308+
check(["function myFunction(", " {", " param1", " }: Params", ") {}"]);
327309

328310
check([
329311
'const unqualified: import("package") = 1;',
@@ -354,8 +336,8 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
354336
check([
355337
"type alias = boolean;",
356338
"const value = 0;",
357-
"export { type alias, value };"
358-
])
339+
"export { type alias, value };",
340+
]);
359341
});
360342

361343
it("InterfaceBody: duplicate semicolon", function () {
@@ -461,11 +443,8 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
461443

462444
const ast = recast.parse(code, { parser });
463445

464-
assert.strictEqual(
465-
recast.prettyPrint(ast).code,
466-
code
467-
);
468-
})
446+
assert.strictEqual(recast.prettyPrint(ast).code, code);
447+
});
469448
});
470449

471450
testReprinting(

tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,5 @@
1414
"importHelpers": true,
1515
"stripInternal": true
1616
},
17-
"exclude": [
18-
"node_modules",
19-
"test/data"
20-
]
17+
"exclude": ["node_modules", "test/data"]
2118
}

0 commit comments

Comments
 (0)