10

I am using the Vue ESLint plugin and it has a rule for not allowing single word component names.

However, I am also using Nuxt, and to set a default Layout in Nuxt you need a .vue component named default.vue which throws the ES Lint rule errors.

I can't seem to get it to just disable in that one .vue file that is actually pretty small...

<template>
    <div>
        <Header/>
        <Nuxt/>
    </div>
</template>

But if I disable the rule in my .eslintrc.js then it works.

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  extends: [
    '@nuxtjs/eslint-config-typescript',
    'plugin:nuxt/recommended',
    'prettier',
  ],
  plugins: [],
  // add your custom rules here
  rules: {
    'vue/multi-word-component-names': 'off',
  },
}

Is there a way to disable the rule for just one Vue file?

Carson Wood
  • 744
  • 3
  • 8
  • 19
  • Does this answer your question? [Turning off eslint rule for a specific file](https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file) – Estus Flask Jan 03 '22 at 21:34
  • 1
    FWIW, this rule is totally impractical and could be disabled forever. – Estus Flask Jan 03 '22 at 21:35
  • This is marked as essential here: https://vuejs.org/v2/style-guide/#Multi-word-component-names-essential – kissu Jan 04 '22 at 07:59

4 Answers4

24

In your case, you can replace

'vue/multi-word-component-names': 'off'

with:

'vue/multi-word-component-names': ['error', {
  'ignores': ['default']
}]

this will set the rule to 'allow' for all files named 'default'

you can read more about it here: https://eslint.vuejs.org/rules/multi-word-component-names.html

Ahmad Ibrahim
  • 241
  • 1
  • 2
5

rules: { 'vue/multi-word-component-names': 0 } try this way

HJW
  • 121
  • 1
  • 8
0

Just the below line the vue.config.js file:

module.exports = defineConfig({
  ....
  lintOnSave: false
})
vinzee
  • 17,022
  • 14
  • 42
  • 60
0

In your case, you can replace

vue.config.js

with:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
})