Vue: Compatibility with linters's rules "no-new" and "no-undef"

Created on 2 Dec 2015  路  2Comments  路  Source: vuejs/vue

I'm using ESlint for code linting. When my Vue code goes like this:

var demo = new Vue({
  el: '#demo',
  data: {
    message: 'Hello Vue.js!'
  }
})

The linter will say "demo is defined but unused" because of this.

But if I write:

new Vue({
  el: '#demo',
  data: {
    message: 'Hello Vue.js!'
  }
})

The linter will say "do not use 'new' for side-effects" because of this.

It's okay if I can add an config file for the linter to my project. But when it comes to using an unconfigable linter, like Standard, the error will always be shown.

Is there any way to avoid this, or a new method in further versions? Like:

Vue.create({
  el: '#demo',
  data: {
    message: 'Hello Vue.js!'
  }
})

Most helpful comment

That is not Vue's concern if you are using an unconfigurable linter. You can just create that method yourself:

Vue.create = function (options) {
  return new Vue(options)
}

All 2 comments

That is not Vue's concern if you are using an unconfigurable linter. You can just create that method yourself:

Vue.create = function (options) {
  return new Vue(options)
}

You can always avoid warning by exporting the variable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wufeng87 picture wufeng87  路  3Comments

gkiely picture gkiely  路  3Comments

loki0609 picture loki0609  路  3Comments

julianxhokaxhiu picture julianxhokaxhiu  路  3Comments

aviggngyv picture aviggngyv  路  3Comments