{"id":13847493,"url":"https://github.com/codeocelot/git-diff-lint","last_synced_at":"2026-02-19T23:19:32.188Z","repository":{"id":69267713,"uuid":"118078600","full_name":"codeocelot/git-diff-lint","owner":"codeocelot","description":"Lint only the files your branch touches","archived":false,"fork":false,"pushed_at":"2020-01-11T01:23:50.000Z","size":5,"stargazers_count":41,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-04T18:02:41.775Z","etag":null,"topics":["codereview","continuous-integration","git","linting","styleguide"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeocelot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-01-19T04:49:45.000Z","updated_at":"2024-05-30T18:15:52.000Z","dependencies_parsed_at":"2023-09-15T12:17:22.585Z","dependency_job_id":null,"html_url":"https://github.com/codeocelot/git-diff-lint","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeocelot%2Fgit-diff-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeocelot%2Fgit-diff-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeocelot%2Fgit-diff-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeocelot%2Fgit-diff-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeocelot","download_url":"https://codeload.github.com/codeocelot/git-diff-lint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225812926,"owners_count":17528087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codereview","continuous-integration","git","linting","styleguide"],"created_at":"2024-08-04T18:01:32.341Z","updated_at":"2026-02-19T23:19:32.159Z","avatar_url":"https://github.com/codeocelot.png","language":"Shell","readme":"# git-diff-lint\nUnopinionated lint runner that only lints files that your feature branch has modified.\n\nMany 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.\n\n`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.\n\n## Installation\nJust download and add command to your system path:\n\n```bash\ncurl -O https://raw.githubusercontent.com/codeocelot/git-diff-lint/master/git-diff-lint\nexport PATH=$PATH/$(pwd)\n# add to zshrc to use in future sessions\necho \"export PATH=\\$PATH:$(pwd)\" \u003e\u003e ~/.zshrc\n# or add to bashrc\necho \"export PATH=\\$PATH:$(pwd)\" \u003e\u003e ~/.bashrc\n```\n\n## Usage\n\n```bash\n$ git-diff-lint -x eslint -e .js\n$ git-diff-lint -x \"pycodestyle --statistics\" -e .py -b master\n```\n\nExecutes 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.  \n\n### Options:\n\n| flag | env var | purpose | default |\n|----|-----|----|----|\n| -x | LINT | lint command, e.g. `eslint` | `pycodestyle` |\n| -b | BRANCH | parent git branch | stage |\n| -e | EXT | file regex expression | `\\.py$` |\n| -h | \\\u003cnone\\\u003e | Show help message and exit |\n\n## Recipes\n\n#### ESLint\n\n- Lint .js \u0026 .jsx files with ESlint:\n\n```bash\ngit-diff-lint -x \"npx eslint\" -e \".js$|.jsx\" -b stage\n# alternatively, using env vars:\nEXT=\".js$|.jsx$\" LINT=\"npx eslint\" BRANCH=stage git-diff-lint\n```\n\n#### Node package.json\n\nEscaping strings is annoying in package.json, but doable.\n\n```json\n{\n  \"name\": \"your-project\",\n  \"scripts\": {\n    \"lint\": \"EXT=\\\".js$|.jsx$|.ts$|.tsx$\\\" LINT=\\\"npx eslint --ext .js,.jsx,.ts,.tsx\\\" ./tools/git-diff-lint/git-diff-lint\"\n  }\n}\n```\n\nOr create a script file and call it.\n\n```bash\n# lint.sh\ngit-diff-lint -x \"npx eslint\" -e \".js$|.jsx\" -b stage\n```\n\n```json\n{\n  \"name\": \"your-project\",\n  \"scripts\": {\n    \"lint\": \"./lint.sh\"\n  }\n}\n```\n\n## Contributing\n\nHave 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.\n\nI prefer if you use [commitizen](https://github.com/commitizen/cz-cli) to format your commits, but any reasonable committing strategy is fine.\n\nIf you have ideas on how to write tests for this project, please share!\n\n## License\n\nMIT Licensed.  Go forth and create, but please provide attribution back to this project.\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeocelot%2Fgit-diff-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeocelot%2Fgit-diff-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeocelot%2Fgit-diff-lint/lists"}