lightsoutAlpha

bare-string-union

a string-literal union exported with no `const` object behind it

Deterministic checkadvisory by defaultbasecode

The argument

Use a union type paired with a const object

For a set of named string values, use a union type backed by a const object. The const object is the single source of truth; the union is derived from it. Consumers reference the object (Action.Add), never raw string literals.

✅ GOOD: const object + derived union

common/constants/Action.ts

export const Action = {
	Add: 'add',
	Remove: 'remove',
	List: 'list',
	Update: 'update',
} as const;

export type Action = (typeof Action)[keyof typeof Action];
// consumer — references the object, not a raw string
doThing(Action.Add);

❌ BAD: bare union, values redefined at every call site

export type Action = 'add' | 'remove' | 'list' | 'update';

// consumers retype raw literals — the source of truth is now "everywhere"
doThing('add');

The proof

failsrc/common/types/Action.ts
// No object behind it, so every caller writes `doThing('add')` and the source
// of truth becomes "everywhere".
export type Action = 'add' | 'remove' | 'list' | 'update';
passsrc/common/constants/Action.ts
export const Action = {
	Add: 'add',
	Remove: 'remove',
	List: 'list',
	Update: 'update',
} as const;

export type Action = (typeof Action)[keyof typeof Action];

Turn it down

Both lines go in your lightsout.config.json.

"standards-checks": { "bare-string-union": "advisory" }
"standards-checks": { "bare-string-union": "off" }