Eslint-plugin-vue: disable eslint in vue template

Created on 28 Nov 2017  ยท  30Comments  ยท  Source: vuejs/eslint-plugin-vue

Hi,

Is there anyway to disable lint in template like in js (e.g. eslint-disable-line)?

enhancement work in progress

Most helpful comment

try <!-- eslint-disable -->
this will disable linting for everything below it
you can use <!-- eslint-enable --> to re-enable it back

All 30 comments

Thank you for this issue.

There is no way, currently.
We should investigate the way to implement directive comments such as eslint-disable.

It's particularly frustrating with the max-len eslint rule. I often have paragraphs or long elements and so I've had to disable the rule. A shame because it's useful for JS linting.

Any way to disable eslint in pug templates? The solution given apparently doesn't work with pug.

2018 June 13,
this annoying me, so I just search and remove js-lint

Before

image
image

After

image
image

You need to add ':key="t"', it needs for circle's item.

@Julia-Lavrova Thanks!

@Julia-Lavrova thanks.

@mysticatea how about now???

    <!-- eslint-disable-next-line vue/no-v-html -->
    <p class="post-excerpt" v-html="post.excerpt || post.frontmatter.description || '' " />

The above vue/no-v-html example works for me, but <!-- eslint-disable vue/valid-v-on --> doesn't, the error still shows. Using 5.0.0-beta.3.

try <!-- eslint-disable -->
this will disable linting for everything below it
you can use <!-- eslint-enable --> to re-enable it back

@willin It seems that it can't resolved this situation
<p class="post-excerpt" v-html="post.excerpt || post.frontmatter.description || '' " />

your_project/config/index.js

change the value of useEslint from _true_ to _false_, from line 26, inside:

module.exports: {
    dev: {
        useEslint: false
    }
}

note: I use the vue webpack template, the version of the template is 1.3.1

@aniude you can use it like so;

        <!-- eslint-disable vue/no-v-html -->
        <div
          v-if="!manageOptions"
          class="content"
          v-html="$t('gdpr.marketingConsent.body')"
        />
        <!--eslint-enable-->

<!-- eslint-disable --> and <!-- eslint-enable --> won't work.
Template linting is unable to disable. ๐Ÿ˜จ

default

@gluons you need to use it inside the <template> tag, this works on webstorm at least

@blowsie It still won't work. Not only VSCode. Vue CLI throws the errors.

default

default

We don't support pug templates @gluons Depending on version of vue-eslint-parser you have installed templates other than html should be ignored. Can you provide informations about versions of eslint-plugin-vue and vue-eslint-parsers you use?

@michalsnik I've removed yarn.lock and node_modules and reinstall modules to get fresh packages. Here is it.

eslint-plugin-vue:

> yarn list --pattern eslint-plugin-vue
yarn list v1.12.3
โ”œโ”€ @vue/[email protected]
โ”‚  โ””โ”€ [email protected]
โ””โ”€ [email protected]

vue-eslint-parser:

> yarn list --pattern vue-eslint-parser
yarn list v1.12.3
โ”œโ”€ @vue/[email protected]
โ”‚  โ””โ”€ [email protected]
โ””โ”€ [email protected]

Errors still exist.

default

default

Is there a way to ignore someone specific rule globally in the .eslintrc file? I tried this, but it doesn't work

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  parserOptions: {
    parser: 'babel-eslint'
  },
  extends: [
    '@nuxtjs',
    'plugin:nuxt/recommended',
    'plugin:prettier/recommended',
    'prettier',
    'prettier/vue'
  ],
  plugins: [
    'prettier'
  ],
  // add your custom rules here
  rules: {
    "vue/no-v-html": "off"
  }
};

I want this, because i want to use v-html everywhere and don't need to set ignore on every occurence.

@PayteR I think this rule expects an int rather than a string. I have it working like this:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  parserOptions: {
    parser: 'babel-eslint'
  },
  extends: [
    '@nuxtjs',
    'plugin:nuxt/recommended'
  ],
  // add your custom rules here
  rules: {
    'nuxt/no-cjs-in-config': 'off',
    'vue/no-v-html': 0,
    'no-console': 0
  }
}

The error exists in VSCode even I try to ignore it:

<div>
    <!--eslint-disable vue/valid-v-for-->
    <component v-for="(item, index) in lists" v-bind="component_binding(item, index)" v-on:event_com="event_binding"></component>
    <!--eslint-enable-->
</div>

Software version:

  1. VSCode v.1.42
  2. eslint-plugin-html v.6.0.0
  3. eslint-plugin-vue v.5.2.3

try <!-- eslint-disable -->
this will disable linting for everything below it
you can use <!-- eslint-enable --> to re-enable it back

Add in App.vue

I'm using [email protected] and I'm still experiencing this bug:
image
Interestingly, without the flag on line 75, VSCode actually emits TWO warnings, one from ESLint, and the other somehow from this plugin...
image
I need to ignore it for this line only (not the whole file) as my cellData variable contains a key.

why not just pass :key="cellData.key"?

why not just pass :key="cellData.key"?

That is what I've done as a workaround, but it doesn't make this not a bug.

It's not working for me. I tried to disable in template and also tried with eslint config in package.json. Nothing is working for me.

Screenshot 2020-08-05 at 1 20 27 AM

Screenshot 2020-08-05 at 1 19 59 AM

Screenshot 2020-08-05 at 1 25 06 AM

The error is irritating. Please let me know if anyone has a solution for this.

why not just pass :key="cellData.key"?

Because you can't do this:

<div>
    <component :="{ key: cellData.key, class: cellData.class }"></component>
</div>

In this situation, you must do something like this:

<div>
    <component v-bind="{ key: cellData.key, class: cellData.class }"></component>
</div>

It's not working for me. I tried to disable in template and also tried with eslint config in package.json. Nothing is working for me.

Screenshot 2020-08-05 at 1 20 27 AM

Screenshot 2020-08-05 at 1 19 59 AM

Screenshot 2020-08-05 at 1 25 06 AM

The error is irritating. Please let me know if anyone has a solution for this.

@rajeshwarpatlolla let me know if you find a solution. I have the exact same problem

@chasedougherty4628

I had the same problem.
But I could solve with adding a line bellow into .vscode/setting.json.

"vetur.validation.template": false

reference: https://gitmemory.com/issue/vuejs/eslint-plugin-vue/1269/668921391

If you are using eslint with vscode and vetur, it may help you.

image
Same issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gluons picture gluons  ยท  4Comments

lichnow picture lichnow  ยท  3Comments

armano2 picture armano2  ยท  4Comments

casprwang picture casprwang  ยท  4Comments

rodneyrehm picture rodneyrehm  ยท  4Comments