{"record":{"id":"7260865579f27cc9","repo":"oxc-project/oxc","slug":"the-file-file-path-is-a-test-file-but-its-name","errorCode":null,"errorMessage":"The file {file_path} is a test file, but its name does not match the expected pattern.","messagePattern":"The file (.+?) is a test file, but its name does not match the expected pattern\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vitest/consistent_test_filename.rs","lineNumber":20,"sourceCode":"\nuse lazy_regex::{Regex, RegexBuilder};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn consistent_test_filename_diagnostic(file_path: &str, pattern: &str) -> OxcDiagnostic {\n    let message = format!(\n        \"The file {file_path} is a test file, but its name does not match the expected pattern.\"\n    );\n    let help = format!(\"Rename the file that match the pattern {pattern}\");\n\n    OxcDiagnostic::warn(message).with_help(help)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ConsistentTestFilename(Box<ConsistentTestFilenameConfig>);\n\n#[derive(Debug, Clone, Deserialize, JsonSchema)]\npub struct CompiledAllTestPattern(\n    #[serde(deserialize_with = \"deserialize_matcher_pattern\")] lazy_regex::Regex,\n);\n\nimpl Default for CompiledAllTestPattern {\n    fn default() -> Self {\n        Self(\n            Regex::new(r\".*\\.(test|spec)\\.[tj]sx?$\")\n                .expect(\"default all-test pattern should be valid\"),\n        )\n    }\n}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vitest/consistent_test_filename.rs#L2-L38","documentation":"Emitted by the vitest/consistent-test-filename rule during the run-once pass for every file that vitest treats as a test file but whose path does not match the configured naming pattern (e.g. `*.spec.ts` vs `*.test.ts`). It fires on the file as a whole, not on a specific AST node.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vitest/consistent_test_filename.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the file to match the expected pattern shown in the help message","Or adjust the rule's `pattern` option to accept your naming convention"],"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"}