{"record":{"id":"2e706049b33a6bb7","repo":"oxc-project/oxc","slug":"do-not-use-use-strict-directive","errorCode":null,"errorMessage":"Do not use \"use strict\" directive.","messagePattern":"Do not use \"use strict\" directive\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/prefer_module.rs","lineNumber":15,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    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!(","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/prefer_module.rs#L1-L33","documentation":"Diagnostic from the unicorn/prefer-module lint rule. It fires when a \"use strict\" directive appears in a file that is (or should be) an ES module: ES modules are always parsed in strict mode, so the directive is redundant. The flagged input is the directive prologue statement. It is a lint suggestion, not a runtime error.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/prefer_module.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the `\"use strict\";` directive","Ensure the file is treated as a module (ESM `import`/`export` or `.mjs`) so strictness applies automatically","Apply the rule's auto-fix"],"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"}