10
11

More than 5 years have passed since last update.

prettier環境に合ったeslint configを作る

Posted at

prettierとの組み合わせを考慮する

現時点で、prettierを使わない理由がないので、スタイルに関するlintは全てprettierに寄せるのが基本方針です。

また、prettier-eslintを使う理由もないでしょう。
以下は、prettier-eslintの作者のツイートですが、もう使っていないとのことです。

prettierのスタイルと重複しないようにするには、eslint-config-prettierに付属しているeslint-config-prettier-checkを使うとチェックできます。

prettier/eslint-config-prettier: Turns off all rules that are unnecessary or might conflict with prettier.

上記のreadmeのようにpackage.jsonに以下のように設定すると便利です。

 "eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check",

eslint-find-rulesで全てのlintのルールを網羅する

eslintは開発が活発でどんどん新しいルールが追加されています。
それは大変素晴らしいことですが、それ故に自分の知らないルールがいつの間にか追加されている可能性も高いです。
この場合、eslint-find-rulesを使うと、設定してないルールが列挙されるので、便利です。

sarbbottam/eslint-find-rules: Find built-in ESLint rules you don't have in your custom config

参考レポ

自分のconfigは以下のようになっています。
他のconfigをextendsせずに、全てのeslintの設定を全て確認して書いてます。
この辺は、airbnbやstandard、xo、googleなどのconfigを継承して使ったほうが手軽で十分だと思います。

akameco/eslint-config-precure

状況に応じてFlowやJest、Reactのconfigを切り替え可能にしています。
デフォルトでは、一般的なconfigとimportに関する設定のみで、precure/ossとすればjestflowの設定が入ってきます。

{
    "extends": "precure"
}
{
    "extends": ["precure/oss"]
}
10
11
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
10
11