npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@serejke/eslint-plugin-pino-enforce-static-message

v0.1.0

Published

ESLint rule to enforce static log messages for Pino loggers

Readme

@serejke/eslint-plugin-pino-enforce-static-message

ESLint rule to enforce static log messages for Pino loggers. Ensures dynamic data is passed via context objects for proper log aggregation and querying.

Why?

Dynamic log messages break log aggregation tools:

// BAD - Each unique userId creates a separate log entry type
logger.info(`User ${userId} logged in`);

// GOOD - All logins group under "User logged in"
logger.info({ userId }, 'User logged in');

Installation

npm install --save-dev @serejke/eslint-plugin-pino-enforce-static-message
# or
pnpm add -D @serejke/eslint-plugin-pino-enforce-static-message

Usage

Flat Config (ESLint 9+)

// eslint.config.js
import pinoEnforceStaticMessage from '@serejke/eslint-plugin-pino-enforce-static-message';

export default [
  {
    plugins: {
      '@serejke/pino-enforce-static-message': pinoEnforceStaticMessage,
    },
    rules: {
      '@serejke/pino-enforce-static-message/enforce-static-message': 'error',
    },
  },
];

With Options

rules: {
  '@serejke/pino-enforce-static-message/enforce-static-message': ['error', {
    allowInTests: true,
    testFilePatterns: ['**/*.test.ts', '**/test/**/*.ts'],
    excludeMethods: ['child', 'flush'],
  }],
}

Rule: enforce-static-message

What it checks

  1. Static message enforcement: Log messages must be string literals
  2. Error key convention: Error objects must use err as the key name (Pino convention)

Valid

// Static message only
logger.info('Server started');

// Context object + static message
logger.info({ userId, action }, 'User action recorded');

// Error with 'err' key
logger.error({ err: error, requestId }, 'Request failed');

// Child logger (exempt from checks)
const childLogger = logger.child({ module: moduleName });

Invalid

// Template literal
logger.info(`Processing ${count} items`);
// Error: Log message must be a static string literal

// String concatenation
logger.error('Failed: ' + error.message);
// Error: Log message must be a static string literal

// Wrong key for Error
logger.error({ error: e }, 'Failed');
// Error: Use 'err' as the key name for Error objects
// Auto-fixed to: logger.error({ err: e }, 'Failed');

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | allowInTests | boolean | true | Skip rule in test files | | testFilePatterns | string[] | ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**/*.ts'] | Glob patterns for test files | | additionalMethods | string[] | [] | Additional method names to check | | excludeMethods | string[] | ['child'] | Method names to exclude from checking |

Checked Methods

By default, the rule checks these Pino log methods:

  • trace()
  • debug()
  • info()
  • warn()
  • error()
  • fatal()

Auto-fix

The rule provides auto-fix for the errorerr key rename:

// Before
logger.error({ error: e }, 'Failed');

// After auto-fix
logger.error({ err: e }, 'Failed');

License

MIT