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

dsh-js-clean

v0.2.1

Published

DeepSeek Harness plugin: score JavaScript cleanliness and name the refactoring (Extract Function, Guard Clauses, …) for every code smell found.

Readme

dsh-js-clean

English · 中文

license: MIT node: >=20

Description

DeepSeek Harness plugin: score JavaScript cleanliness and name the refactoring (Extract Function, Guard Clauses, …) for every code smell found. The technique names and before/after examples come from xianweics/refator-code, a Chinese reading of Martin Fowler's Refactoring: Improving the Design of Existing Code.

Instead of a bare lint warning, most findings point at a catalog entry — 6.1 Extract Function, 10.3 Replace Nested Conditional with Guard Clauses, 8.8 Replace Loop with Pipeline — so an agent reading the result knows both what is wrong and how the book says to fix it.

Features

  • Cleanliness score: one number per file, graded A–E
  • Findings with advice: line, column, message, and the refactoring technique each one maps to
  • Safe fixes: only rewrites that are provably behaviour-preserving, returned as a unified diff
  • Catalog lookup: 61 refactoring techniques and 24 code smells, queryable by id, chapter, or keyword

Install

dsh plugin add dsh-js-clean

or from a checkout:

dsh plugin add /path/to/dsh-js-clean

Start a new session afterwards; the js_clean tool is registered at plugin mount.

Usage

One tool, js_clean, with four actions:

| action | result | | --- | --- | | scan | cleanliness score (A–E), every finding with line + column + advice, and the refactoring each one maps to | | fix | only rewrites that are provably behaviour-preserving; returns a unified diff, writes only with write: true and saves <file>.bak first | | explain | looks up a technique or smell (technique: "6.1" / "Extract Function" / "提炼函数") with intent, when-to-use and a code example | | catalog | lists the catalog: chapter: "10" or keyword: "conditional", otherwise everything |

{ "action": "scan", "path": "src/order.js" }
{ "action": "fix", "path": "src/order.js", "write": true }
{ "action": "explain", "technique": "6.1" }

scan also accepts code instead of path. thresholds overrides any limit (longFunctionLines, maxParams, maxComplexity, …).

Rules (22)

long function · long parameter list · deep nesting · nested ternary · complex condition · high cyclomatic complexity · magic number · long call chain · duplicate code · loop with push · flag parameter · unused variable / function / parameter · mutable module-level binding · var · let that is never reassigned · loose equality · console.* · long file · large class · commented-out code.

Score: 100 - Σ(weight × min(hits, 3)), weights error 8 / warn 5 / info 2. Grades A≥90, B≥75, C≥60, D≥40, then E.

Catalog

lib/catalog.json holds 61 refactoring techniques (6.1–6.11, 7.1–7.9, 8.1–8.9, 9.1–9.5, 10.1–10.6, 11.1–11.10, 12.1–12.11) and 24 code smells, extracted from that repository's README. Findings without a matching technique still report normally; the catalog only adds the "which refactoring" pointer.

What fix will and will not touch

Applied automatically: var → const/let, let → const, and removal of unused declarations whose initializer is side-effect free. With aggressive: true it also rewrites ==/!= to strict equality.

Deliberately skipped, with the reason in skipped:

  • a var at script top level (it is a property of the global object; rewriting changes visibility)
  • a name declared more than once, shadowing a parameter, or referenced before its declaration (var hoisting)
  • destructuring patterns, initializers that may have side effects
  • any location hit by two rules at once — the larger edit wins and the smaller one is reported as merged

Development

pnpm install
node test/analyzer.test.mjs

Only dependency is acorn. Everything else is a plain function in lib/: analyzer.mjs (parse + metrics + smells), fixes.mjs (edits + diff), knowledge.mjs (catalog queries), report.mjs (Markdown rendering), index.mjs (tool registration).

The analyzer is exported separately for reuse:

import { analyzeSource } from 'dsh-js-clean/analyzer'

const report = analyzeSource(source, { filename: 'order.js' })

License

MIT. Technique names and examples belong to the authors of xianweics/refator-code; this repository's code is MIT-licensed.