Skip to content
Esc

@noctcore/eslint-plugin-observability

v1.0.04 rules3 recommended1 opt-innamespace noctcore-observability

A bad fit if you log through console by design, or your logger has no way to carry a context object, because the fix every rule asks for is to move values out of the message and into one.

Structured logging discipline: context objects, no sensitive fields, no lost error detail, declared PII in audit payloads.

Logs are an interface that nobody type-checks. An interpolated message string cannot be queried, a log call that includes password or token is an incident, and a catch block that logs only e.message throws away the stack and cause you needed.

It will yell at you about how you call your logger: a static message plus a context object, never a template literal with values in it. The sensitive-field and PII rules match on names, so they catch user.password but not a secret hiding in a field called data. The rules recognise <logger>.info/warn/error/debug(...) calls on logger names you configure through loggers. It is a bad fit if you log through console by design, or your logger has no way to carry a context object, because the fix every rule asks for is to move values out of the message and into one.

Install
npm install --save-dev @noctcore/eslint-plugin-observability @typescript-eslint/parser
# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-observability @typescript-eslint/parser

The recommended preset enables 3 of 4 rules. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.

Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first read is structured-log-arguments.

3 of 4 at error

--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.

audit-pii-declared
A PII-shaped key written into an audit payload must be declared, either registered for scrubbing on purge or declared non-PII.
Needs options
opt-in
no-error-detail-loss
A catch block that reports a failure must not reduce the error to only e.message / String(e) / ${e} — log the error itself so its stack and cause survive.
recommended
no-sensitive-fields-in-logs
A logger call must not reference an identifier, property, or object key whose name matches a sensitive-field denylist (password, token, secret, ...). Redact it before logging.
recommended
structured-log-arguments
A logger call must not interpolate dynamic values into the message string (a template literal with expressions). Pass a static message and a structured context object instead.
recommended