typescript-formatter
typescript-formatter copied to clipboard
--baseDir value is ignored when determining the config file name
In lib/cli.ts the following code is used to determine the value of opts.tsfmtFile. Note that as a result of the path.join call, the value of opts.tsfmtFile will always be an absolute path (since process.cwd() evaluates to an absolute path).
let tsfmtFile = opts.useTsfmt[0] ? path.join(process.cwd(), opts.useTsfmt[0]) : null;
Next, in lib/provider/base.ts the makeCodeFormatOption function does the following to determine the config file name:
if (opts.tsfmtFile && path.isAbsolute(opts.tsfmtFile)) {
configFileName = opts.tsfmtFile;
} else {
configFileName = getConfigFileName(baseDir, opts.tsfmtFile || "tsfmt.json");
}
As noted above, opts.tsfmtFile is always an absolute path whenever the --useTsfmt flag is specified. So the if always evaluates to true in this case and config file name is assigned value of opts.tsfmtFile. The value of baseDir is never used in determining the configFileName, even when the --baseDir flag is set. This appears to be incorrect behavior.
Other providers (tslint, tsconfigjson, and vscodesettings) also exhibit the same incorrect behavior.