Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/multi-word-component-names: 'off' not respected on pages when nuxt srcDir is changed. #225

Closed
StefanCardnell opened this issue Jul 29, 2022 · 1 comment

Comments

@StefanCardnell
Copy link

StefanCardnell commented Jul 29, 2022

Reproduction:

- Operating System: `Linux`
- Node Version:     `v18.5.0`
- Nuxt Version:     `3.0.0-rc.5`
- Package Manager:  `yarn@1.22.19`
- Builder:          `vite`
- User Config:      `ssr`, `srcDir`, `typescript`, `app`, `vite`, `modules`, `css`
- Runtime Modules:  `@pinia/nuxt@0.3.0`, `@nuxtjs/tailwindcss@5.3.0`
- Build Modules:    `-`
------------------------------
  1. Go to nuxt.config.ts and change srcDir to src/
  2. Move all folders, including layout and pages, under the src/ directory. But keep eslintrc.json in the root directory still.

I face issues that my layout/page components are not multiword components:

image

I can see this is because the ESLint rule is very particular about the pages/layout directory being at the top level:

https://github.com/nuxt/eslint-config/blob/d4250a6e4d57835d7c9d3c017ab82a1f55383c98/packages/eslint-config/index.js#L130

It's fixable with the following override in eslintrc.json, but feels dirty:

    overrides: [
        {
            files: ['src/pages/**/*.vue', 'src/layouts/*.vue'],
            rules: {
                'vue/multi-word-component-names': 'off',
            },
        },
    ],

Edit: I suppose the issue disappears when moving eslintrc.json in to the src/ directory however obviously this means the top level directory won't have eslintrules. So for the moment I've defined two eslintrc.json files - I don't know if this is the intended way of doing this:

/eslintrc.json:

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:prettier/recommended"
    ],
    "parserOptions": {
        "ecmaVersion": "latest",
        "parser": "@typescript-eslint/parser",
        "sourceType": "module"
    },
    "plugins": ["@typescript-eslint"]
}

/src/eslintrc.json:

{
    "extends": [
        "eslint:recommended",
        "plugin:vue/essential",
        "plugin:@typescript-eslint/recommended",
        "@nuxtjs/eslint-config-typescript",
        "plugin:prettier/recommended"
    ],
    "plugins": ["vue", "@typescript-eslint"]
}
@antfu
Copy link
Member

antfu commented Mar 19, 2024

With the previous config format, it's not possible for us to have rules that aware the project configurations (custom rootDir). #332 should fix it (tho it's for Nuxt 3). Otherwise, I think the workaround is for you to disable it manually with local overrides.

@antfu antfu closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants