eslint: Fix unicorn/no-lonely-if.

https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v24.0.0/docs/rules/no-lonely-if.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-12-22 02:26:39 -08:00
committed by Tim Abbott
parent 6acbcec39d
commit 2f80415756
23 changed files with 223 additions and 247 deletions

View File

@@ -19,13 +19,15 @@ exports.smart_insert = function (textarea, syntax) {
const before_str = textarea.val().slice(0, pos);
const after_str = textarea.val().slice(pos);
if (pos > 0) {
if (
pos > 0 &&
// If there isn't space either at the end of the content
// before the insert or (unlikely) at the start of the syntax,
// add one.
if (!is_space(before_str.slice(-1)) && !is_space(syntax[0])) {
syntax = " " + syntax;
}
!is_space(before_str.slice(-1)) &&
!is_space(syntax[0])
) {
syntax = " " + syntax;
}
// If there isn't whitespace either at the end of the syntax or the