Skip to content

vue/prefer-import-from-vue Correctness

🛠️ An auto-fix is available for this rule.

What it does

Enforce import from 'vue' instead of import from '@vue/*'.

Why is this bad?

Imports from the following modules are almost always wrong. You should import from vue instead.

  • @vue/runtime-dom
  • @vue/runtime-core
  • @vue/reactivity
  • @vue/shared

Examples

Examples of incorrect code for this rule:

js
import { ref } from "@vue/reactivity";
import { Component } from "@vue/runtime-core";
import { createApp } from "@vue/runtime-dom";

Examples of correct code for this rule:

js
import { Component, createApp, ref } from "vue";

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny vue/prefer-import-from-vue --vue-plugin
json
{
  "plugins": ["vue"],
  "rules": {
    "vue/prefer-import-from-vue": "error"
  }
}

References

Released under the MIT License.