Skip to content

Incorrect prefer-import-from-vue for values that are not exported by vue #2354

Open
@jods4

Description

@jods4

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.56.0
  • eslint-plugin-vue version: 9.19.2
  • Node version: 19.3.0
  • Operating System: Win 10

Please show your full configuration:

{
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "plugin:vue/vue3-recommended"
  ],
  "parserOptions": {
    "parser": "@typescript-eslint/parser",
    "ecmaVersion": 2020,
    "ecmaFeatures": {
      "jsx": false
    },
    "sourceType": "module"
  },
  "rules": {
    "@typescript-eslint/ban-ts-comment": "off",
    "@typescript-eslint/ban-types": "off",
    "@typescript-eslint/explicit-module-boundary-types": "off",
    "@typescript-eslint/no-empty-function": "off",
    "@typescript-eslint/no-explicit-any": "off",
    "@typescript-eslint/no-non-null-assertion": "off",
    "@typescript-eslint/no-inferrable-types": "off",
    "@typescript-eslint/no-unused-vars": [
      "error",
      {
        "varsIgnorePattern": "^_",
        "argsIgnorePattern": "^_"
      }
    ],
    "prefer-const": [
      "error",
      {
        "destructuring": "all"
      }
    ],
    "vue/html-self-closing": [
      "error",
      {
        "html": {
          "void": "any",
          "normal": "any"
        }
      }
    ],
    "vue/max-attributes-per-line": "off",
    "vue/no-dupe-keys": "off",
    "vue/no-mutating-props": "off",
    "vue/require-default-prop": "off",
    "vue/require-v-for-key": "off",
    "vue/singleline-html-element-content-newline": "off",
    "vue/valid-v-slot": "off",
    "vue/attributes-order": "off",
    "vue/attribute-hyphenation": "off",
    "vue/multi-word-component-names": "off",
    "vue/html-indent": "off"
  }
}

What did you do?

import { trigger, track } from "@vue/reactivity"

What did you expect to happen?
Nothing, that's fine code because vue itself does not export trigger nor track.

What actually happened?
Error vue/prefer-import-from-vue suggesting to import those members from vue, which is impossible.

Suggested fix
It's generally good practice to import from vue directly, so I'd like to keep this rule enabled.
The rule should have a list of all vue exports and not trigger when the imported value is not one of them (false positive).

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