vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

Option to disable Module Warnings from templateLoader.js #1546

Open dflock opened 5 years ago

dflock commented 5 years ago

What problem does this feature solve?

I use eslint, with plugin:vue/recommended & @vue/prettier to lint my projects code. However, when I serve or build the project, I also get output in the console from templateLoader.js for some warnings - that I'm aware of and have disabled in eslint.

An example would be:

warning  in ./src/components/myComponent.vue?vue&type=template&id=74865fe8&scoped=true&lang=html&

Module Warning (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):
(Emitted value instead of an instance of Error) <b-tab v-for="key in tabList">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.

This is the code in question:

      <!-- NOTE: Don't add a :key to this v-for, it'll mess up the tab order, when tabs are dynamically added & removed -->
      <!-- eslint-disable -->
      <b-tab
        v-for="key in tabList"
        :disabled="key !== 'tableDefinition' && isNewTable"
      >
        <!-- eslint-enable -->

As you can see, these lines have comments disabling eslint, because this is a known issue in a 3rd party component.

The templateLoaders doesn't seem to be taking my eslint configuration into account, so is there a way to switch these warnings off?

It looks like this is called tips inside templateLoader.js, here.

What does the proposed API look like?

I guess this would just be another vue-loader option that could be set in vue.config.js, maybe something like this:

  chainWebpack: config => {
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .options({
         moduleWarnings: false
      })
  }
baixiaoyu2997 commented 5 years ago

i need this too