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

Fix/eslint cwd strategy #4781

Merged
merged 3 commits into from
May 31, 2024
Merged

Conversation

ghsang
Copy link
Contributor

@ghsang ghsang commented May 17, 2024

Closes #4487

according to eslint doc

When ESLint is run on the command line, it first checks the current working directory for eslint.config.js. If that file is found, then the search stops, otherwise it checks for eslint.config.mjs. If that file is found, then the search stops, otherwise it checks for eslint.config.cjs. If none of the files are not found, it checks the parent directory for each file. This search continues until either a config file is found or the root directory is reached.

Problem

  • The existing code sets the current working directory (cwd) to the directory where the closest node_modules with ESLint installed is found. In monorepo environments like pnpm workspace or yarn workspace, ESLint is typically installed only in the root node_modules, making that directory the cwd.
  • This setup fails to find the ESLint configuration if it exists only within the app's internal directories.

Solution

  • According to the ESLint documentation, ESLint searches for configuration files in a specific order starting from the cwd and moving up to the root directory.
  • To address the issue, modify the cwd to locate the closest ESLint configuration file from the current buffer. This change allows ESLint to find the configuration file in the parent directory if it exists, adhering to the standard configuration file resolution process described in the ESLint documentation.

@w0rp
Copy link
Member

w0rp commented May 31, 2024

This looks like the right thing to me. I'll go with this, and see if this breaks something for someone else. Only the JavaScript ecosystem could make configuration so complicated.

Cheers! 🍻

@w0rp w0rp merged commit adaa7f6 into dense-analysis:master May 31, 2024
7 checks passed
@emiel
Copy link

emiel commented May 31, 2024

Thank you for this!

@ghsang ghsang deleted the fix/eslint-cwd-strategy branch June 3, 2024 08:27
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.

ALE eslint cannot find config
3 participants