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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rslint-staged

v0.0.15

Published

Run linters on git staged files in Rust

Downloads

42

Readme

rslint-staged

A Rust-based tool for running linters on Git staged files like lint-staged.

Support npm, yarn, pnpm etc.

npm

Introduction

rslint-staged allows you to run lint tools only on files in the Git staging area, rather than checking the entire codebase, thereby speeding up the development process. This tool is written in Rust and provided as a Node.js module, offering higher performance and resource efficiency.

Performance

Performance tests conducted with 22 JavaScript files in the Git staging area.

hyperfine --warmup 5    'npm run lint-staged'   'npm run rslint-staged' 
hyperfine --warmup 5   'npm run rslint-staged'  'npm run lint-staged' 

Features

  • Run lint tools only on Git staged files
  • Support for multiple configuration formats (JSON, TOML, YAML, etc.)
  • High-performance Rust implementation with Node.js integration
  • Support for custom working directories
  • Parallel execution of multiple lint tasks
  • Cross-platform compatible binary
  • Automatically executes commands from package.json's lint-staged configuration

Installation

Global Installation (Recommended)

npm install -g rslint-staged

Local Installation

npm install rslint-staged --save-dev

Installation with yarn

yarn add -D rslint-staged

Installation with pnpm

pnpm add -D rslint-staged

Note: During installation, the package will attempt to compile a native binary for your platform. This requires:

  • Rust toolchain to be installed on your system (https://www.rust-lang.org/tools/install)
  • Node.js build tools

If you encounter any issues during installation, you can try adding the --ignore-scripts flag, but note that you'll need to manually compile the binary afterward.

Usage

Command Line Usage

After global installation, you can use it directly from the command line:

rslint-staged

With local installation, add a script to your package.json:

{
  "scripts": {
    "lint-staged": "rslint-staged"
  }
}

Then run:

npm run lint-staged

Configuration (in package.json)

Configure your linting tasks in package.json's lint-staged section:

{
  "scripts": {
    "lint-staged": "rslint-staged"
  },
  "lint-staged": {
    "*.js": ["eslint --fix", "prettier --write", "git add"],
    "*.ts": ["tsc --noEmit", "eslint --fix"],
    "*.css": ["stylelint --fix"]
  }
}

The Rust implementation of rslint-staged will:

  1. Identify files in the Git staging area
  2. Read the lint-staged configuration from package.json
  3. Apply the specified commands to matching files
  4. Report success or failure based on the command results

Integration with Husky

Integrate with husky to run automatically before each commit:

# Install husky
npm install -D husky

# Initialize husky (if not already done)
npx husky install

# Add pre-commit hook : husky - add command is DEPRECATED
# npx husky add .husky/pre-commit "npx rslint-staged"
echo "npm lint-staged" > .husky/pre-commit

API Usage

const { lintStaged } = require('rslint-staged');

// Async execution
async function run() {
  const passed = await lintStaged({
    cwd: process.cwd(),
    configPath: './custom-config.json'
  });
  
  if (passed) {
    console.log('All lint checks passed!');
  } else {
    console.log('Lint checks failed');
  }
}

run();

Configuration Options

rslint-staged supports the following configuration options:

  • cwd: Working directory path
  • configPath: Custom configuration file path
  • verbose: Whether to output detailed logs
  • concurrent: Whether to run tasks in parallel

Development

Building the project

# Install dependencies
npm install

# Build Rust library
npm run build

Manual Compilation

If you need to manually compile the binary:

# Install Rust if you haven't already
# Visit https://www.rust-lang.org/tools/install

# Clone the repository
git clone https://github.com/[author]/rslint-staged.git
cd rslint-staged

# Install dependencies
npm install

# Build the binary
npm run build

The build process will create a single rslint-staged.node file that is compatible with your current platform.

Testing

npm test

Troubleshooting

"rslint-staged is not recognized as an internal or external command" Error

If you encounter this error on Windows, try the following methods:

  1. Ensure global installation: npm install -g rslint-staged
  2. Or use npx to run: npx rslint-staged
  3. Or add to package.json scripts: "lint-staged": "rslint-staged", then run npm run lint-staged

Binary File Loading Failure

If the binary file fails to load, it may be because:

  1. The compilation process during installation failed
  2. You're missing the Rust toolchain

To fix this:

  1. Install Rust: https://www.rust-lang.org/tools/install
  2. Manually compile by running: npm run build in the package directory

License

MIT