LoginSignup
0
0

More than 5 years have passed since last update.

Vue.jsのプロジェクトでeslintのバージョンをv3→v4に上げようとしてハマったこと

Last updated at Posted at 2018-11-26

起こったこと

他のチームから引き継いだVue.jsのプロジェクトで、node_modules内の各ライブラリのバージョンを上げる作業をしました。
(最新はv5ですが、他ライブラリとの依存の関係でv4までしか上げられず。)

とりあえずpackage.jsoneslintを"^4.0.0"に上げ、また他のeslint系の既存ライブラリたちも適宜バージョンを上げました。

package.json(devDependencies内、eslint関連のライブラリのみ抜粋)
    "eslint": "^4.0.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-html": "^5.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^8.0.0",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^3.1.0",

eslintコマンドを実行したところ以下のエラーが発生。

> 1 | <!-- COMMENTCOMMENTCOMMENTCOMMENTCOMMENT -->
    | ^
  2 | <template>
  src\components\foo\FooBar.vue:1:1
  <!-- COMMENTCOMMENTCOMMENTCOMMENTCOMMENT -->
   ^

✘ 1 problem (1 error, 0 warnings)

Errors:
  1  http://eslint.org/docs/rules/null
    at emitError (C:\Users\miyashiiii\MyProject\node_modules\webpack\lib\NormalModule.js:123:22)
    at printLinterOutput (C:\Users\miyashiiii\MyProject\node_modules\eslint-loader\index.js:128:9)
    at Object.module.exports (C:\Users\miyashiiii\MyProject\node_modules\eslint-loader\index.js:248:3)
 @ ./node_modules/extract-text-webpack-plugin/dist/loader.js??ref--6-0!./node_modules/vue-style-loader!./node_modules/css-loader??ref--6-2!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/vue-loader/lib??vue-loader-options!./src/components/login/StressLogin.vue?vue&type=style&index=0&id=c950f03c&scoped=true&lang=css&
 @ ./src/components/foo/FooBar.vue?vue&type=style&index=0&id=c950f03c&scoped=true&lang=css&
 @ ./src/components/foo/FooBar.vue
 @ ./node_modules/babel-loader/lib??ref--2!./node_modules/vue-loader/lib??vue-loader-options!./src/components/top/TopManager.vue?vue&type=script&lang=js&
 @ ./src/components/top/TopManager.vue?vue&type=script&lang=js&
 @ ./src/components/top/TopManager.vue
 @ ./node_modules/babel-loader/lib??ref--2!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
 @ ./src/App.vue?vue&type=script&lang=js&
 @ ./src/App.vue
 @ ./src/main.js

1行目でいきなり怒られているあたり、.vueファイルを.vueファイルとして扱ってくれていない……?
というかeslint系のライブラリにvueっぽいものが入ってないけど、いままでどうやってvueを扱っていたんだ?

対処

いろいろ調べているうちに行き着いたeslint-plugin-htmlのGithubにそれっぽいissueがありました。

スーパーざっくりまとめると、「eslint-plugin-htmlって、Vue.jsのプロジェクトだとeslint-plugin-vueと競合しない?v5からは.vueサポートするのやめない?」みたいな話っぽい。
(Vue.jsの知見も英語の知見もないので、間違っていたら教えてください。)

確認すると、今回eslint-plugin-htmlのバージョンは3系から5系に上げているためvue非対応となっていた。

そのため、eslint-plugin-vuepackage.jsonに追加し、READMEを参考にもろもろの設定をしたら無事にlintが通りました。
(今までvueファイルはhtml部分以外lintかけていなかった……?)

既存プロジェクトの改修等で同じような現象が発生した方の参考になれば幸いです。

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