なっく日報

技術やら生活やらのメモ

Node.js v4.0.0がリリースされたので、ESLintの設定を見なおしてみた

.eslintrc

.eslintrcに書く項目のうち、ES6関連を抜粋。

{
  "ecmaFeatures": {
    "arrowFunctions": true,
    "binaryLiterals": true,
    "blockBindings": true,
    "classes": true,
    "forOf": true,
    "generators": true,
    "objectLiteralComputedProperties": true,
    "objectLiteralDuplicateProperties": false,
    "objectLiteralShorthandMethods": true,
    "objectLiteralShorthandProperties": true,
    "octalLiterals": true,
    "templateStrings": true
  },
  "rules": {
    "arrow-parens": [2, "always"],
    "arrow-spacing": [2, { "before": true, "after": true }],
    "constructor-super": 2,
    "generator-star-spacing": [2, {"before": false, "after": false}],
    "no-class-assign": 2,
    "no-const-assign": 2,
    "no-dupe-class-members": 2,
    "no-this-before-super": 2,
    "no-var": 2,
    "prefer-arrow-callback": 2,
    "object-shorthand": [2, "methods"],
    "prefer-const": 2,
    "prefer-template": 2,
    "require-yield": 2
  }
}

ポイント

基本、好みになる気がしますが・・・

  • objectLiteralComputedPropertiesはバグっているので、しばらく使うべきではない(Computed props are not properly handled · Issue #2507 · nodejs/node · GitHubが解消されるまでは)
  • objectLiteralDuplicatePropertiesはオブジェクト内で同名のプロパティがあれば、後ろのものが上書きになるって機能なんだけど、不要な気がする。何で入れたんだろ?
  • prefer-*は基本入れるのが好み
  • no-varは入れておくべき