Rush Lint-Staged Plugin

raw JSON →
0.2.2 verified Fri May 01 auth: no javascript

A Rush.js plugin that integrates lint-staged into Rush monorepos, enabling per-project lint-staged configurations via the multi-config feature introduced in lint-staged >=12.2.1. Current stable version: 0.2.2. Released as part of TikTok's rush-plugins, with no fixed schedule. Key differentiator: automatically matches staged files to the nearest .lintstagedrc file in the monorepo, correcting working directories for tasks. Requires Rush >=5.57.0 and Node >=12.

error Rush: Plugin 'rush-lint-staged-plugin' is not found.
cause The plugin is not registered in rush-plugins.json or the version is incorrect.
fix
Add the plugin entry to common/config/rush/plugins.json with the correct name and version.
error Error: ENOENT: no such file or directory, open '.lintstagedrc'
cause No lint-staged configuration found for a staged file.
fix
Ensure a .lintstagedrc file exists in the project root or add a placeholder at monorepo root.
error lint-staged requires a minimum of Node.js 12
cause Node.js version is too old.
fix
Upgrade Node.js to version 12 or later.
gotcha Requires a placeholder .lintstagedrc.json at monorepo root to avoid lint-staged misbehavior when only one config file exists.
fix Add a .lintstagedrc.json file at the root with content: { "*": "echo ok" }.
breaking Rush >=5.57.0 is required; older versions do not support the Rush plugin system.
fix Upgrade Rush to version 5.57.0 or later.
deprecated The plugin uses lint-staged's multi-config feature, which requires lint-staged >=12.2.1.
fix Ensure lint-staged is at version 12.2.1 or later in your projects.
npm install rush-lint-staged-plugin
yarn add rush-lint-staged-plugin
pnpm add rush-lint-staged-plugin

Shows how to enable the Rush plugin, set up a pre-commit hook, add a placeholder config, and run lint-staged via Rush.

# Enable the plugin in rush-plugins.json:
# {
#   "plugins": [
#     {
#       "name": "rush-lint-staged-plugin",
#       "version": "0.2.2"
#     }
#   ]
# }

# Add a pre-commit hook (common/git-hooks/pre-commit):
#!/bin/sh
node common/scripts/install-run-rush.js lint-staged || exit $?

# Add a placeholder config at repo root (.lintstagedrc.json):
{
  "*": "echo ok"
}

# Create per-project .lintstagedrc files (e.g., apps/my-app/.lintstagedrc.js):
module.exports = {
  "*.js": "eslint --fix"
};

# Stage files and run:
git add somefile.js
rush lint-staged