This repo currently contains a single pre-commit hook that internally runs several code formatters in parallel.
- Prettier v2.1.2 for CSS, HTML, JS, JSX, Markdown, Sass, TypeScript, YAML
- Black v20.8b1 for Python
- autoflake v1.4 for Python
- google-java-format v1.9 for Java
- ktfmt v0.25 for Kotlin
- scalafmt v2.7.5 for Scala
- shfmt v3.2.0 for Shell
- styler v1.4.1 for R
- terraform fmt v0.11.14 and v0.12.29 for Terraform
- ClangFormat v10.0.0 for Protobuf
- SVGO v1.3.2 for SVG
- Custom regex transformations (basically sed), for example:
- Trimming trailing whitespace and newlines
- Removing unnecessary
codingpragmas andobjectbase classes in Python 3 - Replacing empty Python collections like
list()with literal equivalents - Replacing empty Kotlin collections like
arrayOf()withemptyequivalents
We run this hook on developer workstations and enforce it in CI for all production repos at Duolingo.
Repo maintainers can declare this hook in .pre-commit-config.yaml:
- repo: https://github.com/duolingo/pre-commit-hooks.git
rev: 1.4.2
hooks:
- id: duolingo
args: [--python-version=2] # Optional, defaults to Python 3Directories named build and node_modules are excluded by default - no need to declare them in the hook's exclude key.
Contributors can copy this repo's .editorconfig file to their home directory in order to have their text editors and IDEs automatically pick up the same linter/formatter settings that this hook uses.
Duolingo is hiring! Apply at https://www.duolingo.com/careers