Open Diogosr6 opened 2 years ago
Thanks for reporting! It might be that you're using an older version of git. Which exact version of git are you running? Personally, I'm developing this plugin using git version 2.37.2.
I'm seeing the same error with latest git 2.37.3. The error appeared starting at eslint-plugin-diff
version 1.0.16.
And I'm also invoking it with the ESLINT_PLUGIN_DIFF_COMMIT
env var:
ESLINT_PLUGIN_DIFF_COMMIT=main.. yarn lint --config .eslintrc-ci-diff.js --color frontend/src/**/*.ts frontend/src/**/*.tsx
Had the same issue and there are 2 issues the plugin and diff/diff
processor:
diff/diff
pulls mutual changes from both ahead and behind commits and runs ESLint on them. Most likely use case though, is that we we want to run ESLint only on changes introduced by ahead commits.ESLINT_PLUGIN_DIFF_COMMIT
can be set to something like base_branch...
, but this is not a valid syntax for git diff --staged
, and because getProcessors
function pulls diffFileList
- it is run for all 3 processors during plugin init, regardless of desired processor, resulting in failure when staged
processor is loaded.I think a potential solution would be to only pull diffFileList
inside processors, and not during plugin load.
My workaround was just to feed ESLint a narrowed down list of files with eslint $(git diff --name-only base_branch... -- | grep -E '\.(js|jsx|ts|tsx)$' | xargs)
and use base_branch
without dots for ESLINT_PLUGIN_DIFF_COMMIT
. One caveat is that it will consider changed lines from both ahead and behind commits, but only in matched files, which is a viable workaround for me.
This plugin has performance issues when a large amount of files is thrown into ESLint pipeline to begin with, because of all the calls to git
in pre-processor.
Since I updated to version 2.0.1 I get the error shown below where the git diff command doesn't recognise one of the options.
After some testing it seems the problem is running the
staged
option alongside theESLINT_PLUGIN_DIFF_COMMIT
user defined option that can be seen above asorigin/master..
.Since I'm running the config "diff:diff" the "staged" option should not even be part of the git diff command. It seems to me that the problem lays on your side, but please correct me if I'm doing something wrong.