fix: Ensure FlatESLint#findConfigFile() doesn't throw.#17151
Merged
Conversation
If findConfigFile() can't find eslint.config.js, it now returns undefined instead of throwing an error. Fixes #17150
✅ Deploy Preview for docs-eslint canceled.
|
snitin315
reviewed
May 5, 2023
| // determine where to load config file from | ||
| let configFilePath; | ||
| let basePath = cwd; | ||
| let error = false; |
Contributor
There was a problem hiding this comment.
The name error sounds generic and I expected it to be an instance of Error. Can we use something like isConfigFileDetected/hasConfigFile? I feel it's better suited for a boolean value.
Member
There was a problem hiding this comment.
Or we can return an error object error = new Error("Could not find config file.");, which can be thrown directly where it is used?
const { configFilePath, basePath, error } = await locateConfigFileToUse({ configFile, cwd });
// config file is required to calculate config
if (error) {
throw error;
}
Member
Author
There was a problem hiding this comment.
@aladdin-add I like that suggestion. Can you open a PR with that change?
mdjermanovic
approved these changes
May 5, 2023
Member
mdjermanovic
left a comment
There was a problem hiding this comment.
Works well! If the above discussion is not resolved before today's release, I'll merge this as is and we can consider refactoring in a follow up.
aladdin-add
added a commit
to aladdin-add/eslint
that referenced
this pull request
May 6, 2023
1 task
mdjermanovic
pushed a commit
that referenced
this pull request
May 7, 2023
1 task
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
If findConfigFile() can't find eslint.config.js, it now returns undefined instead of throwing an error.
Fixes #17150
Is there anything you'd like reviewers to focus on?
Did I miss any edge cases?