Skip to content

Commit c1b659a

Browse files
committed
style: fix formatting
1 parent b4a483e commit c1b659a

File tree

8 files changed

+48
-33
lines changed

8 files changed

+48
-33
lines changed

src/transformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ts from "typescript";
55
import { cast, getImplicitExtensions } from "./utils";
66
import { TsTransformPathsConfig, TsTransformPathsContext, TypeScriptThree, VisitorContext } from "./types";
77
import { nodeVisitor } from "./visitor";
8-
import { createHarmonyFactory } from './utils/harmony-factory';
8+
import { createHarmonyFactory } from "./utils/harmony-factory";
99

1010
/* ****************************************************************************************************************** *
1111
* Transformer
@@ -47,7 +47,7 @@ export default function transformer(
4747
getVisitor() {
4848
return nodeVisitor.bind(this);
4949
},
50-
factory: createHarmonyFactory(tsTransformPathsContext)
50+
factory: createHarmonyFactory(tsTransformPathsContext),
5151
};
5252

5353
return tsInstance.visitEachChild(sourceFile, visitorContext.getVisitor(), transformationContext);

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import tsThree from "./declarations/typescript3";
22
import ts, { CompilerOptions } from "typescript";
33
import { PluginConfig } from "ts-patch";
4-
import { HarmonyFactory } from './utils/harmony-factory';
4+
import { HarmonyFactory } from "./utils/harmony-factory";
55

66
/* ****************************************************************************************************************** */
77
// region: TS Types

src/utils/elide-import-export.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@
2828
* import { A, B } from './b'
2929
* export { A } from './b'
3030
*/
31-
import { ImportOrExportClause, ImportOrExportDeclaration, VisitorContext } from '../types';
31+
import { ImportOrExportClause, ImportOrExportDeclaration, VisitorContext } from "../types";
3232
import {
33-
ExportDeclaration, ExportSpecifier, ImportClause, ImportDeclaration, ImportSpecifier, NamedExports,
34-
NamedImportBindings, Visitor, VisitResult
35-
} from 'typescript';
33+
ExportDeclaration,
34+
ExportSpecifier,
35+
ImportClause,
36+
ImportDeclaration,
37+
ImportSpecifier,
38+
NamedExports,
39+
NamedImportBindings,
40+
Visitor,
41+
VisitResult,
42+
} from "typescript";
3643

3744
/* ****************************************************************************************************************** */
3845
// region: Utilities
@@ -62,7 +69,7 @@ export function elideImportOrExportClause(
6269
SyntaxKind,
6370
visitNodes,
6471
isNamedExportBindings,
65-
isExportSpecifier
72+
isExportSpecifier,
6673
} = tsInstance;
6774

6875
if (tsInstance.isImportDeclaration(node)) {

src/utils/general-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import ts from 'typescript';
2-
import url from 'url';
3-
import path from 'path';
1+
import ts from "typescript";
2+
import url from "url";
3+
import path from "path";
44

55
/* ****************************************************************************************************************** *
66
* General Utilities & Helpers

src/utils/harmony-factory.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import TS, {
2-
Decorator, ExportDeclaration, Expression, Identifier, ImportClause, Modifier, NamedExportBindings, NamedImportBindings
3-
} from 'typescript'
4-
import { TsTransformPathsContext } from '../types';
5-
import { downSampleTsTypes } from './ts-type-conversion';
2+
Decorator,
3+
ExportDeclaration,
4+
Expression,
5+
Identifier,
6+
ImportClause,
7+
Modifier,
8+
NamedExportBindings,
9+
NamedImportBindings,
10+
} from "typescript";
11+
import { TsTransformPathsContext } from "../types";
12+
import { downSampleTsTypes } from "./ts-type-conversion";
613

714
/* ****************************************************************************************************************** */
815
// region: Types
@@ -27,17 +34,18 @@ export function createHarmonyFactory(context: TsTransformPathsContext): HarmonyF
2734
if (context.tsFactory) return (<any>target)[prop];
2835

2936
switch (prop) {
30-
case 'updateCallExpression': return (...args:any) => tsThreeInstance.updateCall.apply(void 0, args);
31-
case 'updateImportClause':
37+
case "updateCallExpression":
38+
return (...args: any) => tsThreeInstance.updateCall.apply(void 0, args);
39+
case "updateImportClause":
3240
return function (
3341
node: ImportClause,
3442
isTypeOnly: boolean,
3543
name: Identifier | undefined,
3644
namedBindings: NamedImportBindings | undefined
3745
) {
3846
return tsThreeInstance.updateImportClause.apply(void 0, downSampleTsTypes(node, name, namedBindings));
39-
}
40-
case 'updateExportDeclaration':
47+
};
48+
case "updateExportDeclaration":
4149
return function (
4250
node: ExportDeclaration,
4351
decorators: readonly Decorator[] | undefined,
@@ -56,10 +64,11 @@ export function createHarmonyFactory(context: TsTransformPathsContext): HarmonyF
5664
// @ts-ignore - This was added in later versions of 3.x
5765
dsNode.isTypeOnly
5866
);
59-
}
60-
default: return (...args:any) => (<any>tsThreeInstance)[prop](...args);
67+
};
68+
default:
69+
return (...args: any) => (<any>tsThreeInstance)[prop](...args);
6170
}
62-
}
71+
},
6372
}) as HarmonyFactory;
6473
}
6574

src/utils/resolve-path-update-node.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ export function resolvePathAndUpdateNode(
2727
tsInstance.sys
2828
);
2929

30-
const overwriteModule : boolean = config.overwriteNodeModules
31-
if ( ! overwriteModule && resolvedModule?.isExternalLibraryImport ) return node;
30+
if (!config.overwriteNodeModules && resolvedModule?.isExternalLibraryImport) return node;
3231

3332
let outputPath: string;
34-
if ( ( ! resolvedModule || overwriteModule ) ) {
33+
if (!resolvedModule || config.overwriteNodeModules) {
3534
const maybeURL = failedLookupLocations[0];
3635
if (!isURL(maybeURL)) return node;
3736
outputPath = maybeURL;

src/visitor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import ts from 'typescript';
2-
import { VisitorContext } from './types';
3-
import { elideImportOrExportClause, resolvePathAndUpdateNode } from './utils';
1+
import ts from "typescript";
2+
import { VisitorContext } from "./types";
3+
import { elideImportOrExportClause, resolvePathAndUpdateNode } from "./utils";
44

55
/* ****************************************************************************************************************** *
66
* Node Visitor

test/tests/transformer/specific.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// noinspection ES6UnusedImports
2-
import {} from 'ts-expose-internals';
3-
import * as path from 'path';
4-
import { createTsProgram, EmittedFiles, getEmitResult } from '../../utils';
5-
import { projectsPaths, ts, tsModules, tTypeScript } from '../config';
2+
import {} from "ts-expose-internals";
3+
import * as path from "path";
4+
import { createTsProgram, EmittedFiles, getEmitResult } from "../../utils";
5+
import { projectsPaths, ts, tsModules, tTypeScript } from "../config";
66

77
/* ****************************************************************************************************************** *
88
* Config
99
* ****************************************************************************************************************** */
1010

1111
// TODO - In the future, remove this and create a separate small short test for TTS using a single SourceFile,
1212
// as we only need to test that it runs the transformer. No other behaviour will differ.
13-
let testTsModules = <const>[ ...tsModules, ["Latest (ttypescript)", tTypeScript] ];
13+
let testTsModules = <const>[...tsModules, ["Latest (ttypescript)", tTypeScript]];
1414

1515
/* ****************************************************************************************************************** *
1616
* Tests

0 commit comments

Comments
 (0)