Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ The Vue layer registers the single-file-component parser, resolves `<script lang
parser, and requires PascalCase component filenames (`UserCard.vue`). It also carries the template layout rules, set to
a four-space indent, because Biome cannot format `.vue` markup. To match, the shared Biome config accepts PascalCase as
well as kebab-case under any `components/` directory, so a component's tests and stories can share its name
(`UserCard.test.ts`).
(`UserCard.test.ts`). Its identifier naming accepts consecutive capitals, so a component whose name opens with an
acronym or a one-letter prefix (`UIButton`) is imported under that name.

Through Qlty, enable the eslint plugin on your `package.json`. Its sandbox installs only `eslint`, `jest` and
`prettier` from that file by default, so widen the filter or the config's imports fail to resolve:
Expand Down
37 changes: 28 additions & 9 deletions js/__tests__/biome.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Tests for the shared Biome config's filename convention, run through the
* Biome version the README has consumers pin.
* Tests for the shared Biome config's filename and identifier conventions, run
* through the Biome version the README has consumers pin.
*
* @author Ben Carey <bdmc@sinemacula.co.uk>
* @copyright 2026 Sine Macula Limited
Expand Down Expand Up @@ -28,17 +28,25 @@ afterAll(() => {
rmSync(consumer, { recursive: true, force: true });
});

/** The filename diagnostics Biome reports for a file at the given path. */
function filenameDiagnostics(path) {
/** The diagnostics of one rule that Biome reports for a file with the given path and source. */
function diagnostics(rule, path, source) {
mkdirSync(dirname(join(consumer, path)), { recursive: true });
writeFileSync(join(consumer, path), 'export const value = 1;\n');
writeFileSync(join(consumer, path), source);

// The rule only warns, so Biome exits cleanly either way.
// The rules only warn, so Biome exits cleanly either way.
const output = execFileSync(BIOME, ['lint', '--reporter=rdjson', path], { cwd: consumer, encoding: 'utf8' });

return JSON.parse(output).diagnostics.filter(
diagnostic => diagnostic.code.value === 'lint/style/useFilenamingConvention',
);
return JSON.parse(output).diagnostics.filter(diagnostic => diagnostic.code.value === `lint/style/${rule}`);
}

/** The filename diagnostics Biome reports for a file at the given path. */
function filenameDiagnostics(path) {
return diagnostics('useFilenamingConvention', path, 'export const value = 1;\n');
}

/** The identifier naming diagnostics Biome reports for the given source. */
function namingDiagnostics(source) {
return diagnostics('useNamingConvention', 'src/naming.ts', source);
}

describe('filenames', () => {
Expand Down Expand Up @@ -69,3 +77,14 @@ describe('filenames', () => {
}
});
});

describe('identifiers', () => {
it('accepts consecutive capitals', () => {
expect(namingDiagnostics("import UIButton from './ui-button.js';\n\nexport { UIButton };\n")).toEqual([]);
expect(namingDiagnostics('export function parseJSON() {}\n')).toEqual([]);
});

it('still rejects other casings', () => {
expect(namingDiagnostics('export const user_name = 1;\n')).toHaveLength(1);
});
});
1 change: 1 addition & 0 deletions js/biome.shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"useNamingConvention": {
"level": "warn",
"options": {
"strictCase": false,
"conventions": [
{
"selector": { "kind": "objectLiteralProperty" },
Expand Down
Loading