[Vuejs]-Eslint treat my *.ts files as javascript in a project that also has vue

0๐Ÿ‘

โœ…

I think Iโ€™m too tired or too old, anyway, the problem was in having two parserOptions sections in the same lint file. Here is the final working version:

module.exports = {
  root: true,
  env: {
    browser: true,
    es2021: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:vue/vue3-essential",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "prettier",
  ],
  parser: "vue-eslint-parser",
  parserOptions: {
    parser: "@typescript-eslint/parser",
    project: ["./tsconfig.json"],
    ecmaVersion: "latest",
    sourceType: "module",
    extraFileExtensions: [".vue"],
  },
//  parserOptions: {
//    ecmaVersion: "latest",
//    sourceType: "module",
//  },
  plugins: ["vue", "@typescript-eslint"],
};

0๐Ÿ‘

As I see it you have two options :

  1. change parser: "vue-eslint-parser" to @typescript-eslint/parser

  2. add an override for .ts files and there set the parser to @typescript-eslint/parser

Leave a comment