mrm-task-lint-staged

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

Mrm task that automates adding lint-staged configuration, pre-commit hooks, and dependencies to a JavaScript/TypeScript project. Version 7.1.22 is stable and maintained as part of the Mrm monorepo. Released alongside other Mrm tasks every few months. Supports ESLint, Prettier, and Stylelint; infers file extensions from existing npm scripts. Configures lint-staged within package.json and sets up a Git pre-commit hook using husky or similar. Offers customizable rules via the `lintStagedRules` option. Targeted at developers using Mrm for project scaffolding, contrasting with manual setup or other task runners.

error No lint-staged rules were created after running `npx mrm lint-staged`
cause No lint scripts (e.g., 'eslint', 'prettier') detected in package.json.
fix
Add appropriate npm scripts, e.g., 'lint': 'eslint .', then re-run the task.
error Error: Cannot find module 'mrm-core'
cause mrm-core not installed globally or locally.
fix
Install mrm-core: npm install -g mrm-core or npx mrm-core lint-staged (if bundled).
error Error: Task 'lint-staged' is not found
cause mrm-task-lint-staged package not installed or mrm version incompatible.
fix
Install mrm and the task: npm install -g mrm mrm-task-lint-staged.
deprecated Inferring extensions from npm scripts may override manual changes on re-run.
fix Use lintStagedRules option to explicitly set rules and prevent overwriting.
gotcha Only supports Prettier, ESLint, and Stylelint; other linters are not detected.
fix Manually add custom rules via lintStagedRules option.
gotcha Task assumes husky is used for Git hooks; other hook managers may not be set up automatically.
fix Ensure husky is installed; otherwise, manually configure hooks.
gotcha If no npm lint scripts exist, no rules are added. Task will create empty config.
fix Add relevant lint scripts before running the task, or specify rules via options.
breaking Version 7.x may have breaking changes from 6.x; check changelog for migration.
fix Review CHANGELOG.md before upgrading.
npm install mrm-task-lint-staged
yarn add mrm-task-lint-staged
pnpm add mrm-task-lint-staged

Run the Mrm task for lint-staged. This will create or update package.json with lint-staged config, install lint-staged, and set up a pre-commit hook. Requires npm scripts (e.g., 'lint') to infer rules. Custom rules can be passed via project config.

npx mrm lint-staged