{"record":{"id":"22532f77226d5624","repo":"oxc-project/oxc","slug":"name-is-a-compiler-macro-and-doesn-t-need-to-b","errorCode":null,"errorMessage":"'{name}' is a compiler macro and doesn't need to be imported.","messagePattern":"'(.+?)' is a compiler macro and doesn't need to be imported\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/vue/no_import_compiler_macros.rs","lineNumber":12,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ImportDeclarationSpecifier, ModuleExportName},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, frameworks::FrameworkOptions, rule::Rule};\n\nfn no_import_compiler_macros_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"'{name}' is a compiler macro and doesn't need to be imported.\"))\n        .with_help(\"Remove the import statement for this macro.\")\n        .with_label(span)\n}\n\nfn invalid_import_compiler_macros_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"'{name}' is a compiler macro and can't be imported outside of `<script setup>`.\"\n    ))\n    .with_help(\"Remove the import statement for this macro.\")\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoImportCompilerMacros;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/no_import_compiler_macros.rs#L1-L30","documentation":"The vue/no-import-compiler-macros rule reports imports of Vue compiler macros (`defineProps`, `defineEmits`, `defineExpose`, `withDefaults`, etc.) inside `<script setup>`. These macros are global, auto-provided by the SFC compiler, and are compiled away — importing them is unnecessary noise and can even bind the wrong binding. The message \"'{name}' is a compiler macro and doesn't need to be imported.\" comes from no_import_compiler_macros_diagnostic.","triggerScenarios":"Inside a `<script setup>` block, an import declaration whose specifier names a compiler macro, e.g. `import { defineProps, defineEmits } from 'vue'`. The rule walks ImportDeclarationSpecifier / ModuleExportName nodes to find the imported macro names.","commonSituations":"IDE auto-import adding `defineProps` to the import list; migrating from a setup() function where macros were genuinely imported; copy-pasting snippets that self-contain their imports; older codebases that predate the macro-globals behavior.","solutions":["Delete the macro names from the import statement (or delete the whole import if it only contained macros).","Configure your editor's auto-import to ignore `defineProps`/`defineEmits`/`defineExpose`/`withDefaults`.","Optionally apply the suggested fix: the diagnostic's help text is 'Remove the import statement for this macro.'","Re-run oxlint to verify."],"exampleFix":"// before\n<script setup>\nimport { defineProps, ref } from 'vue';\nconst props = defineProps<{ id: string }>();\n</script>\n\n// after\n<script setup>\nimport { ref } from 'vue';\nconst props = defineProps<{ id: string }>();\n</script>","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure editor auto-import to exclude compiler macros (defineProps, defineEmits, defineExpose, withDefaults).","Remember macros are global inside `<script setup>` — never add them to import lists.","Run oxlint before commit to catch auto-inserted macro imports."],"tags":["vue","script-setup","lint","compiler-macros","imports"],"backgroundTag":"unnecessary-import","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}