The only standalone, multiplatform pre-commit hook for formatting QML files using the qmlformat tool with no Qt prerequisites required.
-
Add this repository to your
.pre-commit-config.yaml:- repo: https://github.com/tomas-krupa/qmlformat-hook.git rev: 1.2.0 hooks: - id: qmlformat #args: ["--check"] #additional_dependencies: # - PySide6-Essentials==6.8.3 # override version of Qt Python metapackage
- By default, all
*.qmlfiles will be matched
-
Install the pre-commit hooks:
pre-commit install
-
Make a commit with QML files to see the hook in action.