Skip to content

unlisted-marker ​

A // @safe-ts std or // @safe-ts legacy marker in a file the project's package.json doesn't list: "safe-ts": { "trustedFiles": [...] } for std, "legacyFiles": [...] for legacy. On by default, as an error.

Why: one comment turns the rules off for a whole file (and std makes its functions count as never failing, for their callers too). Anyone can write a comment; the list says who may, and it is in package.json, where a change is reviewed. A marker in a file the list doesn't name gains nothing: the file is checked as if the marker weren't there, and the marker is reported.

❌ Rejected: a marker package.json doesn't list

ts
// @safe-ts std
type Settings = { readonly theme: string };

export function settingsOf(value: unknown): Settings {
  return value as Settings;
}

✅ Accepted: the value is checked, so the file needs no marker

✓ Accepted0 diagnostics
ts
import { type JsonError, parseJson } from "@evobug_com/safe-ts-std/json";
import type { Result } from "@evobug_com/safe-ts-std/result";

type Settings = { readonly theme: string };

export function decode(text: string): Result<Settings, JsonError> {
  return parseJson<Settings>(text);
}
ts
import { parseJsonWith as __jsonParse, validateWith as __jsonValidate, jsonFail as __jsonFail, isJsonErr as __jsonIsErr, isJsonObject as __jsonIsObject, type JsonResult as __JsonResult } from "@evobug_com/safe-ts-std/json"; import { type JsonError, parseJson } from "@evobug_com/safe-ts-std/json";
import type { Result } from "@evobug_com/safe-ts-std/result";

type Settings = { readonly theme: string };

export function decode(text: string): Result<Settings, JsonError> {
  return __jsonParse<Settings>(text, __v0);
}
// ---- generated by safe-ts: JSON validators ----
type __T0 = { "theme": string; };
function __v0(v: unknown, p: string): __JsonResult<__T0> {
  if (!__jsonIsObject(v)) return __jsonFail(p, "object", v);
  const __j1 = v["theme"];
  if (typeof __j1 !== "string") return __jsonFail(p + ".theme", "string", __j1);
  const __j2 = __j1;
  const out: { "theme": string; } = { "theme": __j2 };
  return out;
}

✅ Also accepted: a reviewed exception, listed in package.json

json
{
  "safe-ts": {
    "trustedFiles": ["src/protocol/trusted.ts"],
    "legacyFiles": ["src/old/**"]
  }
}

The patterns are those of "overrides", relative to the package.json: * within a directory, ** across them, {a,b} either, and a pattern without a / matches the file name anywhere. The list says where a marker is allowed and the marker says which files use it, so both stay. Listed files are counted in the escape-hatch line (N legacy file(s), N std file(s) with their names), and a baseline fails when either count rises.

Upgrading a project with many markers ​

safe-ts check prints, for each package.json, the lines to put in its "safe-ts" field: what it lists already, with every file that carries an unlisted marker added.

3 files carry a `// @safe-ts std` or `// @safe-ts legacy` marker package.json doesn't list, so the marker is ignored. If they are reviewed, put these in its "safe-ts" field:
  "trustedFiles": ["src/protocol/trusted.ts"],
  "legacyFiles": ["src/old/api.ts","src/old/forms.ts"]

Which package.json ​

The nearest one above the file with a "safe-ts" field, as for "rules" and "overrides": in a monorepo, each package's own, or the root's for packages without one. The editor, the oxlint plugin, the Vite plugin and the Node loader read the same one as safe-ts check (they all go through the same analysis): an unlisted legacy file gets the transform's full rewrites and dev checks, like any checked file.

Code in node_modules keeps its markers: the project doesn't check or report library code, and its package decides how it is written (std's own files are // @safe-ts std, and its package.json lists them).

What the rule can't see ​

  • Whether a listed file deserves its marker. The list is for review; the counts are for the ratchet.
  • A pattern broader than the files that use it ("legacyFiles": ["**"]) allows the marker in files written later. The count of legacy and std files still rises when one is added.

Guide: Escape hatches.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra