-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Update error transform to allow excluding errors inside subexpressions like ternaries #24693
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
Merged
+86
−1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
scripts/error-codes/__tests__/__snapshots__/transform-error-messages.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What if there are multiple nested expressions? Like nested ternaries. Maybe it should check all the nodes until it hits the statement parent.
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.
I like that idea but the lint functionality doesn't follow expression semantics, it seems to actually follow line semantics. If we did this, it would be possible for the linter to take exception to an error that the transformer would ignore. maybe that's ok? but extract errors wouldn't work to auto-fix any errors the linter had a problem with
without changing anything we have
if we walk up expressions we have
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.
perhaps the latter one is actually better? it would make the linter more aggressive than the transformer. Was the point of the transformer to be a more strict guard?
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.
Conceptually it's just another lint rule, except it runs on the build artifacts instead of the source files. It's an additional failsafe in case ESLint was misconfigured, like if you pull in a function from another module and the source files for that module weren't checked by ESLint.
Neither the FIXME comments nor the ESLint rule affect whether the messages get minified — they will cause CI to fail, but they won't change anything about the AST (aside from the additional comments).
The only thing that determines whether a message minified is its presence in
codes.json. So the purpose of both the transformer and the lint rule is to remind you to update that file.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.
I guess I was concerned that FIXME's in the build output were bad b/c they would leak. but practically speaking they are probably always bundled so the extra bytes are maybe getting stripped out anyway.
Either way, I agree it's nice to be able to put the opt-out in a more flexible location and updated the implementation to walk up to the statement parent. lmk what you think
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.
Well I don't mean to say it's fine if those land in the build. That's why the CI job fails if it detects any. The point is just that the author needs to make an intentional decision either way. So as long as either the check_error_codes job or the lint rule catches it, it's fine. It's just even better if the lint rule covers all cases because it provides the nicer dev experience, since you don't have to build first.
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 makes sense. the error_codes job in CI working is an invariant I suppose we should be able to to expect
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.
Yes