3
1

More than 5 years have passed since last update.

ESLint v3.18.0

Last updated at Posted at 2017-03-18

v3.17.0 | 次 v3.19.0

ESLint 3.18.0 がリリースされました。
いくつかの機能追加・バグ修正が行われています。

質問やバグ報告等ありましたら、お気軽にこちらまでお寄せください。


✨ 本体の変更

#5407: AST Selectors

プラグイン・カスタム ルール開発者向けです。

各ルールは AST の種類毎にイベントハンドラを書くことで実装されていますが、そのイベント名に AST Selectors を利用できるようになりました。
例えば、let定義を調べたい場合のコードは次のように簡潔になります。

例.(before)
exports.create = (context) => ({
    VariableDeclaration(node) {
        if (node.kind === "let") {
            // 調べる
        }
    }
})
例.(after)
exports.create = (context) => ({
    "VariableDeclaration[kind=let]"(node) {
        // 調べる
    }
})

これに伴い、no-restricted-syntax ルールのオプションとしても AST Selectors が利用できるようになりました。

例.(xdescribe関数呼び出しを禁止する)
{
    "rules": {
        "no-restricted-syntax": [
            "error",
            "CallExpression[callee.name='xdescribe']"
        ]
    }
}

💡 新しいルール

今回はありません。

🔧 オプションが追加されたルール

#7632: no-unused-expressions (allowTaggedTemplates)

タグ付きテンプレートを副作用を持つ式として扱うオプションが追加されました。

/*eslint no-unused-expressions: [error, {allowTaggedTemplates: true}] */

//✘ BAD
`hello, ${world}!`

//✔ GOOD
tag`hello, ${world}!`

✒️ eslint --fix をサポートしたルール

今回はありません。


3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1