Solution of “do not use ‘new’ for side effects” for eslint verification of Vue project

When I was writing Vue project, I wrote the following code in JS to report an error

import Vue from 'vue'
import App from './App.vue'

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

Solution:

1. Define a variable XXX to accept the created Vue, and then add XXX to use

import Vue from 'vue'
import App from './App.vue'

let myOwn = new Vue({
  el: '#app',
  component: {
    App
  },
  template: '<App/>'
})
Vue.use ({ xxx })

2. Add a comment line above the new Vue so that eslint does not check for ‘no new’

import Vue from 'vue'
import App from './App.vue'

/* eslint-disable no-new */
new Vue({
  el: '#app',
  component: {
    App
  },
  template: '<App/>'
})

 


Read More: