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

selo-solid

v0.1.0

Published

selo rule pack: SOLID-alike rules (SRP file/function/params/depth/statements/complexity/class-methods, OCP no-type-discriminating-switch). For the linter, see @guilhermesilveira/selo.

Downloads

130

Readme

selo-solid

A selo rule pack with SOLID-alike rules. Use with @guilhermesilveira/selo.

Rules

| Rule id | Type | Default unit | What it caps | |---|---|---|---| | srp/max-file-lines | threshold | lines | source lines per file | | srp/max-function-lines | threshold | lines/fn | source lines per function | | srp/max-params | threshold | params/fn | parameters per function | | srp/max-depth | threshold | depth/fn | max nesting depth per function | | srp/max-statements-per-function | threshold | stmts/fn | top-level statements per function | | srp/max-cyclomatic-complexity | threshold | CC/fn | McCabe cyclomatic complexity per function | | srp/max-class-methods | threshold | methods | MethodDefinition count per class | | isp/max-interface-members | threshold | members | TSPropertySignature + TSMethodSignature count per interface (and per TSTypeLiteral) | | ocp/no-type-discriminating-switch | count | dispatches | switch / if-else-if chains over a single discriminator (kind/type/__typename/tag) |

Each rule's seal message names the unit value and the next refactor — never the bare "too many X."

Install

npm install --save-dev @guilhermesilveira/selo selo-solid

Use

In selo.config.mjs:

import solid from 'selo-solid';

export default {
  packs: [solid],
  rules: {
    'srp/max-file-lines':              { goal: 800 },
    'srp/max-function-lines':          { goal: 80 },
    'srp/max-params':                  { goal: 4 },
    'srp/max-depth':                   { goal: 4 },
    'srp/max-statements-per-function': { goal: 30 },
    'srp/max-cyclomatic-complexity':   { goal: 15 },
    'srp/max-class-methods':           { goal: 10 },
    'isp/max-interface-members':       { goal: 10 },
    'ocp/no-type-discriminating-switch': {},
  },
};

Then npx selo check (see the selo README for the full workflow).

OCP exemptions

The OCP rule sometimes fires on legacy code you can't refactor immediately. Exempt those files at the project level:

'ocp/no-type-discriminating-switch': {
  exempt: ['lib/legacy-dispatcher.ts', 'ui/old/Page.tsx'],
},

Paths are project-relative. The list is meant to be temporary — refactor and remove.

Layout

src/
  index.ts                     pack export (default + named rule exports)
  lib/walk.ts                  AST walker, function-name lookup, FN_TYPES
  rules/srpMaxFileLines.ts
  rules/srpMaxFunctionLines.ts
  rules/srpMaxParams.ts
  rules/srpMaxDepth.ts
  rules/srpMaxStatementsPerFunction.ts
  rules/srpMaxCyclomaticComplexity.ts
  rules/srpMaxClassMethods.ts
  rules/ispMaxInterfaceMembers.ts
  rules/ocpNoTypeDiscriminatingSwitch.ts
tests/
  helpers.ts                   fixtureFile() — parse + set parents
  *.test.ts                    one focused test per rule

Adding a rule

  1. New file under src/rules/ exporting a SeloRule object. Use walkAst/walkAstSkip from lib/walk.js. Skip descent at nested function nodes if the measurement is per-function.
  2. Add to src/index.ts's rules map under its meta.id.
  3. Test under tests/<name>.test.ts using fixtureFile() to build a SeloFile.

Releasing

Manual SemVer release flow. See @guilhermesilveira/selo's release notes for the engine-releases-first ordering — when @guilhermesilveira/selo's contract changes, the engine ships first, then this pack bumps its peer range and follows.

# 1. Move [Unreleased] in CHANGELOG.md under a new
#    `## [<version>] — YYYY-MM-DD` heading.
# 2. If the engine bumped, update peerDependencies."@guilhermesilveira/selo"
#    in package.json.
# 3. npm version patch        # 0.0.1 → 0.0.2 (or `minor` / `major`)
# 4. git push --follow-tags
# 5. npm publish               # one-time `npm login` first

The prepublishOnly script gates publishing on a clean build + tests + lint, so a broken state can't ship.


What is not in this pack

  • srp/no-identical-functions and srp/max-cognitive-complexity rely on SonarJS's algorithms. They live in selo-eslint-raiz (the shim pack) where the wrapping mechanism handles them.