oxc-project/oxc · warning
Enforce lowercase test names
Error message
Enforce lowercase test names
What it means
This is the oxlint `prefer-lowercase-title` rule (jest/vitest plugin). It enforces that the first letter of `it`/`test`/`describe`/`bench` titles is lowercase, which keeps generated failure sentences grammatical ('adds two numbers' vs 'Adds two numbers'). The diagnostic includes the offending title and points at the title argument span.
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/prefer_lowercase_title.rs:17
use oxc_ast::{AstKind, ast::Argument};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;
use oxc_str::CompactStr;
use schemars::JsonSchema;
use serde::Deserialize;
use crate::{
context::LintContext,
rule::DefaultRuleConfig,
utils::{
JestFnKind, JestGeneralFnKind, ParsedJestFnCallNew, PossibleJestNode, parse_jest_fn_call,
},
};
fn prefer_lowercase_title_diagnostic(title: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Enforce lowercase test names")
.with_help(format!("`{title:?}`s should begin with lowercase"))
.with_label(span)
}
pub const DOCUMENTATION: &str = r"### What it does
Enforce `it`, `test`, `describe`, and `bench` to have descriptions that begin with a
lowercase letter. This provides more readable test failures.
### Why is this bad?
Lowercase messages for test failures generally result in more grammatically correct
failure messages when you have a test failure.
### Examples
Examples of **incorrect** code for this rule:
```javascriptView on GitHub (pinned to e1e7af627c)
Solutions
- Lowercase the first letter of the title: `it('returns 404', ...)`.
- For titles that must start with a proper noun/acronym (e.g. 'HTTP ...'), add it to the rule's allowed prefixes option.
- If your team standard is capitalized titles, turn this rule off in .oxlintrc.json rather than fighting it file by file.
Example fix
// before
describe('UserApi', () => {
it('Returns 404 for missing user', () => { /* ... */ });
});
// after
describe('userApi', () => {
it('returns 404 for missing user', () => { /* ... */ });
}); Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json
{
"rules": {
"jest/prefer-lowercase-title": ["error", { "allowedPrefixes": ["HTTP", "GET", "POST"] }]
}
}
npx oxlint tests/ Prevention
- Write titles as lowercase predicate phrases ('returns 404 when user missing').
- Add unavoidable proper nouns/acronyms to allowedPrefixes instead of disabling the rule.
- If the team prefers capitalized titles, disable the rule globally once — not per-file.
When it happens
Trigger: A title string literal passed to a test/describe/bench call whose first alphabetic character is uppercase — e.g. `it('Returns 404', ...)` — and not exempted by the rule's configuration.
Common situations: Teams writing titles as short sentences with a capital first word; porting tests from frameworks that capitalize titles; mixing conventions after a merge. Config knobs (allowedPrefixes, ignore, ignoreTopLevelDescribe in the ESLint original / schema-driven options here) let teams carve out exceptions.
Related errors
- Mock functions that return simple values should use `mockRet
- Do not use setup or teardown hooks.
- `expect` must be inside of a test block.
- Jest tests should not return a value
- Unnecessary async function wrapper
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/1ca4bec5e01a98c7.
Report an issue: GitHub.