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 packages/oxlint-config/function-verb.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function isVerbMatch(name, verb, bareAllowed) {
return bareAllowed;
}

return name.startsWith(verb) && /[A-Z]/u.test(name.charAt(verb.length));
// a digit also ends the verb: acronyms like 2FA start camelCase segments
return name.startsWith(verb) && /[A-Z0-9]/u.test(name.charAt(verb.length));
}

function findAllowedVerb(name, verbs) {
Expand Down
24 changes: 24 additions & 0 deletions packages/oxlint-config/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ test('it matches a verb only at a camelCase boundary', async () => {
expect(result.exitCode).toBe(1);
});

test('it accepts a digit as the boundary after a verb', async () => {
const source = [
'export function run2FA(): void {}',
'',
'export function get2FAVerificationURI(): string {',
" return '';",
'}',
'',
].join('\n');

const result = await runLint(source, false, { 'zgeoff/function-verb': 'error' });

expect(result.exitCode).toBe(0);
});

test('it flags a banned verb at a digit boundary', async () => {
const source = 'export function save2FABackupCodes(): void {}\n';

const result = await runLint(source, false, { 'zgeoff/function-verb': 'error' });

expect(result.exitCode).toBe(1);
expect(result.stdout).toInclude("banned verb 'save'");
});

test('it skips PascalCase names, object-literal properties, getters, and setters', async () => {
const source = [
'export function Component(): null {',
Expand Down