mrm-task-lint-staged

Mrm task that adds lint-staged.

Note: supports only Prettier, ESLint and Stylelint now, pull requests are welcome.

What it does

  • Creates a config in package.json
  • Sets up a pre-commit Git hook
  • Installs dependencies

This tasks will try to infer extensions from your npm scripts. For example, if you have lint script that runs ESLint for js and ts files, the task will add lint-staged rule that runs ESLint for the same extensions. And will overwrite an existing rule if you change it manually and run the task again, but it will try to keepy your custom rules.

Usage

npx mrm lint-staged

Options

See Mrm docs and lint-staged docs for more details.

lintStagedRules (default: infer)

Overrides and custom rules. By default will try to infer by project dependencies.

For example, a custom extension:

{
"lintStagedRules": {
"eslint": {
"extensions": ["js", "jsx", "mjs"]
}
}
}

Or a custom command:

{
"lintStagedRules": {
"eslint": {
"command": "eslint --fix"
}
}
}

Or you can disable one of the default rules:

{
"lintStagedRules": {
"prettier": {
"enabled": false
}
}
}

Or add a custom rule:

{
"lintStagedRules": {
"jest": {
"extensions": ["js"],
"command": "jest --bail --findRelatedTests"
}
}
}

Available rules are prettier, eslint and stylelint.