{"record":{"id":"ff9b7b33c7ba9e92","repo":"oxc-project/oxc","slug":"jsx-not-allowed-in-files-with-extension-ext","errorCode":null,"errorMessage":"JSX not allowed in files with extension '.{ext}'","messagePattern":"JSX not allowed in files with extension '\\.(.+?)'","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/jsx_filename_extension.rs","lineNumber":21,"sourceCode":"use itertools::Itertools;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\nuse serde_json::Value;\n\nuse oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\n\nuse crate::{context::LintContext, rule::Rule};\n\nfn no_jsx_with_filename_extension_diagnostic(\n    ext: &str,\n    span: Span,\n    allowed_extensions: &[CompactStr],\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"JSX not allowed in files with extension '.{ext}'\"))\n        .with_help(format!(\n            \"Rename the file to use an allowed extension: {}\",\n            allowed_extensions.iter().map(|e| format!(\".{e}\")).join(\", \")\n        ))\n        .with_label(span)\n}\n\nfn extension_only_for_jsx_diagnostic(ext: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Only files containing JSX may use the extension '.{ext}'\"))\n        .with_help(\"Rename the file with a good extension.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize, Serialize)]\n#[serde(rename_all = \"kebab-case\")]\nenum JsxFilenameExtensionAllowMode {\n    /// Always allow a JSX filename extension.\n    #[default]","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/jsx_filename_extension.rs#L3-L39","documentation":"Raised by react/jsx_filename_extension when the file being linted has an extension not in the rule's `allow` list (default jsx/tsx) yet contains JSX. At the throw site JSX in a file with an unexpected extension (e.g. `.js`) breaks tooling conventions — bundler resolution, editor tooling, and team norms expect JSX only in configured extensions. run_once() reads the file path, extracts its extension, and reports the module span when the extension is disallowed.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/jsx_filename_extension.rs:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the file to an allowed extension (.jsx or .tsx).","Add the current extension to the rule's allowedExtensions configuration.","Move the JSX into a separate .jsx file."],"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-14T05:17:10.506Z"}