Skip to content

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

Closed
cexbrayat opened this issue May 31, 2016 · 12 comments
Closed

npm run lint exits in error #967

cexbrayat opened this issue May 31, 2016 · 12 comments
Assignees
Labels
effort1: easy (hours) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@cexbrayat
Copy link
Member

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 of tslint?
I can submit a PR if you are OK with that.

@filipesilva
Copy link
Contributor

Sure, that flag seems helpful. I'd like that PR.

cexbrayat added a commit to cexbrayat/angular-cli that referenced this issue Jun 1, 2016
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
@cexbrayat
Copy link
Member Author

@filipesilva Done, check #974 ;)

@caseyhoward
Copy link

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.

@filipesilva
Copy link
Contributor

@caseyhoward you have a very valid point.. for some reason, I thought that the --force option wouldn't change the exit code but rather only remove the NPM ERR messages, which was silly of me.

@cexbrayat I'm going to close your PR then, but I'll leave you with an alternative: ng lint basically runs npm run lint, so you can easily add the --force flag there.

@cexbrayat
Copy link
Member Author

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.

@caseyhoward
Copy link

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 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:

npm run-script lint --force

Or you can just have them add the "--force" to their package.json after generating the project.

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.

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.

@cexbrayat
Copy link
Member Author

Yup, I think we agree.

Maybe we can add an explicit flag to the ng lint command in the help/documentation ? That would be a first step to help beginners and keep the current behavior.

@filipesilva
Copy link
Contributor

Well there's actually another alternative, which is to have the ng lint strip out the NPM ERR lines. I toyed with this idea for a while for ng lint and ng e2e, what do you think?

@cexbrayat
Copy link
Member Author

I think that would be great!

@filipesilva filipesilva self-assigned this Jun 3, 2016
@filipesilva filipesilva reopened this Jun 3, 2016
@filipesilva
Copy link
Contributor

I'll work on that then.

@filipesilva filipesilva added effort1: easy (hours) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Jun 4, 2016
@filipesilva
Copy link
Contributor

Tracking this in #867

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants