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

prettier-plugin-sieve

v0.3.0

Published

Prettier plugin for Sieve email filtering scripts (RFC 5228)

Readme

prettier-plugin-sieve

A Prettier plugin for formatting Sieve email filtering scripts (RFC 5228).

Features

  • Formats .sieve / .siv files via Prettier
  • Hand-rolled Peggy.js PEG grammar for RFC 5228 core language
  • Supports: require, if/elsif/else, all standard tests (address, header, envelope, allof, anyof, not, size, exists, true, false), all standard actions (fileinto, redirect, keep, discard, stop, reject, vacation, addflag, setflag, removeflag)
  • Idempotent — formatting twice gives the same result
  • Works with Prettier 3.x
  • IntelliJ IDEA + VS Code Prettier extension compatible

Installation

npm install --save-dev prettier prettier-plugin-sieve

Configuration

.prettierrc

{
  "plugins": ["prettier-plugin-sieve"]
}

VS Code (settings.json)

{
  "prettier.documentSelectors": ["**/*.sieve", "**/*.siv"],
  "[sieve]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true
  }
}

IntelliJ IDEA

Go to Settings → Languages & Frameworks → JavaScript → Prettier:

  • Enable "Run on save"
  • Add **/*.sieve to the "Run for files" glob

Usage

# Format all .sieve files
npx prettier --write "**/*.sieve"

# Check formatting without writing
npx prettier --check "**/*.sieve"

Example

Input (messy):

require ["fileinto","reject","vacation"];
if anyof(header :contains "Subject" "URGENT",address :is "From" "[email protected]"){fileinto "Priority";}
elsif header:contains "Subject" "[SPAM]"{discard;}
else{keep;}

Output (formatted):

require ["fileinto", "reject", "vacation"];
if anyof (
  header :contains "Subject" "URGENT",
  address :is "From" "[email protected]"
) {
  fileinto "Priority";
} elsif header :contains "Subject" "[SPAM]" {
  discard;
} else {
  keep;
}

Project Structure

prettier-plugin-sieve/
├── src/
│   ├── index.ts               # Plugin entry: languages, parsers, printers
│   ├── types.ts               # Full TypeScript AST node interfaces
│   ├── printer.ts             # Prettier Doc builder / printer
│   └── parser/
│       ├── index.ts           # parse(), locStart(), locEnd() exports
│       └── sieve.pegjs        # Peggy PEG grammar for RFC 5228
├── tests/
│   └── format.test.ts         # Jest end-to-end formatting tests
├── package.json
└── tsconfig.json

Architecture

1 · Grammar (src/parser/sieve.pegjs)

A Peggy PEG grammar that directly encodes RFC 5228 syntax. Each grammar rule returns a typed AST node with a loc (source location) property. The grammar is compiled at runtime the first time parse() is called (or can be pre-compiled via npm run generate-parser for production builds).

2 · Parser adapter (src/parser/index.ts)

Wraps Peggy's parse() to:

  • Return a Script root node
  • Expose locStart / locEnd so Prettier can attach comments
  • Surface grammar errors with human-readable messages

3 · Printer (src/printer.ts)

Converts the Sieve AST into Prettier's Doc IR using the doc.builders API:

| Doc primitive | Where used | | ------------- | -------------------------------------------------------------------- | | hardline | Between top-level commands and block contents | | softline | Inside string lists, test argument lists | | group | All commands and tests — allows line-breaking when over printWidth | | indent | Block bodies, multi-line list arguments | | join | Comma-separated string lists and test lists |

Building

# Compile TypeScript → dist/
npm run build

# Optionally pre-compile the Peggy grammar to JS for faster startup
npm run generate-parser

Testing

npm test

Extending

To add support for Sieve extensions (e.g. RFC 5232 sieve-imap-flags, RFC 5230 vacation):

  1. Add new rules to src/parser/sieve.pegjs
  2. Add new AST interfaces to src/types.ts
  3. Add case branches to printAction / printTest in src/printer.ts

License

MIT