Skip to content
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

feat: Add findConfigFile() method to FlatESLint #17142

Merged
merged 1 commit into from May 3, 2023

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented May 2, 2023

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Adds a findConfigFile() method to FlatESLint. The purpose of this method is to return the location of the config file this FlatESLint instance will use as the basis for its configuration without actually loading the file.

Fixes #17046

Is there anything you'd like reviewers to focus on?

I didn't include any caching for the config file path as I don't see this as a common enough use case to optimize what is typically a very fast search. Let me know if you think differently.

@nzakas nzakas requested a review from a team as a code owner May 2, 2023 21:34
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label May 2, 2023
@netlify
Copy link

netlify bot commented May 2, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 70eb1d9
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/645181f24a206f00080884b6

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! I'll leave this open for a couple of days in case anyone else wants to take a look.

@amareshsm amareshsm added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 3, 2023
Copy link
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

LGTM

@snitin315 snitin315 merged commit f5574dc into main May 3, 2023
22 checks passed
@snitin315 snitin315 deleted the find-flat-config-file branch May 3, 2023 15:01
@mdjermanovic
Copy link
Member

@nzakas in the default mode (overrideConfigFile constructor option is not a string or true), findConfigFile() throws an error if it doesn't find an eslint.config.js file. I assumed this was desired behavior, but per the example from #17129 (comment) where it returns a falsy value that doesn't seem to be the case, so just to double check with you - is throwing an error in mentioned case the desired behavior?

@mdjermanovic
Copy link
Member

in the default mode (overrideConfigFile constructor option is not a string or true), findConfigFile() throws an error if it doesn't find an eslint.config.js file. I assumed this was desired behavior, but per the example from #17129 (comment) where it returns a falsy value that doesn't seem to be the case, so just to double check with you - is throwing an error in mentioned case the desired behavior?

Fixed by #17151.

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Oct 31, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Request: Add JS API method to find nearest config file
4 participants