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-jenkinsfile

v0.3.0

Published

Prettier plugin for Jenkins Declarative Pipeline files using tree-sitter-groovy

Downloads

48

Readme

prettier-plugin-jenkinsfile

A Prettier plugin for formatting Jenkins Declarative Pipeline files (Jenkinsfile) and Groovy files.

Uses a forked tree-sitter-groovy (extended from murtaza64/tree-sitter-groovy) for parsing, producing AST-aware formatting that understands Groovy's named parameter syntax and Jenkins DSL patterns.

Features

  • terraform(), ansible(), and tofu* calls always expand named arguments one per line with trailing commas
  • Short single-statement closures kept inline (e.g. retry(3) { sh 'make' })
  • Multi-statement closures expanded to block format
  • Triple-quoted strings (YAML pod specs) preserved verbatim
  • Proper 2-space indentation throughout
  • Jenkins DSL blocks (pipeline, stages, stage, steps, agent, dir, when, etc.) always kept in block form

Installation

npm install --save-dev prettier-plugin-jenkinsfile

Usage

# Format a Jenkinsfile
npx prettier --write Jenkinsfile

# Format all Jenkinsfiles in a directory
npx prettier --write '**/Jenkinsfile'

# Check formatting (CI mode)
npx prettier --check Jenkinsfile

The plugin automatically detects files named Jenkinsfile and files with .groovy or .gradle extensions.

Pre-commit / prek hook

This repo ships a pre-commit hook (also compatible with prek). Add it to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/bootswithdefer/prettier-plugin-jenkinsfile
    rev: v0.1.2
    hooks:
      - id: jenkinsfile-fmt

The hook formats files named Jenkinsfile and files with .groovy or .gradle extensions on commit. It runs Prettier with this plugin in an isolated Node environment managed by pre-commit — no Node project or global install required.

Example

Before:

#!groovy
def appName = 'my-service'
pipeline {
  agent { label 'linux' }
  stages {
    stage('deploy') {
      steps {
        script {
          terraform(workspace: 'production', auto_approve: true)
          retry(3) {
            sh './deploy.sh'
          }
        }
      }
    }
  }
}

After:

#!groovy
def appName = 'my-service'
pipeline {
  agent {
    label 'linux'
  }
  stages {
    stage('deploy') {
      steps {
        script {
          terraform(
            workspace: 'production',
            auto_approve: true,
          )
          retry(3) { sh './deploy.sh' }
        }
      }
    }
  }
}

Configuration

This plugin uses Prettier's standard configuration. Relevant options:

| Option | Default | Description | |--------|---------|-------------| | tabWidth | 2 | Indentation width | | printWidth | 80 | Line width for inline/expand decisions |

How It Works

  1. Parses the file using tree-sitter-groovy (via WebAssembly)
  2. Walks the concrete syntax tree (CST)
  3. Emits Prettier's intermediate representation (doc IR)
  4. Prettier handles line-breaking, indentation, and output

The plugin bundles a pre-compiled tree-sitter-groovy.wasm — no native dependencies required.

Limitations

  • Does not format arbitrary Groovy (class definitions, complex expressions). Focused on Jenkins Pipeline DSL patterns.
  • Comments attached to the end of a line may move to the next line.
  • The parser handles most Declarative Pipeline patterns but may not parse highly unusual Scripted Pipeline code.

License

MIT