Skip to content

Conversation

@jbartolotta-sfdc
Copy link
Contributor

The previous implementation would thrown an error if a tsconfig.json
file was found in the current working directory and the --tsconfig flag
was specified on the command line.

Allow this situation, giving precedence to the value provided to --tsconfig.

The previous implementation would thrown an error if a tsconfig.json
file was found in the current working directory and the --tsconfig flag
was specified on the command line.

Allow this situation, giving precedence to the value provided to --tsconfig.
"InvalidNameTsConfigFromOptions": "File '%s' specified by the --tsconfig flag must be named '%s'",
"NotAFileTsConfigFromOptions": "Unable to find '%s' at location '%s' specified by the 'tsconfig' option",
"MultipleTsConfigs": "'%s' was found in current directory at location '%s', '%s' was also specified by the --tsconfig flag. Please change to another directory or remove the --tsconfig flag."
"NotAFileTsConfigFromOptions": "Unable to find '%s' at location '%s' specified by the 'tsconfig' option"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the the docs/examples for the run command, they don't need to be changed based on this change.

expect(fileFound).equals(engineOptionsVal);
});


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this up negative test cases since it is now allowed.

Copy link
Contributor

@jfeingold35 jfeingold35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, aside from the one style critique.

Comment on lines 140 to 149
let foundTsConfig = await this.checkEngineOptionsForTsconfig(engineOptions);

if (!foundTsConfig) {
foundTsConfig = await this.checkWorkingDirectoryForTsconfig();
if (!foundTsConfig) {
const cwd = path.resolve();
// Not specified in engineOptions and not found in the current directory
throw SfdxError.create('@salesforce/sfdx-scanner', 'TypescriptEslintStrategy', 'MissingTsConfigFromCwd',
[TS_CONFIG, cwd, TS_CONFIG]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace this with:
let foundTsConfig = (await this.checkEngineBlah()) || (await this.checkWorkingBlah()) || null;
if (!foundTsConfig) {
// Your code that throws an error
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's cleaner.

Copy link
Contributor

@jfeingold35 jfeingold35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@jbartolotta-sfdc jbartolotta-sfdc merged commit d457edb into dev Jul 7, 2020
@jbartolotta-sfdc jbartolotta-sfdc deleted the d/jbartolotta/W-7760223-param-takes-precedence branch July 13, 2020 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants