From 682a6b78d3258b0b713d797401a265718274a699 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Thu, 10 Sep 2020 12:16:38 -0700 Subject: [PATCH] ComposeBox [nfc]: Use optional chaining instead of `if` block. Prompted by discussion on #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 #4254), but we could probably use the old one. [1] https://github.com/zulip/zulip-mobile/pull/4101#discussion_r463396478 [2] https://github.com/facebook/flow/issues/4303 [3] https://github.com/eslint/eslint/issues/11045 [4] https://github.com/eslint/eslint/issues/11045#issuecomment-436685184 --- src/compose/ComposeBox.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compose/ComposeBox.js b/src/compose/ComposeBox.js index 63321aa8b05..4c3bf23c307 100644 --- a/src/compose/ComposeBox.js +++ b/src/compose/ComposeBox.js @@ -250,9 +250,9 @@ class ComposeBox extends PureComponent { 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); } };