Duolingo Pre Commit Hooks Save

Standardizing our code quality tooling :hammer_and_wrench:

Project README

pre-commit hooks

This repo currently contains a single pre-commit hook that internally runs several code formatters in parallel.

  • Prettier v3.1.0 for CSS, HTML, JS, JSX, Markdown, Sass, TypeScript, XML, YAML
  • Ruff v0.1.5 for Python 3
  • Black v21.12b0 for Python 2
  • autoflake v1.7.8 for Python
  • isort v5.12.0 for Python 2
  • google-java-format v1.18.1 for Java
  • ktfmt v0.46 for Kotlin
  • scalafmt v3.7.16 for Scala
  • shfmt v3.7.0 for Shell
  • xsltproc from libxslt v10138 for XML
  • terraform fmt v1.6.3 for Terraform
  • ClangFormat v16.0.6 for Protobuf
  • SVGO v3.0.3 for SVG
  • Custom regex transformations (basically 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 equivalents

We 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:

- repo: https://github.com/duolingo/pre-commit-hooks.git
  rev: 1.7.3
  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 automatically pick up the same linter/formatter settings that this hook uses.

Duolingo is hiring! Apply at https://www.duolingo.com/careers

Open Source Agenda is not affiliated with "Duolingo Pre Commit Hooks" Project. README Source: duolingo/pre-commit-hooks
Stars
56
Open Issues
3
Last Commit
3 months ago
License

Open Source Agenda Badge

Open Source Agenda Rating