Skip to content

Commit c455946

Browse files
a-tokyoclaude
andcommitted
fix(eslint): disable test/prefer-lowercase-title — it mangles acronyms — 0.1.3
antfu enables `test/prefer-lowercase-title`, whose autofix lowercases the first character of every describe/it title: `POST` -> `pOST`, `RLS` -> `rLS`, `Clerk` -> `clerk`. Test titles are descriptive sentences that legitimately open with acronyms and proper nouns, and no rule option preserves them (only `allowedPrefixes`, which would have to enumerate every acronym). The rule buys trivial consistency at the cost of silently corrupting meaning, so it is off for test files. Regression fixture: uppercase-opening titles must not trip it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2dfeffb commit c455946

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

‎eslint/_shared.js‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,23 @@ export function sonarReactRules() {
103103
}
104104

105105
/**
106-
* sonarjs rules that are noise in tests/fixtures/config files.
106+
* Rules that are noise in tests/fixtures/config files — the sonarjs subset plus one antfu rule.
107+
*
108+
* `test/prefer-lowercase-title` (antfu's default) lowercases the FIRST CHARACTER of every
109+
* `describe`/`it` title, and its autofix does so silently: `POST` becomes `pOST`, `RLS` becomes
110+
* `rLS`, `Clerk` becomes `clerk`. Test titles are descriptive sentences that legitimately open with
111+
* acronyms and proper nouns, and no option to the rule preserves them (only `allowedPrefixes`, which
112+
* would have to enumerate every acronym anyone might ever start a title with). The rule buys trivial
113+
* consistency at the cost of corrupting meaning, so it is off.
107114
* @param {string[]} [testGlobs]
108-
* @returns {import('eslint').Linter.Config} the tests/config sonarjs-off block.
115+
* @returns {import('eslint').Linter.Config} the tests/config rule-off block.
109116
*/
110117
export function sonarTestOff(testGlobs = DEFAULT_TEST_GLOBS) {
111118
return {
112-
name: 'zoldytech/sonar-test-off',
119+
name: 'zoldytech/test-file-overrides',
113120
files: testGlobs,
114121
rules: {
122+
'test/prefer-lowercase-title': 'off',
115123
'sonarjs/prefer-specific-assertions': 'off',
116124
'sonarjs/no-floating-point-equality': 'off',
117125
'sonarjs/no-hardcoded-passwords': 'off',

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zoldytech/javascript",
33
"type": "module",
4-
"version": "0.1.2",
4+
"version": "0.1.3",
55
"private": true,
66
"description": "Zoldytech's JavaScript/TypeScript standards: SonarQube-compatible ESLint presets (Next.js, NestJS, React+Vite, plain JS/TS) plus shared Prettier and tsconfig configs.",
77
"license": "MIT",

‎test/fixtures/plain/titles.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Uppercase-opening titles: acronyms and proper nouns that `test/prefer-lowercase-title`
2+
// would otherwise mangle (POST -> pOST, RLS -> rLS). The preset disables that rule for test
3+
// files, so these must NOT trip it.
4+
import { describe, expect, it } from 'vitest';
5+
6+
describe('POST /api/webhooks handler', () => {
7+
it('RLS confines the query to the calling tenant', () => {
8+
expect([1, 2, 3].length).toBe(3);
9+
});
10+
11+
it('Clerk session maps to the app user', () => {
12+
expect('a'.toUpperCase()).toBe('A');
13+
});
14+
});

‎test/presets.test.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ presetSuite('plain', 'clean.ts', 'dirty.ts', [
5252
'sonarjs/cognitive-complexity', // the headline SonarQube guardrail
5353
]);
5454

55+
test('plain: uppercase test titles do not trip test/prefer-lowercase-title', async () => {
56+
const result = await lintFixture('plain', 'titles.test.ts');
57+
const lowercase = result.messages.filter((m) => m.ruleId === 'test/prefer-lowercase-title');
58+
assert.equal(
59+
lowercase.length,
60+
0,
61+
`acronyms/proper nouns in test titles must survive; got:\n${detail(result)}`
62+
);
63+
});
64+
5565
presetSuite('react-vite', 'clean.tsx', 'dirty.tsx', ['no-console', 'react/exhaustive-deps']);
5666

5767
presetSuite('react-native', 'clean.tsx', 'dirty.tsx', ['no-console', 'react/exhaustive-deps']);

0 commit comments

Comments
 (0)