generated from qiwi/blank-ts-repo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow configure
js
and ts
extensions lists
closes #168
- Loading branch information
1 parent
a964d86
commit 3d2630e
Showing
9 changed files
with
98 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import {IFixOptions, IFixOptionsNormalized} from "./interface"; | ||
import {omitUndefinedKeys} from './util' | ||
import { IFixOptions, IFixOptionsNormalized } from './interface' | ||
import { asArray, omitUndefinedKeys } from './util' | ||
|
||
export const JS_EXT = ['.js', '.jsx', '.mjs', '.mjsx', '.cjs', '.cjsx'] | ||
export const TS_EXT = ['.ts', '.tsx', '.mts', '.mtsx', '.cts', '.ctsx'] | ||
|
||
export const DEFAULT_FIX_OPTIONS: IFixOptionsNormalized = { | ||
cwd: process.cwd(), | ||
tsconfig: './tsconfig.json', | ||
tsconfig: ['./tsconfig.json'], | ||
src: [], | ||
target: [], | ||
filenameVar: true, | ||
dirnameVar: true, | ||
ext: true, | ||
tsExt: TS_EXT, | ||
jsExt: JS_EXT, | ||
unlink: true, | ||
debug: () => {}, // eslint-disable-line | ||
} | ||
|
||
export const normalizeOptions = ( | ||
opts?: IFixOptions, | ||
opts: IFixOptions = {}, | ||
): IFixOptionsNormalized => ({ | ||
...DEFAULT_FIX_OPTIONS, | ||
...omitUndefinedKeys(opts || {}), | ||
debug: typeof opts?.debug === 'function' | ||
...omitUndefinedKeys(opts), | ||
tsconfig: opts.tsconfig ? asArray(opts.tsconfig) : DEFAULT_FIX_OPTIONS.tsconfig, | ||
src: asArray(opts.src), | ||
target: asArray(opts.target), | ||
jsExt: typeof opts.jsExt === 'string' ? opts.jsExt.split(',') : opts.jsExt || DEFAULT_FIX_OPTIONS.jsExt, | ||
tsExt: typeof opts.tsExt === 'string' ? opts.tsExt.split(',') : opts.tsExt || DEFAULT_FIX_OPTIONS.tsExt, | ||
debug: typeof opts.debug === 'function' | ||
? opts.debug | ||
: opts?.debug === true | ||
: opts.debug === true | ||
? console.log | ||
: DEFAULT_FIX_OPTIONS.debug, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters