Vue.js2.x ESLint error  Do not use ‘new’ for side effects

Vue.js2.x ESLint error Do not use ‘new’ for side effects

Vue.js2.x 系で ESLint を稼働させたところ以下のエラーが出力されました。

エラー内容

error  Do not use 'new' for side effects

エラーコード

new Vue({
  el: 'app',
  template: '<App/>',
  components: { App },
});

対応方法

const myApp = new Vue({
  template: '<App/>',
  components: { App },
});
myApp.$mount('app');

new を一回constに入れます。constに入れるだけだと別の警告で指摘されるので、面倒ですがマウントを外出ししてやります。

以上でございます。

PS

ESLintの設定は参考サイト様に習いました。

https://qiita.com/sbut_sug/items/ed58605e4e12519876fd

Comments

No comments yet. Why don’t you start the discussion?

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です