0
0

More than 3 years have passed since last update.

VuePress で eslint を使いたい。

Posted at

問題

.vuepress という隠しディレクトリ配下に Single File Component を書き込むことになります。しかし eslint を実行しても何もエラーが表示されません。

$ eslint project/docs/.vuepress/components/Sample.vue
/Users/user/project/docs/.vuepress/components/Sample.vue
  0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override
    注意 ファイルは無視されました何故なら無視するパターンと一致したからです...

✖ 1 problem (0 errors, 1 warning)

$ 

これは eslint は、デフォルトで隠しディレクトリ配下を無視する設定になっています。そのため、コマンドを実行した場合は、無視しましたよ warning だけ表示されます。加えて連携させたいエディタ vim では何も表示されません。

解決策

これを避けるために .eslintignore を設定する必要があります。! は ignore の反対、無視するなよ、という意味らしいです。

!docs/.vuepress/

これで無事に動くはずです。

$ eslint project/docs/.vuepress/components/Sample.vue
/Users/user/project/docs/.vuepress/components/Sample.vue

  112:9   error  'foo' is assigned a value but never used  no-unused-vars
  123:20  error  'var' is not defined                      no-undef

✖ 2 problems (2 errors, 0 warnings)

$
0
0
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
0
0