question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

๐Ÿ› eslint vue/multi-word-component-names naming limitation for routes

See original GitHub issue

Versions

  • nuxt: v2.15.8
  • node: v14.15.1

Reproduction

I tried to add a codesandbox link but this is an error during build that would not show on console

Steps to reproduce

  1. Create nuxt app
  2. Create a single word component, either in /layouts, /components or /pages
  3. Check build error, it says error Component name "name" should always be multi-word

What is Expected?

For example if I create pages/home.vue or pages/home/index.vue then I should be able to go to http://localhost:3000/home according to the docs

Also according to docs I should be able to create layouts/default.vue

What is actually happening?

During build it shows the error I mentioned before

If I rename my component to VHome.vue then it works but itโ€™s not ideal since that changes my route too

Current workaround

I changed my Nuxt version to v2.15.7 and it worked, it built and the routes were how I wanted. However if I upgrade to the latest version of Nuxt, I can go to .eslintrc.js and set:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  parserOptions: {
    parser: '@babel/eslint-parser',
    requireConfigFile: false,
  },
  extends: ['@nuxtjs', 'plugin:nuxt/recommended', 'prettier'],
  plugins: [],
  // ๐Ÿšจ IMPORTANT: this is the config that fixes it at the moment
  rules: {
    "vue/multi-word-component-names": ["error", {
      "ignores": ["default", "home"]
    }]
  },
}

However this is not convenient because I have to put the name of every single file in the array

๐Ÿ’– Thank you for taking the time to review this, lmk if I can provide more information

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:12
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
olivervorasaicommented, Jan 4, 2022

You can disable it in /pages and /layouts like this in .eslintrc.js:

module.exports = {
    root: true,
    env: {
        ...
    },
    extends: [
        ...
    ],
    rules: {
        ...
    },
    overrides: [
        {
            files: ['pages/**/*.vue', 'layouts/*.vue'],
            rules: {
                'vue/multi-word-component-names': 'off',
            },
        },
    ],
}

This example file is with .eslintrc.js in your top-level directory, not within the /pages directory.

13reactions
der-danielcommented, Jan 3, 2022

My workaround is to use a .eslintrc.js inside the pages directory with

module.exports = {
  rules: {
    'vue/multi-word-component-names': 'off',
  },
}

See: https://github.com/vuejs/eslint-plugin-vue/issues/245

But I find it sub optimal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/multi-word-component-names
This rule require component names to be always multi-word, except for root App components, and built-in components provided by Vue,ย ...
Read more >
ESLint Vue multiword components - Stack Overflow
There's a simple solution. You need define your component name with more than one word as it states. Should beย ...
Read more >
how to disable multi-word-component-names eslint rule for ...
I'm working on learning vue 3 and recently bought web storm as the ide to use. I can't get it working if I...
Read more >
Working with Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Deal with ESLint errors in Vue project - HackMD
For routes, I can't cahnge the route name with restriction of specification, ... .eslintrc.js module.exports = { 'vue/multi-word-component-names': 0 }ย ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found