paleite / eslint-plugin-diff

Run ESLint on your changes only
https://npm.im/eslint-plugin-diff
MIT License
181 stars 14 forks source link

Move getDiffFileList inside the processor #37

Closed quaardvark closed 1 year ago

quaardvark commented 1 year ago

Duplicating context from #31

By default, diff/diff pulls 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.

To work around the above issue 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.

This PR moves diffFileList call inside the processor, so it won't get invoked during plugin load, which should resolve the issue w/o changing anything else.

quaardvark commented 1 year ago

This is not a good solution, since pre-processor is called for each matched file and git command can execute unmanageable number of time