Skip to content

vue-tsc throws unused variable error while tsc does not #4575

Closed
@vincerubinetti

Description

@vincerubinetti

Vue - Official extension or vue-tsc version

2.0.26

VSCode version

n/a (1.91.0)

Vue version

3.4.31

TypeScript version

5.5.3

System Info

No response

Steps to reproduce

I have the following ESLint config, in the ESLint v9.0.0 eslint.config.mjs file format. It specifies that unused variables should be a warning, not an error.

import path from "node:path";
import { fileURLToPath } from "node:url";
import prettier from "eslint-plugin-prettier";
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";

const compat = new FlatCompat({
  baseDirectory: path.dirname(fileURLToPath(import.meta.url)),
  recommendedConfig: js.configs.recommended,
  allConfig: js.configs.all,
});

export default [
  ...compat.extends(
    "plugin:vue/vue3-recommended",
    "plugin:vuejs-accessibility/recommended",
    "eslint:recommended",
    "@vue/eslint-config-typescript",
    "@vue/eslint-config-prettier/skip-formatting",
  ),
  {
    plugins: {
      prettier,
    },
    languageOptions: {
      ecmaVersion: "latest",
      sourceType: "module",
    },
    rules: {
      "prettier/prettier": "warn",
      "prefer-const": ["error", { destructuring: "all" }],
      "@typescript-eslint/no-unused-vars": "warn",
      "@typescript-eslint/consistent-type-definitions": ["error", "type"],
      "@typescript-eslint/consistent-type-imports": "error",
      "vuejs-accessibility/label-has-for": [
        "error",
        { required: { some: ["nesting", "id"] } },
      ],
    },
    files: ["**/*.ts", "**/*.vue"],
  },
  {
    ignores: ["dist"],
  },
];

But running vue-tsc, it seems to ignore the configuration and throw an error for unused vars.

$ vue-tsc && vite build
src/components/AppTable.vue:108:10 - error TS6133: 'cloneDeep' is declared but its value is never read.

108 import { cloneDeep, truncate } from "lodash";
             ~~~~~~~~~
Found 1 error in src/components/AppTable.vue:108

I have another package.json script for testing types that uses tsc --noemit, and it correctly flags it as a warning.

What is expected?

vue-tsc should respect ESLint v9 config in my repo, like tsc does.

What is actually happening?

vue-tsc seems to ignore the config file (at least for this one rule).

Link to minimal reproduction

No response

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions