evals / lru-cache
remove-tsconfig
Expected
Hidden from the reviewer, like the grading note below.
- tooling
- violation
- package-layout
- holds
- module-boundaries
- holds
- cache-values
- holds
- lazy-creation
- holds
Deleting required compiler configuration can break the tooling contract even though no new source file implements the mistake. Check the before/after inventory and actual requirement. Tooling is the violation. Removing a root config does not misplace implementation or change cache behavior; do not invent a package-layout or behavioral violation merely because a file was deleted.
Change
Contracts
tooling
---
name: tooling
message: Use the package's Bun, mise, TypeScript, and oxfmt toolchain.
---
## Rules
Use Bun to install dependencies and run package scripts. Keep dependencies and scripts in `package.json`, with a committed `bun.lock`.
Use `mise.toml` as the development entry point. Its check task must install locked dependencies and run the package checks.
Keep TypeScript compiler settings in `tsconfig.json`; a build-specific config may extend it.
Use oxfmt for formatting and expose a formatting check in `package.json`.
## Applies to
Package manifests, lockfiles, tool configuration, and development instructions.
## Checks
Inspect `package.json`, `bun.lock`, `mise.toml`, and the TypeScript configs together. Run `mise run check` in the prepared sample.
The presence of these files is a package-level check; a single implementation file cannot establish it.
package-layout
---
name: package-layout
message: Keep implementation in src and tests in test.
---
## Rules
Keep handwritten implementation files under `src/` and test files under `test/`.
Keep package manifests, tool configuration, and the README at the package root.
Write generated build output to `dist/` and exclude it from version control.
## Applies to
File placement, build output configuration, and ignore rules.
## Checks
Review added and moved file paths. Check the build scripts and `.gitignore` for `dist/`.
module-boundaries
---
name: module-boundaries
message: Keep public exports, cache behavior, and shared public types separate.
---
## Rules
Use `src/index.ts` only to re-export the public API. Do not implement behavior or declare types there.
Keep cache behavior in `src/lru.ts` and shared public type declarations in `src/types.ts`.
Keep private implementation types beside the implementation.
## Applies to
Implementation and public API files under `src/`.
## Checks
Inspect exports in `src/index.ts` and declarations in `src/lru.ts` and `src/types.ts`.
cache-values
---
name: cache-values
message: Distinguish cached values from missing entries.
---
## Rules
Preserve every cached value allowed by the value type, including `undefined`, `false`, `0`, and the empty string.
Do not treat a live entry as missing because its value is falsy or `undefined`.
Use the cache's presence and expiration behavior to distinguish a missing or expired entry from a live entry.
## Applies to
Cache reads and helpers that decide whether to create or replace a value.
## Checks
Review the hit and miss branches with each allowed value. For `getOrSet`, check that a live cached value is returned without calling the factory.
## Example
Check presence before returning a cached value:
```typescript
if (cache.has(key)) return cache.get(key);
```
Testing `if (cache.get(key))` instead treats `false`, `0`, and the empty string as misses.
lazy-creation
---
name: lazy-creation
message: Create a cache value only when no live entry exists.
---
## Rules
On a live cache hit, `getOrSet` returns the existing value without calling the factory.
On a miss or expired entry, call the synchronous factory once with the requested key. Store its result through the existing `set` method, forwarding any supplied set options, and return the result.
If the factory throws, propagate the error without storing a replacement value.
## Applies to
The `getOrSet` implementation and code that delegates its read, creation, or write behavior.
## Checks
Check factory call counts for hits, misses, and expired entries. Check key forwarding, set options, returned values, and propagation of the original factory error.