-
Notifications
You must be signed in to change notification settings - Fork 53
@W-776022@ Give precedence to --tsconfig flag over cwd #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@W-776022@ Give precedence to --tsconfig flag over cwd #131
Conversation
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" |
There was a problem hiding this comment.
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); | ||
| }); | ||
|
|
||
|
|
There was a problem hiding this comment.
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.
jfeingold35
left a comment
There was a problem hiding this 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.
| 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]); | ||
| } |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's cleaner.
jfeingold35
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
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.