Skip to content

Commit ae85987

Browse files
committed
chore: prettier and use dash-case for file names
1 parent be63087 commit ae85987

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const typescriptPaths = ({
66
tsConfigPath = findConfigFile('./', sys.fileExists),
77
absolute = true,
88
transform,
9-
preserveExtensions = false
9+
preserveExtensions = false,
1010
}: Options = {}): Plugin => {
1111
const { compilerOptions, outDir } = getTsConfig(tsConfigPath);
1212

@@ -37,7 +37,10 @@ export const typescriptPaths = ({
3737
return null;
3838
}
3939

40-
const jsFileName = join(outDir, preserveExtensions ? resolvedFileName : resolvedFileName.replace(/\.tsx?$/i, '.js'));
40+
const jsFileName = join(
41+
outDir,
42+
preserveExtensions ? resolvedFileName : resolvedFileName.replace(/\.tsx?$/i, '.js'),
43+
);
4144

4245
let resolved = absolute ? sys.resolvePath(jsFileName) : jsFileName;
4346

File renamed without changes.

test/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ const typescriptPaths = require('../dist').default;
77
const transform = (path) => path.replace(/\.js$/i, '.cjs.js');
88

99
const plugin = typescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json') });
10+
1011
const pluginNonAbs = typescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json'), absolute: false });
12+
1113
const pluginTransform = typescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json'), transform });
12-
const pluginPreserveExtensions = typescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json'), preserveExtensions: true });
14+
15+
const pluginPreserveExtensions = typescriptPaths({
16+
tsConfigPath: resolve(__dirname, 'tsconfig.json'),
17+
preserveExtensions: true,
18+
});
1319

1420
try {
1521
strictEqual(plugin.resolveId('@asdf', ''), null);
1622
strictEqual(plugin.resolveId('\0@foobar', ''), null);
1723
strictEqual(plugin.resolveId('@foobar', ''), join(__dirname, 'foo', 'bar.js'));
18-
strictEqual(plugin.resolveId('@foobar-react', ''), join(__dirname, 'foo', 'barReact.js'));
24+
strictEqual(plugin.resolveId('@foobar-react', ''), join(__dirname, 'foo', 'bar-react.js'));
1925
strictEqual(plugin.resolveId('@bar/foo', ''), join(__dirname, 'bar', 'foo.js'));
2026
strictEqual(plugin.resolveId('@js', ''), join(__dirname, 'js', 'index.js'));
2127

@@ -24,7 +30,7 @@ try {
2430
strictEqual(pluginTransform.resolveId('@foobar', ''), join(__dirname, 'foo', 'bar.cjs.js'));
2531

2632
strictEqual(pluginPreserveExtensions.resolveId('@foobar', ''), join(__dirname, 'foo', 'bar.ts'));
27-
strictEqual(pluginPreserveExtensions.resolveId('@foobar-react', ''), join(__dirname, 'foo', 'barReact.tsx'));
33+
strictEqual(pluginPreserveExtensions.resolveId('@foobar-react', ''), join(__dirname, 'foo', 'bar-react.tsx'));
2834

2935
console.log('PASSED');
3036
} catch (error) {

test/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"baseUrl": "test",
55
"paths": {
66
"@foobar": ["foo/bar"],
7-
"@foobar-react": ["foo/barReact"],
7+
"@foobar-react": ["foo/bar-react"],
88
"@bar/*": ["bar/*"],
99
"@js": ["js"]
1010
}

0 commit comments

Comments
 (0)