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

@nejs/styler

v0.1.0

Published

An AST-safe JavaScript styler that applies a small, opinionated, configurable rule set — built for people who don't want one-true-brace.

Downloads

77

Readme

@nejs/styler

An AST-safe JavaScript styler that applies a small, opinionated, configurable rule set — built for people who want their code formatted to a real style guide, not the One True Brace defaults that Prettier and JSLint locked in.

@nejs/styler parses your source with acorn, applies a focused set of transformations through magic-string, and never reflows code it doesn't recognize. Run it locally to read code in your preferred style, even if the upstream repo uses a different formatter — your upstream's formatter will move it back the next time anyone touches the file.

Installation

npm install -g @nejs/styler
# or, project-local:
npm install --save-dev @nejs/styler

Usage

nejs-styler format src/                # rewrite files in place
nejs-styler check  src/                # exit non-zero if any file would change
nejs-styler diff   src/foo.mjs | less  # print a diff; never write
nejs-styler explain braces             # show a rule's docs
nejs-styler list                       # list every registered rule

File arguments may be paths to .mjs, .js, or .cjs files, or directories (recursive). node_modules and dot-directories are skipped automatically.

Rules

| Rule | What it does | |---|---| | jsdoc | Strips the - separator between a @param name and its description. Collapses column-aligned padding. Inserts a blank gutter line before @returns / @throws / @example. | | semicolons | Removes trailing statement semicolons. Keeps class-field declarations (#x;), for headers, and inter-statement separators on the same line (a(); b();). | | braces | Drops curly braces around control-flow bodies whose body is a single statement — even when that statement spans many lines (e.g. a return whose argument is a multi-line object literal). catch and finally always keep their braces because JS requires it. | | oneline-if-split | Splits if (cond) statement (and same-line for / while) into two lines: head on its own line, body indented underneath. | | vertical-spacing | Inserts a blank line between sibling statements when one or both is a control-flow statement (if / for / while / try / switch). Existing blank lines are preserved. |

Run nejs-styler explain <rule> to see each rule's full description.

What it doesn't touch

  • Generic indentation, line wrapping, quote normalization, trailing commas — that's prettier's domain, and it does it well.
  • Files it can't parse — a parse failure is reported as an error and the file is returned unchanged.

Example

Before:

/**
 * @param {string} name - The user's name.
 * @returns {string}
 */
function greet(name) {
  if (!name) {
    return 'hello, friend';
  }
  if (name === 'Brielle') {
    return 'hey there, captain';
  }
  return `hello, ${name}`;
}

After nejs-styler format:

/**
 * @param {string} name The user's name.
 *
 * @returns {string}
 */
function greet(name) {
  if (!name)
    return 'hello, friend'

  if (name === 'Brielle')
    return 'hey there, captain'

  return `hello, ${name}`
}

Configuration

Drop a .nejs-styler.json at your project root to tweak behavior:

{
  "indent": 2,
  "lineWidth": 80,
  "rules": {
    "vertical-spacing": "off"
  }
}

Per-rule values:

  • "off" — disable the rule entirely
  • object — pass rule-specific options (each rule documents what it accepts)

If no config file exists, the defaults match the rule table above.

Programmatic API

import { format, check, diff } from '@nejs/styler'

const result = format(sourceCode)
// { output, changed, results: [{ rule, edits, skipped, error? }] }

const status = check(sourceCode)
// { ok, results }

const dr = diff(sourceCode)
// { diff, changed, results }

Why?

I have a code style I like, that I write by hand, that doesn't match any of the popular formatter defaults. Prettier and JSLint both went the "no configuration, accept our defaults" route on purpose — fine for teams that don't care, painful when you do.

@nejs/styler is small enough (one parser, one transform helper, a handful of rule files) that I can read every line of it, extend it, and trust it on my own code. It runs against any JS file but doesn't try to be Prettier — it does the few things Prettier won't, and nothing else. Run it locally; let your upstream's formatter undo it.

License

MIT