-
Notifications
You must be signed in to change notification settings - Fork 49.8k
[compiler] Derive ErrorSeverity from ErrorCategory #34401
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
Conversation
josephsavona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for working on this! See comments before landing though, about isError() and similar functions
| let res = false; | ||
| for (const detail of this.details) { | ||
| if (detail.severity === ErrorSeverity.Off) { | ||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just ignore details that are off? maybe instead of returning a boolean, we could have CompilerError.proto.errors(): Array<CompilerDetail> | null and that filters out any details that are off, and returns null if empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good call. Originally I was thinking, if there's any details that were not meant to be displayed we should just not display the whole thing. But probably better to just filter that out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #34409
| /** | ||
| * Returns true if there are no Errors and there is at least one Warning. | ||
| */ | ||
| isWarning(): boolean { | ||
| let res = false; | ||
| for (const detail of this.details) { | ||
| if (detail.severity === ErrorSeverity.Off) { | ||
| return false; | ||
| } | ||
| if (detail.severity === ErrorSeverity.Error) { | ||
| return false; | ||
| } | ||
| if (detail.severity === ErrorSeverity.Warning) { | ||
| res = true; | ||
| } | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| isHint(): boolean { | ||
| let res = false; | ||
| for (const detail of this.details) { | ||
| if (detail.severity === ErrorSeverity.Off) { | ||
| return false; | ||
| } | ||
| if (detail.severity === ErrorSeverity.Error) { | ||
| return false; | ||
| } | ||
| if (detail.severity === ErrorSeverity.Warning) { | ||
| return false; | ||
| } | ||
| if (detail.severity === ErrorSeverity.Hint) { | ||
| res = true; | ||
| } | ||
| } | ||
| return res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here, there isn't a clear semantic meaning for these isFoo() given there are multiple details. feels like it should be more hasFoo()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #34409
| case ErrorSeverity.InvalidReact: | ||
| case ErrorSeverity.UnsupportedJS: { | ||
| severityCategory = 'Error'; | ||
| function printErrorSummary(category: ErrorCategory, message: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should make this a property of the ErrorCategory details object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address in a follow up
|
Comparing: c4e2508...3a1ff39 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
With #34176 we now have granular lint rules created for each compiler ErrorCategory. However, we had remnants of our old error severities still in use which makes reporting errors quite clunky. Previously you would need to specify both a category and severity which often ended up being the same. This PR moves severity definition into our rules which are generated from our categories. For now I decided to defer "upgrading" categories from a simple string to a sum type since we are only using severities to map errors to eslint severity.
Now that we have a new CompilerDiagnostic type (which the CompilerError aggregate can hold), the old CompilerErrorDetail type can be marked as deprecated. Eventually we should migrate everything to the new CompilerDiagnostic type. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34402). * #34409 * #34404 * #34403 * __->__ #34402 * #34401
With #34176 we now have granular lint rules created for each compiler ErrorCategory. However, we had remnants of our old error severities still in use which makes reporting errors quite clunky. Previously you would need to specify both a category and severity which often ended up being the same. This PR moves severity definition into our rules which are generated from our categories. For now I decided to defer "upgrading" categories from a simple string to a sum type since we are only using severities to map errors to eslint severity. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34401). * #34409 * #34404 * #34403 * #34402 * __->__ #34401 DiffTrain build for [60d9b97](60d9b97)
With #34176 we now have granular lint rules created for each compiler ErrorCategory. However, we had remnants of our old error severities still in use which makes reporting errors quite clunky. Previously you would need to specify both a category and severity which often ended up being the same. This PR moves severity definition into our rules which are generated from our categories. For now I decided to defer "upgrading" categories from a simple string to a sum type since we are only using severities to map errors to eslint severity. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34401). * #34409 * #34404 * #34403 * #34402 * __->__ #34401 DiffTrain build for [60d9b97](60d9b97)
The compiler playground was crashing at any small syntax errors in the `Input` panel due to updating the `CompilerErrorDetailOptions` type in #34401. Updated the option to take in a `ErrorCategory` instead. --------- Co-authored-by: lauren <poteto@users.noreply.github.com>
With #34176 we now have granular lint rules created for each compiler ErrorCategory. However, we had remnants of our old error severities still in use which makes reporting errors quite clunky. Previously you would need to specify both a category and severity which often ended up being the same.
This PR moves severity definition into our rules which are generated from our categories. For now I decided to defer "upgrading" categories from a simple string to a sum type since we are only using severities to map errors to eslint severity.
Stack created with Sapling. Best reviewed with ReviewStack.