lint-emit

Crates.iolint-emit
lib.rslint-emit
version0.3.3
sourcesrc
created_at2019-02-17 08:56:05.282298
updated_at2019-02-19 10:01:03.386075
descriptionLint your git diffs!
homepage
repositoryhttps://github.com/ragone/lint-emit
max_upload_size
id115326
size37,037
Alex Ragone (ragone)

documentation

README

This tool aims to run multiple linters on a commit range compatible with git.

Inspired by lint-diff and lint-staged

Linters are great tools to enforce code style in your code, but it has some limitations: it can only lint entire files.
When working with legacy code, we often have to make changes to very large files (which would be too troublesome to fix all lint errors)
and thus it would be good to lint only the lines changed and not the entire file.

lint-emit receives a commit range and uses the specified linters to lint the changed files and filter only the errors introduced in the commit range (and nothing more).

Configuration

You can add a linter by editing the config file found in your user path.

  • Linux: /home/alice/.config/lint-emit
  • Windows: C:\Users\Alice\AppData\Roaming\ragone\lint-emit
  • macOS: /Users/Alice/Library/Preferences/io.ragone.lint-emit

If no config file is found, you will be asked which default linters you would like to add.

[[linters]]                                                                                                                                                                 
name = "eslint"                                                                                                                                                             
cmd = "eslint"                                                                                                                                                              
args = ["{file}", "-f=compact"]                                                                                                                                             
regex = '(?P<file>.*): line (?P<line>\d*), col \d*, (?P<message>.*)'                                                                                                        
ext = ["js", "jsx"]                                                                                                                                                         

Installation

cargo install lint-emit

Usage

Lint the last commit

$ lint-emit HEAD^..HEAD                                                                                                                                                     

Lint the last 3 commits

$ lint-emit HEAD~3..HEAD                                                                                                                                                    

Lint local changes that are not yet committed

$ lint-emit HEAD                                                                                                                                                            
# or                                                                                                                                                                        
$ lint-emit                                                                                                                                                                 

Lint using phpmd and phpcs

$ lint-emit --linters phpmd phpcs                                                                                                                                           
Commit count: 48

cargo fmt