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

Classify lintish diagnostics as warnings, add treatWarningsAsErrors #19126

Closed
wants to merge 7 commits into from

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Oct 12, 2017

Fixes #13408

We already had the infrastructure to do this in pretty much the entire stack (heck, pretty output even has configured yellow text for warnings, even though in no circumstances would we have seen them before). All that was missing was the ability to toggle warnings as errors and the initial listing of the diagnostics as warnings.

@mhegazy As a feature, I assume this is too late for 2.6?

void x; // implicit fallthrough
case "b":
~~~
!!! error TS2678: Type '"b"' is not comparable to type '"a"'.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly related to the test, but when I went to remove it, I considered that it is useful in verifying that we're not reporting all errors as warnings.

function shouldTreatWarningsAsErrors() {
const setValue = program.getCompilerOptions().treatWarningsAsErrors;
if (typeof setValue === "undefined") {
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that it defaults to the safer setting (true); but how do you disable it via command-line arguments? --no-treatWarningsAsErrors?

Copy link
Member Author

@weswigham weswigham Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--treatWarningsAsErrors false, same as our other boolean flags.

@weswigham
Copy link
Member Author

weswigham commented Oct 12, 2017

I think I've gotten all the places where the warning v. error distinction matters changed. Also:
image
Note the green underline instead of red. Already works in vscode, too. We really did plumb this through almost everywhere already.

@RyanCavanaugh
Copy link
Member

What's the rule for whether something is a warning or not?

@weswigham
Copy link
Member Author

Based on the disccussion in #18894, a new flag --treatWraningsAsErrorrs will be added, defaults to true. The servirty of the style checks done by the compiler will all be set to Warrning. here is the list of configurations to control these messages :
--noUnusedLocals
--noUnusedParameters
--noImplicitReturns
--noFallthroughCasesInSwitch
--allowUnusedLabels
--allowUnreachableCode

For future errors... Based on this pattern, non-semantic errors which aren't runtime errors but are code smells.

@alexeagle
Copy link
Contributor

alexeagle commented Oct 13, 2017

I didn't check, but does the tsc output order the errors last? That is very important when a build has a wall of warnings, so I don't have to scroll around my terminal buffer or CI log.

Also, I think it's desirable that the treatWarningsAsErrors applies to the exit code and on the command line, but not in the editor.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

Also, I think it's desirable that the treatWarningsAsErrors applies to the exit code and on the command line, but not in the editor.

I am not sure i understand this statement. can you elaborate?

@weswigham
Copy link
Member Author

weswigham commented Oct 16, 2017

Also, I think it's desirable that the treatWarningsAsErrors applies to the exit code and on the command line, but not in the editor.

Wait, do you mean always still red underlines in the editor, but still allow the exit code to be 0? Or the opposite?

@weswigham
Copy link
Member Author

weswigham commented Oct 16, 2017

I didn't check, but does the tsc output order the errors last? That is very important when a build has a wall of warnings, so I don't have to scroll around my terminal buffer or CI log.

No, right now warnings are mixed with errors, sorted by file position. Is it always desirable to split them up?

Actually rustc only outputs warnings when there are no errors - is that more desirable? (Then again, #deny in rust also only changes the exit code - warnings are still only reported once all errors are resolved... And in rust a program with errors is never compiled, with TS, even with errors you get output...)

@timc13
Copy link

timc13 commented Jan 26, 2018

any movement here?

@alexeagle
Copy link
Contributor

@timc13 see the design notes linked above:

Conclusion: hold off on dealing with warnings, understand how to improve TSLint, think about how to champion community tooling better by default for projects.

@RyanCavanaugh
Copy link
Member

@weswigham can we close for now?

@weswigham
Copy link
Member Author

We're not actively considering it right now, and I imagine the next time we decide to talk about this we'll waffle just as much, so sure. 😛

The real question is will you close the original issue: #13408

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants