-
Notifications
You must be signed in to change notification settings - Fork 12k
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
ng lint succeeds when tslint fails, and other default linting misconfiguration (vscode) #16231
Comments
The workspace shown above has two projects:
The standalone E2E project is an artifact from an earlier version of the CLI and a project generated by 8.3.19 will not have a standalone E2E project. The E2E testing has been incorporated into the main project. |
With regards to your point that lint errors should fail IMO, Lint should be used as a precommit step or/and as a CI check which if that fails will make the PR unmergable. |
I kindly disagree. tslint has severities warning and error. If desired, a developer or automated tooling could set the linting severities to warning instead of error during development. But at least ng lint should fail when there are errors. Otherwise ng lint is not useful as an automateable cli tool, there would be no place in having it integrated into ng in the firat place. Linting errors should be strictly distinguished from linting warnings |
In an effort to make the most out of tooling and automated best practice enforcement, many good developers treat all warnings as error and only very carefully ignore them |
It does, ng lint will exit with a non zero error code when there is a lint error.
When there are no errors, ng lint is not exited with a non zero error code but will when there is a lint error. |
As mentioned above, the lint command will run against each project within the workspace and provide a separate output for each project. In the output provided in the screenshot, the |
Closing as per above, as it doesn't seem to be a bug here. |
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. |
@Masterxilo I just wanted to follow up on your original issue description and point out that it reflects a lot of frustration and is borderline aggressive. This might not have been your intention, but I wanted to let you know that that's how it was received. In the future please try to stay away from using profanity, verbal attacks, or negative comments directed at individuals or groups of people. The issue tracker is a place for collection of factual information. Your messages are read by many people, some of which might feel negatively affected by your choice of words, and in return might be less willing to help you with your issue. Lastly, please keep in mind that just as many of our other communication channels, the GitHub issue tracker is governed by our code of conduct policy: https://github.com/angular/code-of-conduct Thanks for understanding! |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
No, this never worked AFAIK.
Description
tslint and ng lint should behave the same.
In general, ng build and ng serve should fail when code that tslint shall consider as {"severity": "error"} is encountered.
I lost 3 hours first isolating a bug caused by a shadowed variable, then trying to make my build always fail and my IDE report "no-shadowed-variable" as an error.
After I put the line
in the ./tsconfig.json file, all my tools should recognize and report this error always.
Currently they don't. ng lint is one of them
🔬 Minimal Reproduction
Then append to app.component.ts the following
This code demonstrates shadowing. Does it do what we want? We should probably have used a different variable name.
Let's assume we had a bug caused by shadowing.
Now we want to make sure that never happens again, so we want the build to fail if we ever rely on shadowing anywhere.
So we put in tslint.json under rules:
But damn it:
Our IDE still shows it as a warning:
aha, the vscode team messed up: microsoft/vscode-typescript-tslint-plugin#122
so we configure in settings json "tslint.alwaysShowRuleFailuresAsWarnings": false
F*** now everything is an error:
Aha, the angular team messed up: The didn't put any "defaultSeverity" in ./tslint.json so let's do that:
After restarting the IDE (because we live in the fantastic time where some changes have immediate effect and some require a restart and no one know which require a restart...) it behaves properly
Now lets see the CLI:
properly reports only the ERRORs
detects the error, but happily reports that "All files pass linting.". Clearly a BUG.
ng serve succeeds - arguably it should treat linting errors just as much as errors as typechecking errors!
ng build succeeds - yay, "errors" in tslint.json officially means nothing to angular :(
🔥 Exception or Error
When there is a linting ERROR.
🌍 Your Environment
Anything else relevant?
Related Issues:
The text was updated successfully, but these errors were encountered: