Skip to content

Commit ebda77a

Browse files
committed
chore: format with prettier@v2
1 parent b277366 commit ebda77a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import ts from "typescript";
33
import { parse } from "url";
44
import { existsSync } from "fs";
55

6-
76
/* ****************************************************************************************************************** *
87
* Helpers
98
* ****************************************************************************************************************** */
109

1110
export const normalizePath = (p: string) =>
1211
// Is extended length or has non-ascii chars (respectively)
13-
(/^\\\\\?\\/.test(p) || /[^\u0000-\u0080]+/.test(p)) ? p :
14-
// Normalize to forward slash and remove repeating slashes
15-
p.replace(/[\\\/]+/g, '/');
16-
12+
/^\\\\\?\\/.test(p) || /[^\u0000-\u0080]+/.test(p)
13+
? p
14+
: // Normalize to forward slash and remove repeating slashes
15+
p.replace(/[\\\/]+/g, "/");
1716

1817
/* ****************************************************************************************************************** *
1918
* Transformer
@@ -48,10 +47,10 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
4847
paths["*"] = paths["*"]?.concat("*") ?? ["*"];
4948

5049
const binds = Object.keys(paths)
51-
.filter(key => paths[key].length)
52-
.map(key => ({
50+
.filter((key) => paths[key].length)
51+
.map((key) => ({
5352
regexp: new RegExp("^" + key.replace("*", "(.*)") + "$"),
54-
paths: paths[key]
53+
paths: paths[key],
5554
}));
5655

5756
if (!baseUrl || binds.length === 0) {
@@ -90,7 +89,8 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
9089
if (isUrl(out)) return out;
9190

9291
const filepath = resolve(baseUrl, out);
93-
if (!fileExists(`${filepath}/index`) && !fileExists(filepath)) continue;
92+
if (!fileExists(`${filepath}/index`) && !fileExists(filepath))
93+
continue;
9494

9595
const resolved = fixupImportPath(relative(sourceDir, filepath));
9696

@@ -150,7 +150,7 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
150150
const fileLiteral = ts.createLiteral(file);
151151

152152
return ts.updateCall(node, node.expression, node.typeArguments, [
153-
fileLiteral
153+
fileLiteral,
154154
]);
155155
}
156156

@@ -247,7 +247,7 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
247247
visitImportSpecifier as any,
248248
ts.isImportSpecifier
249249
);
250-
return elements.some(e => e)
250+
return elements.some((e) => e)
251251
? ts.updateNamedImports(node, elements)
252252
: undefined;
253253
}
@@ -313,7 +313,7 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
313313
visitExportSpecifier as any,
314314
ts.isExportSpecifier
315315
);
316-
return elements.some(e => e)
316+
return elements.some((e) => e)
317317
? ts.updateNamedExports(node, elements)
318318
: undefined;
319319
}
@@ -323,12 +323,12 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
323323
return resolver.isValueAliasDeclaration(node) ? node : undefined;
324324
}
325325

326-
function fixupImportPath(p:string) {
326+
function fixupImportPath(p: string) {
327327
let res = normalizePath(p);
328328

329329
/* Remove implicit extension */
330330
const ext = extname(res);
331-
if (ext && implicitExtensions.includes(ext.replace(/^\./, '')))
331+
if (ext && implicitExtensions.includes(ext.replace(/^\./, "")))
332332
res = res.slice(0, -ext.length);
333333

334334
return res;

0 commit comments

Comments
 (0)