[eslint-patch] bulk suppressions patch fails to find eslintrc in git root
SpenserJ opened this issue · 0 comments
Summary
When trying to use @rushstack/eslint-patch/eslint-bulk-suppressions
in a package that is not a monorepo, the .eslintrc.js
may be at the root of the git repository. Enabling the patch for bulk suppression will throw an error of Cannot locate eslintrc
Repro steps
Reproduction: https://github.com/SpenserJ/rushstack/tree/repro-bulk-suppression-in-polyrepo
- Create a new repository with a new package (not a workspace/monorepo)
- Install ESLint and
@rushstack/eslint-patch
, and configure it with the bulk suppression patch and any ESLint config or preset you'd like - Create a file that will result in a linting error with your config
- Run ESLint against that file
Expected result: The linter should run and report any linting errors
Actual result: Error: Cannot locate eslintrc
Details
In a polyrepo, the eslintrc file will usually be in the root directory of the git repository, however findEslintrcDirectory
will stop as soon as it has reached the GitRootPath
. Changing this to check if we're outside/above the root path resolves this issue:
- for (let currentDir = fileAbsolutePath; currentDir !== GitRootPath; currentDir = path.dirname(currentDir))
+ for (let currentDir = fileAbsolutePath; currentDir.startsWith(GitRootPath); currentDir = path.dirname(currentDir))
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question | Answer |
---|---|
@rushstack/eslint-config version? |
N/A |
Operating system? | Mac |
Would you consider contributing a PR? | Yes |
TypeScript compiler version? | N/A |
Node.js version (node -v )? |
v20.10.0 |