-
Notifications
You must be signed in to change notification settings - Fork 12k
npm run lint
exits in error
#967
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
Comments
Sure, that flag seems helpful. I'd like that PR. |
This uses the `--force` flag of tslint to always exit the command in success, even if violations are detected. It changes the current behaviour where the command exits in error. See https://github.com/palantir/tslint#usage Fixes angular#967
@filipesilva Done, check #974 ;) |
I don't agree with this. It should fail. If not, it defeats the purpose of linting. If your code doesn't lint it shouldn't build. Same with if the tests don't pass. There's a reason there is a linter in place. I would rather have no linter run then a linter that is successful when it shouldn't be. It takes less time and adds the same amount of value. If I was setting up a CI server, I would have to remember "npm run lint" doesn't work probably and run tslint directly, create a new run script, or parse the output. Otherwise the build would just pass and that would be terrible. |
@caseyhoward you have a very valid point.. for some reason, I thought that the @cexbrayat I'm going to close your PR then, but I'll leave you with an alternative: |
OK no problem, thanks for considering it. I just want to point out that the error is frightening to beginners, so I was thinking a more beginner-friendly setting by default would help the people that will rely on angular-cli to get started. I've trained dozens of people these past weeks (with angular-cli), and they systematically call for help when they try the linter (who would blame them with this error?). I'm less worried about the people who want their build to break on linting: they are the kind the people who can tweak the command to do that. Whereas beginners will just stop using it (again that's what I see every week), and that's sad because they are the people who will benefit the most of learning from the linter. |
I know they are beginners and the "npm ERR!"s are scary, but the error is still readable. It tells you what command caused the error and right above you see the lint errors. I think if they are ready to use the linter, then learning to read output is just as important. However, it would be nice if npm didn't spit out so much worthless information. You could have them pass the force flag when running the npm script:
Or you can just have them add the "--force" to their package.json after generating the project.
The thing that's annoying about this is that you don't know about it until you review the build output and see that there are linting errors but the build isn't failing. You have no idea what's wrong. It the build server configured wrong? Is there a bug in tslint or npm? Maybe it's a bug in angular-cli. Then after some googling you learn that the --force flag was added to the package.json when angular-cli generated the project. Pretty much everyone who has a build server will encounter this. They will end up wasting a lot of time and the noobies will end up not learning how to read output. Nobody wins. |
Yup, I think we agree. Maybe we can add an explicit flag to the |
Well there's actually another alternative, which is to have the |
I think that would be great! |
I'll work on that then. |
Tracking this in #867 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
It is a bit scary for new users to run
npm run lint
because it exits in error by default if you have a violation. They usually think something is wrong with their install, where as it is just because they missed a semicolon somewhere...Maybe we could have
npm run lint
exiting nicely by using the--force
flag oftslint
?I can submit a PR if you are OK with that.
The text was updated successfully, but these errors were encountered: