Skip to content

--baseDir value is ignored when determining the config file name #137

@nishanths

Description

@nishanths

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions