nuxt-modules / eslint

ESLint module for Nuxt.js
MIT License
159 stars 15 forks source link

Reference `@nuxt/eslint-config` in the README #114

Closed mrleblanc101 closed 8 months ago

mrleblanc101 commented 1 year ago

Am I the only one finding configuring ESLint in Nuxt 3 very confusing ? I'm trying to setup eslint for a JavaScript project (no Typescript), and I can't find reliable documentation. Every .eslintrc file i find use parser: '@typescript-eslint/parser', but I can't make it work with @babel/eslint-parser

module.exports = {
    root: true,
    env: {
        browser: true,
        node: true,
    },
    parser: '@babel/eslint-parser',
    parserOptions: {
        ecmaVersion: 'latest',
        requireConfigFile: false,
        sourceType: 'module',
    },
    extends: [
        'eslint:recommended',
        'plugin:vue/essential',
        '@nuxt/eslint-config',
        'plugin:prettier/recommended',
        'prettier',
    ],
    plugins: ['prettier'],
};

But i get this error:

Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): "jsx", "flow", "typescript". (1:0)

Screenshot 2023-10-08 at 10 23 43 PM

Second, shouldn't the nuxt 3 version of this module be in the @nuxt namespace instead of the @nuxtjs namespace ? Because the @nuxtjs/eslint-config and @nuxtjs/esling-config-typescript package are meant for Nuxt 2 and the Nuxt 3 version are called @nuxt/eslint-config and @nuxt/eslint-config-typescript.

XyoloJR commented 11 months ago

It should be nice to reference that config @nuxt/eslint-config for sure. I didn't find a running config before reading your post here.

Instead of babel parser you could try vue-eslint-parser from eslint-plugin-vue

I manage to have a minimal config running for typescript with that .eslinrc.json :

{
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:vue/vue3-recommended",
        "@nuxt/eslint-config"
    ],
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": "@typescript-eslint/parser",
        "sourceType": "module"
    },
    "plugins": ["@typescript-eslint"],
    "root": true
}