Resolve no-new eslint issues with our Vue instantiation methods
Currently we have a common pattern of instantiating Vue components with:
new Vue({
el: '#some-element',
render(createElement) {
// ...
},
});
This violates our no-new
eslint rule because we instantiate a JavaScript object without storing it anywhere. In this case it is usually acceptable because we have no use for the returned object, and we bypass the rule with
// eslint-disable-line no-new
However this is tedious and we want to avoid making exceptions to our eslint rules wherever possible. So I propose we implement something Evan You suggests in a github thread on this subject (link to comment).
Vue.create = function (options) { return new Vue(options) }
We would monkey-patch Vue itself to add a (very) simple create
method and then replace all instances of new Vue
with Vue.create
which won't need an exception from our linter rules.