{"record":{"id":"8f6f5b63cf500449","repo":"oxc-project/oxc","slug":"error-message","errorCode":null,"errorMessage":"{error_message:?}","messagePattern":"\\{error_message:\\?\\}","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs","lineNumber":18,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{\n        AssignmentExpression, CallExpression, Expression, MemberExpression, SimpleAssignmentTarget,\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{context::LintContext, rule::Rule};\n\nfn no_jasmine_globals_diagnostic(\n    error_message: &str,\n    help_text: &str,\n    span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"{error_message:?}\"))\n        .with_help(format!(\"{help_text:?}\"))\n        .with_label(span)\n}\n\n// <https://github.com/jest-community/eslint-plugin-jest/blob/v28.9.0/docs/rules/no-jasmine-globals.md>\n#[derive(Debug, Default, Clone)]\npub struct NoJasmineGlobals;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// This rule reports on any usage of Jasmine globals, which are not ported to\n    /// Jest, and suggests alternatives from Jest's own API.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// When migrating from Jasmine to Jest, relying on Jasmine-specific globals\n    /// creates compatibility issues and prevents taking advantage of Jest's","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs#L1-L36","documentation":"Diagnostic constructor for oxlint's port of eslint-plugin-jest's no-jasmine-globals rule. It reports Jasmine-specific globals that Jest does not define, so the test crashes with a ReferenceError under Jest. Messages are per-API ('Illegal usage of jasmine global', 'Illegal usage of global spyOn', 'Illegal usage of `fail`', 'Illegal usage of `pending`', etc.) and each suggests the Jest equivalent. Note the constructor formats with `{error_message:?}` (Rust Debug), so the rendered text appears wrapped in quotes.","triggerScenarios":"Two code shapes: (1) bare unresolved references to `spyOn`, `spyOnProperty`, `fail`, `pending` at module root scope; (2) any member access on an identifier literally named `jasmine` — calls like `jasmine.createSpy()`, `jasmine.addMatchers(m)`, `jasmine.any()`, `jasmine.clock()`, and assignments like `jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000`. Auto-fix exists for `jasmine.DEFAULT_TIMEOUT_INTERVAL = <number>` (→ `jest.setTimeout(n)`) and for jasmine.any/anything/arrayContaining/objectContaining/stringMatching (→ expect.*).","commonSituations":"Specs migrated from Jasmine or Karma runners (AngularJS-era codebases); helper files shared between Jasmine and Jest suites; assertions copy-pasted from Jasmine documentation; `pending()` used to mark unfinished work.","solutions":["Swap the Jasmine API for its Jest equivalent: jest.spyOn (spyOn/spyOnProperty), jest.fn (createSpy), expect.extend (addMatchers), expect.any/anything/arrayContaining/objectContaining/stringMatching, jest.setTimeout (DEFAULT_TIMEOUT_INTERVAL), test.skip (pending), throw or done.fail (fail).","Run `oxlint --fix` to apply the automatic replacements (DEFAULT_TIMEOUT_INTERVAL and expect.* member calls).","Grep the suite for `jasmine.` and the four bare globals to catch stragglers in helpers/setup files.","If a `jasmine` identifier in your code is unrelated to the Jasmine framework, rename it or disable the rule for that file."],"exampleFix":"// before\njasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;\nconst spy = jasmine.createSpy('cb');\nspyOn(obj, 'method');\n\n// after\njest.setTimeout(5000);\nconst spy = jest.fn();\njest.spyOn(obj, 'method');","handlingStrategy":"validation","validationCode":"// fail the build before Jasmine globals reach CI test runs\noxlint --jest-plugin --deny-warnings test/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the jest plugin enabled for all spec/helper globs so jasmine.* slips surface statically.","During a Jasmine→Jest migration, grep for `jasmine.`, spyOn, spyOnProperty, fail, pending in one sweep: `rg --no-ignore -w 'jasmine|spyOn|pending|fail' test/`.","Prefer jest.fn/jest.spyOn/expect.* in shared helpers so both runners' code paths stay Jest-native."],"tags":["jest","jasmine","migration","oxlint","lint"],"backgroundTag":"jasmine-to-jest-migration","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"}