{"record":{"id":"cc07a42bb64ca9c4","repo":"oxc-project/oxc","slug":"ts5042","errorCode":"TS5042","errorMessage":"Option 'project' cannot be mixed with source files on a command line.","messagePattern":"Option 'project' cannot be mixed with source files on a command line\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/oxc_type_checker/src/execute/tsc.rs","lineNumber":75,"sourceCode":"    for file in program.files() {\n        println!(\"  {}\", file.file_name().display());\n    }\n    println!(\"({} files)\", program.len());\n    Ok(())\n}\n\n/// Resolve the command line into the `tsconfig.json` (or config file) to load, mirroring\n/// the project-resolution block of tsgo's `tscCompilation`.\n///\n/// Returns:\n/// - `Ok(Some(path))` — a resolved config file to load,\n/// - `Ok(None)` — source files were given with no config file (compile them directly),\n/// - `Err(_)` — one of `tsc`'s command-line errors, ready to print.\nfn resolve_config_file(command: &TypeCheckCommand, cwd: &Path) -> Result<Option<PathBuf>> {\n    if let Some(project) = &command.project {\n        // TS5042\n        if !command.files.is_empty() {\n            bail!(\"Option 'project' cannot be mixed with source files on a command line.\");\n        }\n\n        let file_or_directory = to_path(cwd, project);\n        if file_or_directory.is_dir() {\n            // A directory: look for `tsconfig.json` inside it.\n            let config_file = file_or_directory.join(\"tsconfig.json\");\n            if config_file.is_file() {\n                Ok(Some(config_file))\n            } else {\n                // TS5081\n                bail!(\n                    \"Cannot find a tsconfig.json file at the current directory: {}.\",\n                    config_file.display()\n                );\n            }\n        } else if file_or_directory.exists() {\n            // An explicit config file (need not be named `tsconfig.json`).\n            Ok(Some(file_or_directory))","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_type_checker/src/execute/tsc.rs#L57-L93","documentation":"Diagnostic from oxlint's vue/valid-define-emits rule (crates/oxc_linter/src/rules/vue/valid_define_emits.rs). It fires when the `defineEmits` argument references a variable declared locally in the same `<script setup>` scope (`const def = {...}; defineEmits(def)`). Compiler macros are hoisted and transformed at compile time, so referencing setup-local values can break compilation or produce wrong output. Variables imported from other modules, or declared in the sibling plain `<script>` block, are fine.","triggerScenarios":"`<script setup> const def = { notify: null }; defineEmits(def) </script>` — the argument identifier resolves to a binding declared inside the setup scope. The identical code with `def` imported from './defs' or declared in a normal `<script>` block passes the rule.","commonSituations":"Sharing props/emits definition objects between components via copy-paste; extracting the object 'for readability' inside the setup block.","solutions":["Inline the object/array literal into the call: `defineEmits({ notify: null })`.","Or move the definition to a module and import it: `import { emitsDef } from './defs'; defineEmits(emitsDef);`.","In TS prefer a type-only declaration: `defineEmits<(e: 'notify') => void>()`."],"exampleFix":"// before\nconst def = { notify: null };\ndefineEmits(def);\n\n// after\nimport { def } from './emits-defs';\ndefineEmits(def);\n// or simply: defineEmits({ notify: null })","handlingStrategy":"validation","validationCode":"// defineEmits must not reference setup-local variables\nif (/const\\s+(\\w+)[\\s\\S]*?defineEmits\\s*\\(\\s*\\1\\s*\\)/.test(setupSource)) {\n  throw new Error('defineEmits references a locally declared variable; inline it or import it');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass literals (object/array) or type parameters directly to compiler macros.","Shared definitions belong in a separate module, imported.","Remember macros are compile-time hoisted; never feed them setup-local state."],"tags":["vue","oxlint","lint","script-setup","defineemits","compiler-macro","hoisting"],"backgroundTag":"vue-define-emits-misuse","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"}