refactor: replace ignored numeric literals with constants
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Failing after 2m17s
Conventional commits / commits (pull_request) Successful in 31s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 1m56s

This commit is contained in:
2026-09-28 11:24:59 +03:00
parent 9b3558f96c
commit 9cc9fbdcff
60 changed files with 510 additions and 283 deletions
+16
View File
@@ -45,3 +45,19 @@ test('focused tests are rejected and generated code is excluded', async () => {
assert.ok(await eslint.isPathIgnored('generated/prisma/client.ts'));
assert.ok(await eslint.isPathIgnored('dist/src/main.js'));
});
test('numeric literals require names, including previously ignored numbers and bigints', async () => {
const literals = [-60, -24, -10, -2, -1, 0, 1, 2, 10, 24, 60].map(String);
for (const literal of [...literals, ...literals.map((value) => `${value}n`)]) {
const [inline] = await eslint.lintText(
`export function value() { return ${literal}; }`,
{ filePath: 'src/main.ts' },
);
assert.ok(inline.messages.some(({ ruleId }) => ruleId === '@typescript-eslint/no-magic-numbers'), literal);
const [named] = await eslint.lintText(
`const boundary = ${literal}; export function value() { return boundary; }`,
{ filePath: 'src/main.ts' },
);
assert.ok(!named.messages.some(({ ruleId }) => ruleId === '@typescript-eslint/no-magic-numbers'), literal);
}
});