Skip to content

Commit

Permalink
ComposeBox [nfc]: Use optional chaining instead of if block.
Browse files Browse the repository at this point in the history
Prompted by discussion on zulip#4101 [1].

Flow started supporting method calls in optional chains in
v0.112.0 [2], but ESLint isn't yet on board [3]; it gives a false
positive for `no-unused-expressions`.

A comment on the ESLint issue [4] suggests we could be more
systematic by using an ESLint plugin from Babel, instead of one-off
suppressions of `no-unused-expressions` like this one. That plugin
moved from (on NPM) `babel-eslint-plugin` to `@babel/eslint-plugin`.
We can't use the new one until we're on ESLint 7 (see zulip#4254), but we
could probably use the old one.

[1] zulip#4101 (comment)
[2] facebook/flow#4303
[3] eslint/eslint#11045
[4] eslint/eslint#11045 (comment)
  • Loading branch information
chrisbobbe committed Sep 18, 2020
1 parent b3f4c30 commit a169908
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ class ComposeBox extends PureComponent<Props, State> {
this.setMessageInputValue(completedText);

if (lastWordPrefix === '@') {
if (this.mentionWarnings.current) {
this.mentionWarnings.current.getWrappedInstance().handleMentionSubscribedCheck(completion);
}
// https://github.com/eslint/eslint/issues/11045
// eslint-disable-next-line no-unused-expressions
this.mentionWarnings.current?.getWrappedInstance().handleMentionSubscribedCheck(completion);
}
};

Expand Down

0 comments on commit a169908

Please sign in to comment.