{"record":{"id":"fd9e67b35e42eee0","repo":"oxc-project/oxc","slug":"do-not-use-name","errorCode":null,"errorMessage":"Do not use \"{name}\".","messagePattern":"Do not use \"(.+?)\"\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_module.rs","lineNumber":25,"sourceCode":"    AstNode,\n    context::{ContextHost, LintContext},\n    rule::Rule,\n};\n\nconst COMMON_JS_GLOBALS: [&str; 5] = [\"exports\", \"require\", \"module\", \"__filename\", \"__dirname\"];\n\nfn use_strict_directive_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(r#\"Do not use \"use strict\" directive.\"#)\n        .with_help(\"ES modules are always strict mode, so this directive is redundant.\")\n        .with_label(span)\n}\n\nfn global_return_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(r#\"\"return\" should be used inside a function.\"#).with_label(span)\n}\n\nfn common_js_global_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(r#\"Do not use \"{name}\".\"#))\n        .with_help(\"Prefer ES modules over CommonJS globals.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferModule;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Prefer JavaScript modules (ESM) over CommonJS.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// CommonJS globals and patterns (`require`, `module`, `exports`, `__filename`, `__dirname`)\n    /// make code harder to migrate and can block ESM-only features.\n    ///\n    /// ### Examples","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_module.rs#L7-L43","documentation":"Diagnostic from the unicorn/prefer-module lint rule. It fires when code references a CommonJS global — `exports`, `require`, `module`, `__filename`, or `__dirname` (the name appears in the message) — inside a file that is an ES module, where those identifiers do not exist and would be runtime `ReferenceError`s. The flagged input is the identifier reference to the CommonJS global.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_module.rs:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace `require()` with a static `import` or dynamic `import()`","Replace `exports`/`module.exports` with `export` statements","Replace `__dirname`/`__filename` with `import.meta.dirname`/`import.meta.filename`","Apply the rule's auto-fix where available"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}