lightsoutAlpha

single-use-scalar

a module-scope scalar constant only one place reads

Deterministic checkadvisory by defaultbasecode

The argument

Don't Hoist Single-Use Scalars

Don't hoist single-use scalars to module scope or a constants file. A value used by one function and not a lookup map is declared inline — const maxRetries = 10; inside the function, not const MAX_RETRIES = 10; at module scope. Promote to a module-level constant (or constants/) only when it's consumed in 2+ places, or it's a lookup map / structured config.

The proof

failsrc/billing/chargeInvoice.ts
const maxRetries = 10;

// A folded number names a value the same way a bare literal does.
const retryWindowMs = 10 * 60_000;

export const chargeInvoice = ({ attempt, elapsedMs }: { attempt: number; elapsedMs: number }): boolean => attempt < maxRetries && elapsedMs < retryWindowMs;
pass
// Genuinely computed — it has a moving part (an identifier), so it is not a
// folded number, however many places read it.
const startedAt = Date.now();

// A folded number read in two places has earned its module scope.
const graceWindowMs = 5 * 60_000;

const isWithinGrace = ({ elapsedMs }: { elapsedMs: number }) => elapsedMs < graceWindowMs;

export const buildReceipt = ({ elapsedMs }: { elapsedMs: number }): string =>
	`started ${startedAt}, grace ${graceWindowMs}, within: ${isWithinGrace({ elapsedMs })}`;

Turn it down

Both lines go in your lightsout.config.json.

"standards-checks": { "single-use-scalar": "advisory" }
"standards-checks": { "single-use-scalar": "off" }