airbnb / airbnb/javascript

`if` statements – one line vs. one expression

オープン
#445 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
needs eslint rule change/addition question
主要言語
JavaScript
スター
148k
フォーク
26.6k
PR マージ指標
30日以内にマージされた PR はありません

説明

Until I started using ESLint with your configuration I saw nothing against the rules in this:

``` js
$ cat if.js
const [one, two] = [1, 2];

if (one !== two) throw new Error(
'One does not equal two'
);
```

But ESLint does:

``` sh
$ eslint if.js

if.js
3:0 error Expected { after 'if' condition curly

✖ 1 problem (1 error, 0 warnings)
```

Is this intended? In my opinion the pattern I’ve been using is explicit – and more readable than this:

``` js
if (one !== two) {
throw new Error(
'One does not equal two'
);
}
```

The parens form a visual brace-like block much like in #438.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

このレポートでは、ESLint の `curly` ルールとプロジェクトの設定を特定し、波括弧付きの形式との比較および #438 への参照を行います。まず `curly` がどのように設定されているか、またスタイルガイドが 1 行の `if` 文をどのように扱っているかを確認してください。現在のルールが意図されたものかどうかを判断し、それに応じてその指針を文書化または変更すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
eslint, javascript
領域
documentation, tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。