Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duolingo/pre-commit-hooks
Standardizing our code quality tooling :hammer_and_wrench:
https://github.com/duolingo/pre-commit-hooks
black formatter git google-java-format ktlint pre-commit prettier scalafmt shfmt svgo terraform
Last synced: 5 days ago
JSON representation
Standardizing our code quality tooling :hammer_and_wrench:
- Host: GitHub
- URL: https://github.com/duolingo/pre-commit-hooks
- Owner: duolingo
- License: apache-2.0
- Created: 2019-09-26T09:12:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T17:56:44.000Z (3 months ago)
- Last Synced: 2024-10-29T19:14:52.325Z (3 months ago)
- Topics: black, formatter, git, google-java-format, ktlint, pre-commit, prettier, scalafmt, shfmt, svgo, terraform
- Language: JavaScript
- Homepage:
- Size: 465 KB
- Stars: 60
- Watchers: 7
- Forks: 9
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pre-commit hooks
This repo currently contains a single [pre-commit](https://pre-commit.com/) hook that internally runs several code formatters in parallel.
- [Prettier](https://github.com/prettier/prettier) v3.3.3 for CSS, HTML, JS, JSX, Markdown, Sass, TypeScript, XML, YAML
- [Ruff](https://docs.astral.sh/ruff/) v0.7.3 for Python 3
- [Black](https://github.com/psf/black) v21.12b0 for Python 2
- [autoflake](https://github.com/myint/autoflake) v1.7.8 for Python
- [isort](https://github.com/PyCQA/isort) v5.13.2 for Python 2
- [google-java-format](https://github.com/google/google-java-format) v1.24.0 for Java
- [ktfmt](https://github.com/facebookincubator/ktfmt) v0.53 for Kotlin
- [gofmt](https://pkg.go.dev/cmd/gofmt) v1.23.3 for Go
- [scalafmt](https://scalameta.org/scalafmt/) v3.8.3 for Scala
- [shfmt](https://github.com/mvdan/sh) v3.10.0 for Shell
- [xsltproc](http://www.xmlsoft.org/xslt/xsltproc.html) from libxslt v10139 for XML
- [terraform fmt](https://github.com/hashicorp/terraform) v1.9.8 for Terraform
- [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v18.1.8 for C++, Protobuf
- [SVGO](https://github.com/svg/svgo) v3.3.2 for SVG
- [Taplo](https://taplo.tamasfe.dev/) v0.9.3 for TOML
- Custom regex transformations (basically [sed](https://en.wikipedia.org/wiki/Sed)), for example:
- Trimming trailing whitespace and newlines
- Removing unnecessary `coding` pragmas and `object` base classes in Python 3
- Replacing empty Python collections like `list()` with literal equivalents
- Replacing empty Kotlin collections like `arrayOf()` with `empty` equivalentsWe run this hook on developer workstations and enforce it in CI for all production repos at Duolingo.
## Usage
Repo maintainers can declare this hook in `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/duolingo/pre-commit-hooks.git
rev: 1.8.0
hooks:
- id: duolingo
args: # Optional
- --python-version=2 # Defaults to Python 3
- --scala-version=3 # Defaults to Scala 2.12
```Directories named `build` and `node_modules` are excluded by default - no need to declare them in the hook's `exclude` key.
Contributors can copy or symlink this repo's `.editorconfig` file to their home directory in order to have their [text editors and IDEs](https://editorconfig.org/) automatically pick up the same linter/formatter settings that this hook uses.
_Duolingo is hiring! Apply at https://www.duolingo.com/careers_