LoginSignup
7
5

More than 5 years have passed since last update.

@flow の有無を eslint でチェックする

Last updated at Posted at 2017-05-12

プロジェクトで全面的に flowtype を導入している場合、eslint-plugin-flowtype の eslint plugin も使ってる場合がほとんどだと思うのだけど、標準だと @flow の有無をチェックしてくれない

ルールで有効化する

の通り、強制するルールがあるので有効化する。

{
  "rules": {
    "flowtype/require-valid-file-annotation": [
      2,
      "always"
    ]
  }
}

これで @flow がない js ファイルはエラーになるし、明示的に flow でチェックしたくないファイルの場合、 @noflow をつければ OK なので有効にしておきたい。

そしてこのルールを追加したところ、かなりのファイル(ほぼ書き忘れてるのは私…) でうっかり @flow 書き忘れが発見された… :crying_cat_face:@flow 追加したらちゃんとバグも見つかったので、flow 大事だなぁ。

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