LoginSignup
5
1

More than 5 years have passed since last update.

ESLintの--fixはソースを破壊する!本当??

Last updated at Posted at 2017-01-20

そういうものなの?破壊的なものはやめてもらいたいんだけど......(背景を追記。&続きは、別記事......)

環境

  • ESLint Version:3.13.1
  • Node Version:7.4.0
  • npm Version:4.1.1
.eslintrc.js(まだいじりかけ)
module.exports = {
  extends: 'airbnb',
  rules: {
    'no-unused-vars': ['error', { vars: "all", args: 'none' }],
  }
}

サンプル

fix前
function foo(key) {
  var value = map[key];
  if(!value){
    return;
  }
  // do something....
}
fix後
function foo(key) {
  var value = map[key];
  if(!value){
  }
  // do something....つねにここに通っちゃうのですか???
}

背景

  • Atomで、linter-eslintを使っている。
  • linter-eslintでは、保存時のautofixを使っている。(インデントがグダっていても平気!スイスイかける!!)
  • コード書いたらガンガン保存。
  • コードの記述は「条件チェックでreturn;残りは後で!」って感じで、わかることを書いてあっちこっちに行くスタイル。

結論

Atomで保存するときに自動でESLintに直させるのは危険。
誰だ?そんな危険な状態にしたのは??ってか、そういうものなんでしょうか???

5
1
4

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
5
1