JSPM

lint-staged

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13821540
  • Score
    100M100P100Q217482F
  • License MIT

Lint JS and CSS files staged by git

Package Exports

  • lint-staged/package.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lint-staged) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lint-staged

Lint JS and CSS files staged by git

Motivation

Linting makes more sense when running before commiting you code into repository. In this case you can ensure no 💩 is going put into it and enforce styles. This repsitory contains shell scrtips that run ESLint, Stylelint, JSCS and Flow against only currently staged files.

Installation

npm install --save-dev lint-staged

Install and setup your linters just like you would do normally. Add appropriate .eslintrc and .stylelintrc etc. configs (see ESLint and Stylelint docs if you need help here).

Adding pre-commit hooks

To start linting, you have to install a pre-commit hook:

  1. npm install --save-dev pre-commit
  2. Add "eslint-staged": "eslint-staged" to scripts section of package.json (if you want to lint your JS)
  3. Add "stylelint-staged": "stylelint-staged" to scripts section of package.json (if you want to lint your CSS)
  4. ...
  5. Add pre-commit": [ "eslint-staged", "stylelint-staged" ] to package.json

Example package.json

{
  "name": "My project",
  "version": "0.0.1",
  "scripts": {
    "eslint-staged": "eslint-staged",
    "stylelint-staged": "stylelint-staged"
  },
  "pre-commit": [ "eslint-staged", "stylelint-staged" ]
  "devDependencies: {}
}