eclint icon indicating copy to clipboard operation
eclint copied to clipboard

`env eclint check $(git ls-files)` crashes with `ENAMETOOLONG`

Open ljharb opened this issue 6 years ago • 7 comments

It would be ideal if eclint check could take an option to handle gitignore itself, instead of requiring me to pass in a list of files - which in most projects is far too long for the shell to handle.

ljharb avatar May 08 '18 06:05 ljharb

I will start to deal with this problem, but it may take a long time, you can use the following two options for a while:

  • eclint check without any other arguments
  • eclint check $(git diff --cached --name-only) run in git commit hook

gucong3000 avatar May 11 '18 01:05 gucong3000

@gucong3000 I ran into an edge case with both git diff --cached --name-only and git ls-files when trying to mimic a "respect gitignore" feature. If a file is removed from the project that was previously tracked by git it will be included in the output of both commands thus creating the error below. Could you provide a flag for eclint check that would set allowEmpty to true?

Thanks.

> eclint check $(git diff --name-only)

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: File not found with singular glob: /Project/foo.txt (if this was purposeful, use `allowEmpty` option)
    at Glob.<anonymous> (/Project/node_modules/glob-stream/readable.js:84:17)
    at Object.onceWrapper (events.js:286:20)
    at Glob.emit (events.js:198:13)
    at Glob._finish (/Project/node_modules/glob/glob.js:197:8)
    at done (/Project/node_modules/glob/glob.js:182:14)
    at Glob._processSimple2 (/Project/node_modules/glob/glob.js:688:12)
    at /Project/node_modules/glob/glob.js:676:10
    at Glob._stat2 (/Project/node_modules/glob/glob.js:772:12)
    at lstatcb_ (/Project/node_modules/glob/glob.js:764:12)
    at RES (/Project/node_modules/inflight/inflight.js:31:16)
Emitted 'error' event at:
    at Pumpify.emit (events.js:198:13)
    at Pumpify.Duplexify._destroy (/Project/node_modules/duplexify/index.js:191:15)
    at /Project/node_modules/duplexify/index.js:182:10
    at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] eclint: `eclint check $(git diff --name-only)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] eclint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/marshall/.npm/_logs/2019-06-13T18_04_57_173Z-debug.log

> [email protected] markdownlint /Project

marshallford avatar Jun 13 '19 18:06 marshallford

On *nix couldn't you use xargs to solve this?

zbeekman avatar Jul 01 '19 20:07 zbeekman

@zbeekman Hmm not sure what you mean. I did think about this a bit more and came up with this hacky solution:

eclint check $(git ls-files --deleted > deleted && git ls-files | comm -3 deleted -); rm deleted

marshallford avatar Jul 02 '19 17:07 marshallford

@marshallford Perhaps something like

git diff --name-only | xargs eclint check

xuhdev avatar Jul 03 '19 03:07 xuhdev

@xuhdev I am trying to lint all files that git is tracking, not just the files changed since the last commit.

In addition both git diff --name-only | xargs eclint check and eclint check $(git diff --name-only) result in the same error as above. Removed files are in fact "differences".

marshallford avatar Jul 03 '19 19:07 marshallford

@marshallford: Yes, my comment was in reference to OP's issue, not your additional issue. OP was saying that git ls-files crashes with ENAMETOOLONG. Your case where you have a deleted file is a separate issue, of sorts, although not necessarily an issue with eclint since you're passing it a file which no longer exists.

zbeekman avatar Jul 08 '19 16:07 zbeekman