No top-level side effects

Rule

Importing a module must not do anything observable. At top level, only declare functions, classes, types and constants built from literals. Do not log, read the environment, start timers, register globals, or modify built-in prototypes. Create state inside functions the caller invokes.

Do

const DEFAULT_K1 = 1.2;
const DEFAULT_B = 0.75;
 
export interface Bm25Params {
  readonly k1: number;
  readonly b: number;
}
 
export function defaultParams(): Bm25Params {
  return { k1: DEFAULT_K1, b: DEFAULT_B };
}

Don’t

const cache = new Map<string, number>();
Reflect.set(globalThis, 'bm25Cache', cache);
console.log('bm25 loaded');
 
export function cached(term: string): number | undefined {
  return cache.get(term);
}

Rationale

The manifest declares "sideEffects": false, which tells bundlers they may drop any unused module. A module with top-level effects then behaves differently depending on what the consumer imports. Shared module-level state also leaks between consumers that load the library twice.