0

I'm working with Vue3 + Typescript and want to integrate a pipeline with Lint but it's giving me some issues.

I have eslint 9.34.0 and my eslint.config.cjs is in /config but I reference it in my package.json with

--config config/eslint.config.cjs

The problem is that when I run "npm run lint" to test it it's giving me this error:

error  Parsing error: Unexpected token <

I searched and I might need to add a parser but it isn't recognized in langaugeOptions.

"parser": "@babel/eslint-parser"
TypeError: Key "languageOptions": Key "parser": Expected object with parse() or parseForESLint() method.

This is my eslint.config.cjs

module.exports = [
    {
        languageOptions: {
            globals: {
                window: 'readonly',
                document: 'readonly',
                console: 'readonly',
            },
            parserOptions: {
                ecmaVersion: 2021,
                sourceType: 'module',
            },
        },
        rules: {
            'no-unused-vars': 'warn',
            'no-console': 'warn',
        },
        ignores: ['dist/', 'node_modules/'],
    },
];

---

All good now. I've checked https://eslint.vuejs.org/user-guide/#example-configuration-with-typescript-eslint-and-prettier, and I was using the wrong extension and format, as well as missing the Vue plugin.

Now it works: eslint.config.js.

import eslint from '@eslint/js'
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
    {
        ignores: ['dist/', 'node_modules/'],
    },
    {
        files: ['**/*.{ts,vue}'],
        extends: [
            eslint.configs.recommended,
            ...tseslint.configs.recommended,
            ...pluginVue.configs['flat/recommended'],
        ],
        languageOptions: {
            ecmaVersion: 'latest',
            sourceType: 'module',
            globals: {
                ...globals.browser,
            },
            parserOptions: {
                parser: tseslint.parser, 
            },
        },
        rules: {
            'no-unused-vars': 'warn',
            'no-console': 'warn',
        },
    }
)
1
  • 1
    You can answer your own question since you've found a working config. Commented Aug 29 at 12:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.