LoginSignup
7

More than 3 years have passed since last update.

ESLint v6.4.0

Last updated at Posted at 2019-09-14

v6.3.0 | 次 v6.5.0

ESLint 6.4.0 がリリースされました。
小さな機能追加とバグ修正が行われています。

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

🏢 日本語 Issue 管理リポジトリ
👫 日本語サポート チャット
🏢 本家リポジトリ
👫 本家サポート チャット

🚀 本体への機能追加

特になし。

💡 新しいルール

default-param-last

🔖 #12188

仮引数の最初や途中にだけデフォルト パラメーター構文を使うことを禁止するルールです。

/*eslint default-param-last: error */

//✘ BAD
function f1(a = 0, b, options) { /* ... */ }
function f2(a, b = 0, options) { /* ... */ }

//✔ GOOD
function f3(a, b, options = {}) { /* ... */ }
function f4(a, b = 0, options = {}) { /* ... */ }

Online Demo

no-import-assign

🔖 #12252

ES Modules の import 構文で作成した変数について、変更を禁止するルールです。これらは読み取り専用なので、変更しようとすると実行時エラーになります。

/*eslint no-import-assign: error */

import mod, { named } from "./mod.mjs"
import * as mod_ns from "./mod.mjs"

//✘ BAD
mod = 1
named = 2
mod_ns.named = 3
mod_ns = {}

//✔ GOOD
mod.prop = 1
named.prop = 2
mod_ns.named.prop = 3

Online Demo

prefer-regex-literals

🔖 #12254

静的に内容が決定する new RegExp(...) 式について、正規表現リテラルを使用するように矯正するルールです。

/*eslint prefer-regex-literals: error */

//✘ BAD
const r1 = new RegExp("\\d\\d\\.\\d\\d\\.\\d\\d\\d\\d");
const r2 = RegExp(`^\\d\\.$`);
const r3 = new RegExp(String.raw`^\d\.$`);

//✔ GOOD
const r4 = /\d\d\.\d\d\.\d\d\d\d/;
const r5 = /^\d\.$/;
const r6 = new RegExp(pattern);
const r7 = RegExp("abc", flags);
const r8 = new RegExp(prefix + "abc");
const r9 = RegExp(`${prefix}abc`);
const r0 = new RegExp(String.raw`^\d\. ${sufix}`);

Online Demo

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

accessor-pairs enforceForClassMembers

🔖 #12192

不揃いな Getters/Setters ペアを禁止するルールに、クラス構文をサポートするオプションが追加されました。

/*eslint accessor-pairs: [error, { enforceForClassMembers: true }] */

//✘ BAD
class C {
    set prop(value) { /* ... */ }
}

Online demo

computed-property-spacing enforceForClassMembers

🔖 #12214

Computed プロパティのスペースを矯正するルールに、クラス構文をサポートするオプションが追加されました。

/*eslint computed-property-spacing: [error, never, { enforceForClassMembers: true }] */

const funcKey = Symbol()

//✔ GOOD
class C {
    [ funcKey ]() { /* ... */ }
}

Online demo

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

特になし。

⚠️ 非推奨になったルール

特になし。

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
7