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

Add 'severityOverride' option #725

Merged
merged 4 commits into from
Mar 13, 2023
Merged

Conversation

elsassph
Copy link
Contributor

@elsassph elsassph commented Oct 21, 2022

bsconfig.json now accepts a severityOverride map allowing to adjust a diagnostic severity.

Fixes #724 - see issue for details

@elsassph elsassph force-pushed the feature/724-override-severity branch from bff3f30 to 790e337 Compare October 21, 2022 10:17
@elliot-nelson
Copy link
Contributor

Really interesting. Like tsc, bsc doesn't have an "eslint-esque" rules engine where there's a very clear way to turn on and off errors and give them different severity levels.

Instead, TS "rules" are governed by human-readable options that are kind of disjointed from the error message you get... i.e., when your build pops out TS7006: foobar has implicit type 'any', that doesn't inform you that you could disable that by setting compilerOptions.noImplicitAny: false.

So, I like your approach, although I see two issues:

  • If you change errors to non-errors, might you accidentally cause your build to succeed (exit code 0) even though your formatted output might be incorrect / non-runnable? Or are there still errors that are so bad the whole compiler just chokes up. (Maybe there's a "fatal" level that never reaches the diagnostic stage.)
  • The name severityOverrides seems very specific and almost a dirty hack, whereas I think this use case probably has a number of legit purposes. Would a structure more like compilerOptions: { diagnostics: { 1004: "error" } } seem less dirty?

@elsassph
Copy link
Contributor Author

elsassph commented Oct 22, 2022

Yes @elliot-nelson, the whole point of this setting is to be a workaround - it should feel nasty!

Unlike eslint, plugins contributing to diagnostics can be heterogeneous so yes, this property is meant to be seen as a "workaround", which is useful when transitioning a project to bsc/bslint (as our colleagues are doing) where a lot of errors can be non-fatal in the current state of the codebase but need time to clean up.

src/BsConfig.ts Outdated
/**
* A map of error codes with their severity level override (error|warn|info)
*/
severityOverride?: Record<number | string, 'error' | 'warn' | 'info' | 'hint'>;
Copy link
Member

Choose a reason for hiding this comment

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

Let's call this diagnosticSeverityOverrides instead? Keeps it more in line with diagnosticFilters

@TwitchBronBron TwitchBronBron merged commit 47aa7eb into master Mar 13, 2023
@TwitchBronBron TwitchBronBron deleted the feature/724-override-severity branch March 13, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow overriding errors severity
4 participants