refactor: replace .bind(this, intent) with arrow fn in Settings#56
Merged
Conversation
Settings is a function component; props.onSubmit.bind(this, intent)
binds `this` to undefined (function components have no `this` in
strict mode). At runtime it works because the parent's onSubmit is
itself bound to the parent class instance, so the inner bind's
this=undefined is silently ignored. But oxlint flags every `this`
in an exported function (no-this-in-exported-function), and the
intent of the code is clearer as a partial-application closure.
4 sites in components/Settings.js:
props.onSubmit.bind(this, 'sso') → (e) => props.onSubmit('sso', e)
... and the same for dsync, audit_logs, domain_verification.
No runtime behaviour change. Lint warnings drop from 7 to 3.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Clears the 4
no-this-in-exported-functionoxlint warnings incomponents/Settings.js.Settings is a function component;
props.onSubmit.bind(this, intent)bindsthistoundefined. At runtime it works because the parent'sonSubmitis itself bound to the parent class instance, so the inner bind'sthis=undefinedis silently ignored. The arrow function form is clearer about what's actually happening — partial application ofintent.No runtime behaviour change. Lint warnings drop from 7 to 3.