All Projects → codeocelot → git-diff-lint

codeocelot / git-diff-lint

Licence: MIT license
Lint only the files your branch touches

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to git-diff-lint

docker-ansible
Alpine-based multistage-build version of Ansible for reproducible usage in CI
Stars: ✭ 168 (+366.67%)
Mutual labels:  linting, continuous-integration
python
Python Style Guide
Stars: ✭ 49 (+36.11%)
Mutual labels:  styleguide, linting
makefiles
No description or website provided.
Stars: ✭ 23 (-36.11%)
Mutual labels:  linting, continuous-integration
koshry
Run on CI, Apply Rules on the Build and Get the Result back to the Pull Request.
Stars: ✭ 59 (+63.89%)
Mutual labels:  continuous-integration, codereview
Javascript Style Guide
Airbnb JavaScript 스타일 가이드
Stars: ✭ 132 (+266.67%)
Mutual labels:  styleguide, linting
Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (+2.78%)
Mutual labels:  linting, continuous-integration
eslint-config-mingelz
A shared ESLint configuration with Chinese comments. 一份带有完整中文注释的 ESLint 规则。
Stars: ✭ 15 (-58.33%)
Mutual labels:  styleguide, linting
ue5-style-guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,892 (+7933.33%)
Mutual labels:  styleguide, linting
Typescript Guidelines
The TypeScript Guidebook
Stars: ✭ 104 (+188.89%)
Mutual labels:  styleguide, linting
Javascript Airbnb
Перевод «JavaScript Style Guide» от Airbnb
Stars: ✭ 579 (+1508.33%)
Mutual labels:  styleguide, linting
Javascript
JavaScript Style Guide
Stars: ✭ 117,286 (+325694.44%)
Mutual labels:  styleguide, linting
Ue4 Style Guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,656 (+7277.78%)
Mutual labels:  styleguide, linting
typo3-typoscript-lint
Find coding errors in your TypoScript files.
Stars: ✭ 78 (+116.67%)
Mutual labels:  linting, continuous-integration
generator-nullfactory-xrm
Yeoman generator for Dynamics 365 Solutions. It generates a project structure that facilitates the quick creation builds and automated release strategies with minimal effort.
Stars: ✭ 15 (-58.33%)
Mutual labels:  continuous-integration
ci
🐳 Dockette dockerized Alpine linux Dockerfiles for PHP 5.6-8.2 + Composer. NodeJS 6-18. Ansible.
Stars: ✭ 18 (-50%)
Mutual labels:  continuous-integration
Sitegeist.Monocle
An fusion based styleguide implementation for Neos
Stars: ✭ 46 (+27.78%)
Mutual labels:  styleguide
tryceratops
A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).
Stars: ✭ 381 (+958.33%)
Mutual labels:  styleguide
styleguide
A living styleguide powering the Mapzen brand (TM)
Stars: ✭ 13 (-63.89%)
Mutual labels:  styleguide
Norimaki
🌀 Android client for Circle CI
Stars: ✭ 19 (-47.22%)
Mutual labels:  continuous-integration
pattern-library
AXA CH UI component library. Please share, comment, create issues and work with us!
Stars: ✭ 103 (+186.11%)
Mutual labels:  styleguide

git-diff-lint

Unopinionated lint runner that only lints files that your feature branch has modified.

Many codebases don't start off with good linting standards and adopting a linting standard in a large codebase is rarely non-trivial or easy. git-diff-lint is a tool that allows contributors to enjoy the benefits of linting and automated status checks on their feature branches without requiring the entire project to conform. git-diff-lint only lints files that have been modified since the current branch diverges from it's parent.

git-diff-lint is configurable with many popular linters and faithfully preserves the linter exit code meaning it works great as a status check or git pre-push hook.

Installation

Just download and add command to your system path:

curl -O https://raw.githubusercontent.com/codeocelot/git-diff-lint/master/git-diff-lint
export PATH=$PATH/$(pwd)
# add to zshrc to use in future sessions
echo "export PATH=\$PATH:$(pwd)" >> ~/.zshrc
# or add to bashrc
echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc

Usage

$ git-diff-lint -x eslint -e .js
$ git-diff-lint -x "pycodestyle --statistics" -e .py -b master

Executes linter command with the list of modified files compared to parent git branch. Returns status from linter command and prints any linting errors to stderr.

Options:

flag env var purpose default
-x LINT lint command, e.g. eslint pycodestyle
-b BRANCH parent git branch stage
-e EXT file regex expression \.py$
-h <none> Show help message and exit

Recipes

ESLint

  • Lint .js & .jsx files with ESlint:
git-diff-lint -x "npx eslint" -e ".js$|.jsx" -b stage
# alternatively, using env vars:
EXT=".js$|.jsx$" LINT="npx eslint" BRANCH=stage git-diff-lint

Node package.json

Escaping strings is annoying in package.json, but doable.

{
  "name": "your-project",
  "scripts": {
    "lint": "EXT=\".js$|.jsx$|.ts$|.tsx$\" LINT=\"npx eslint --ext .js,.jsx,.ts,.tsx\" ./tools/git-diff-lint/git-diff-lint"
  }
}

Or create a script file and call it.

# lint.sh
git-diff-lint -x "npx eslint" -e ".js$|.jsx" -b stage
{
  "name": "your-project",
  "scripts": {
    "lint": "./lint.sh"
  }
}

Contributing

Have any ideas on how to make this tool more useful? PRs are greatly appreciated. Since this project doesn't have a test suite, please make sure your contribution doesn't break existing functionality and within your PR, please document how to test your proposed feature.

I prefer if you use commitizen to format your commits, but any reasonable committing strategy is fine.

If you have ideas on how to write tests for this project, please share!

License

MIT Licensed. Go forth and create, but please provide attribution back to this project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].