Repository navigation
v0.2.0
Tasks on staged files: Ward now replaces lint-staged as well as husky, with one config for both.
Warning
Ward is in early development (0.x). Until 1.0, any minor release may change the config and behavior.
Install
npm install -D @hexlabelposition/ward
npm pkg set scripts.prepare=ward
npm run preparePublished with npm provenance. Requires Node.js 24 or later. Two runtime dependencies (yaml, picomatch), ESM-only.
What's in v0.2
Tasks on files
- Named tasks:
{ tasks: { name: { run } } }, run in the order they are listed. {staged_files},{push_files}and{all_files}placeholders. Long file lists are split into several runs, so they fit the command line limit on Windows.globandexcludeper task pick the files a task runs on. A task with no matching files is skipped.- Files fixed by a task are staged again;
stageFixed: falseleaves them unstaged. - Symlinks are left out of file lists;
symlinks: truepasses them to the task. - Function tasks in
ward.config.ts: a function that gets the file list. parallel: trueruns the tasks of a hook at the same time, with each line of output prefixed by the task name.
Safety
- A backup with
git stash createbefore every run;backup: falseor--no-backupskips it. - Partial staging: unstaged changes of partially staged files are hidden while tasks run and put back afterwards.
- When a task fails, the index and working tree are reverted to the backup;
revert: falseor--no-revertkeeps the changes of the tasks. - Deletions, binary files, renames, symlinks and merge conflicts are handled in the backup and partial staging.
- A
pre-commitwhose tasks undid every staged change fails instead of making an empty commit.
Install
ward --bin <path>sets the binary the hooks call instead ofnode_modules/.bin/ward.
Moving from lint-staged
Move each glob and its commands into a named task with glob and {staged_files}, then remove lint-staged. See Moving from lint-staged.
Tested on
Ubuntu, macOS and Windows, on Node.js 24 and the current release.
What's next
- v0.3: Bun and Deno.
- v0.4: the same config in CI (
--from-ref,--all-files,--ci) and shared configs withextends.
See BACKLOG.md.
Full Changelog: v0.1.0...v0.2.0