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

No output from linter #122

Closed
vasyas opened this issue Jan 16, 2017 · 14 comments
Closed

No output from linter #122

vasyas opened this issue Jan 16, 2017 · 14 comments

Comments

@vasyas
Copy link

vasyas commented Jan 16, 2017

I've configured lint-staged with tslint.
tslint is run via npm-run-script:

"scripts": {
      "tslint": "tslint -c tslint.json"
}

"lint-staged": {
    "*.tsx": "tslint",
    "gitDir": "../"
}

When I run tslint directly via Npm, I get linting messages:

~/workspace/ibanking/ui> npm run --silent tslint -- src/common/ModalDialog.tsx
src/common/ModalDialog.tsx[23, 27]: missing whitespace

But when I run it using lint-staged, I get no messages, just the indication of failed process

~/workspace/ibanking/ui> lint-staged
 ❯ Running tasks for *.tsx
   ✖ tslint

🚫 tslint found some errors. Please fix them and try committing again.

Using lint-staged@3.2.6, execa 0.6.0 on MacOS.

@okonet
Copy link
Collaborator

okonet commented Jan 16, 2017

Weird. I output both stdout and stderr in case of an error.

@vasyas
Copy link
Author

vasyas commented Jan 16, 2017

Yes, looks like bug comes from execa.

Btw, it works ok if I use local scripts and fails only for npm run scripts.

@okonet
Copy link
Collaborator

okonet commented Jan 16, 2017

Hmm, can it be --silent flag that I'm using when running npm scripts?

https://github.com/okonet/lint-staged/blob/master/src/findBin.js#L16

@grofzero
Copy link

I think the problem might be, that execa's cwd is set to the .git directory and not the dir, where package.json is located, but the collected filepaths start from there.

@okonet
Copy link
Collaborator

okonet commented Jan 18, 2017

Can you try the latest version since it should fix this behavior I think let me know.

@grofzero
Copy link

It's working great! Thank you very much!

@okonet
Copy link
Collaborator

okonet commented Jan 18, 2017

👍

@okonet okonet closed this as completed Jan 18, 2017
@km-tr
Copy link

km-tr commented Jan 27, 2017

I also get the same error in lint-staged 3.2.8.

@okonet
Copy link
Collaborator

okonet commented Jan 27, 2017

@km-tr are you certain? Can you create a repo where I can reproduce this issue?

@km-tr
Copy link

km-tr commented Jan 27, 2017

It seems that it takes time to reproduce the situation, so I have not finished yet, but I understood the problem part.

If I turn off --silent in findBin.js I got an error like the following.

🚫 lint:js found some errors. Please fix them and try committing again.

npm ERR! Darwin 16.1.0
npm ERR! argv "/Users/kmtr/.anyenv/envs/ndenv/versions/v6.9.1/bin/node" "/Users/kmtr/.anyenv/envs/ndenv/versions/v6.9.1/bin/npm" "run" "lint:js" "--" "/Users/kmtr/dev/assets/javascripts/app/components/App.jsx"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path /Users/kmtr/dev/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/Users/kmtr/dev/package.json'

npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

gitDir /Users/kmtr/dev
package.jsonDir /Users/kmtr/dev/assets

config.gitDir ../

An error has occurred because it is running in a directory that does not have package.json

@km-tr
Copy link

km-tr commented Jan 30, 2017

When running execa with runSctipt.js, if res is npm run-script, you did not specify cwd with execaOptions and it worked correctly

@okonet
Copy link
Collaborator

okonet commented Jan 30, 2017

I'm still not sure what's the bug exactly. Can anyone create an example with exact steps to r it?

@km-tr
Copy link

km-tr commented Jan 30, 2017

I have created a repository for testing

https://github.com/km-tr/lint-staged-findbin

If you add js to each stage and run npm run lint-staged you think that you get different results

@okonet

okonet added a commit that referenced this issue Jan 30, 2017
…nstead of git directory.

When running `npm run ...` scripts it should run in a (sub-) directory where
package.json is located. If `.git` directory and `package.json` dirs doesn't match
it will fail. This commit fixes it.

Closes #122
okonet added a commit that referenced this issue Jan 30, 2017
…nstead of git directory.

When running `npm run ...` scripts it should run in a (sub-) directory where
package.json is located. If `.git` directory and `package.json` dirs doesn't match
it will fail. This commit fixes it.

Closes #122
@km-tr
Copy link

km-tr commented Jan 31, 2017

I was able to confirm that it works correctly at 3.3.0. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants