Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96ef4ce

Browse files
committed
lintfix
1 parent 7c5c1a0 commit 96ef4ce

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/test/transpilers.spec.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,34 @@
33
// Should consolidate them here.
44

55
import { context } from './testlib';
6-
import {
7-
contextTsNodeUnderTest,
8-
testsDirRequire,
9-
} from './helpers';
6+
import { contextTsNodeUnderTest, testsDirRequire } from './helpers';
107
import * as expect from 'expect';
118

129
const test = context(contextTsNodeUnderTest);
1310

1411
test.suite('swc', (test) => {
1512
test('verify that TS->SWC target mappings suppport all possible values from both TS and SWC', async (t) => {
16-
const swcTranspiler = testsDirRequire('ts-node/transpilers/swc-experimental') as typeof import('../transpilers/swc');
13+
const swcTranspiler = testsDirRequire(
14+
'ts-node/transpilers/swc-experimental'
15+
) as typeof import('../transpilers/swc');
1716

1817
// Detect when mapping is missing any ts.ScriptTargets
1918
const ts = testsDirRequire('typescript') as typeof import('typescript');
20-
for(const key of Object.keys(ts.ScriptTarget)) {
21-
if(/^\d+$/.test(key)) continue;
22-
if(key === 'JSON') continue;
23-
expect(swcTranspiler.targetMapping.has(ts.ScriptTarget[key as any] as any)).toBe(true);
19+
for (const key of Object.keys(ts.ScriptTarget)) {
20+
if (/^\d+$/.test(key)) continue;
21+
if (key === 'JSON') continue;
22+
expect(
23+
swcTranspiler.targetMapping.has(ts.ScriptTarget[key as any] as any)
24+
).toBe(true);
2425
}
2526

2627
// Detect when mapping is missing any swc targets
2728
// Assuming that tests/package.json declares @swc/core: latest
2829
const swc = testsDirRequire('@swc/core');
2930
let msg: string | undefined = undefined;
3031
try {
31-
swc.transformSync('', {jsc: {target: 'invalid'}});
32-
} catch(e) {
32+
swc.transformSync('', { jsc: { target: 'invalid' } });
33+
} catch (e) {
3334
msg = (e as Error).message;
3435
}
3536
expect(msg).toBeDefined();
@@ -39,7 +40,7 @@ test.suite('swc', (test) => {
3940
expect(match).toBeDefined();
4041
const targets = match![1].split(', ').map((v: string) => v.slice(1, -1));
4142

42-
for(const target of targets) {
43+
for (const target of targets) {
4344
expect([...swcTranspiler.targetMapping.values()]).toContain(target);
4445
}
4546
});

src/transpilers/swc.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ export function create(createOptions: SwcTranspilerOptions): Transpiler {
6161
// Perhaps project has an older version of swc.
6262
// TODO cache the results of this; slightly faster
6363
let swcTargetIndex = swcTargets.indexOf(swcTarget);
64-
for(; swcTargetIndex >= 0; swcTargetIndex--) {
64+
for (; swcTargetIndex >= 0; swcTargetIndex--) {
6565
try {
66-
swcInstance.transformSync('', {jsc: {target: swcTargets[swcTargetIndex]}});
66+
swcInstance.transformSync('', {
67+
jsc: { target: swcTargets[swcTargetIndex] },
68+
});
6769
break;
68-
} catch(e) {}
70+
} catch (e) {}
6971
}
7072
swcTarget = swcTargets[swcTargetIndex];
7173
const keepClassNames = target! >= /* ts.ScriptTarget.ES2016 */ 3;
@@ -148,7 +150,17 @@ type SwcTarget = typeof swcTargets[number];
148150
* @internal
149151
* We use this list to downgrade to a prior target when we probe swc to detect if it supports a particular target
150152
*/
151-
const swcTargets = ['es3', 'es5', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021'] as const;
153+
const swcTargets = [
154+
'es3',
155+
'es5',
156+
'es2015',
157+
'es2016',
158+
'es2017',
159+
'es2018',
160+
'es2019',
161+
'es2020',
162+
'es2021',
163+
] as const;
152164

153165
const ModuleKind = {
154166
None: 0,

0 commit comments

Comments
 (0)