Skip to content

Run eslint on changed files in your git repo, before git commit. It output results colorfully.

Notifications You must be signed in to change notification settings

yyh77/lint-git-changes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lint-git-changes

version npm

Run eslint on changed files in your git repo, before git commit. It output results colorfully.

Installation

$ npm install lint-git-changes --save-dev

or

$ yarn add lint-git-changes --dev

Usage

It should be used as a script with husky or pre-commit.

lint(options)

Options

  • ext - {String | Array<String>}. Files which matched the configured extensions will be lint. Default: "js".
  • fix - {Boolean}. Whether fix the codes automatically. Default: false.
  • dir - {String}. Choose the directory(relative path to project dir) to lint.

Example

./foo.js

const lint = require('lint-git-changes')
lint({
  ext: 'js, jsx' // or ['js', 'jsx'] 
})

package.json

used with husky, please install it first.

{
  "script": {
    "precommit": "node ./foo.js"
  }
}

Addition

  • eslint was considered as a peer dependency.

About

Run eslint on changed files in your git repo, before git commit. It output results colorfully.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published