summaryrefslogtreecommitdiff
path: root/docs/internals/contributing/writing-code/coding-style.txt
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2020-12-15 20:32:08 +0000
committerCarlton Gibson <carlton@noumenal.es>2020-12-23 11:14:48 +0100
commit3bca95cca277a1e205c10d4fd3ea8527c6fcc34a (patch)
treec39e0b0309f3a81aebcbea0b54a80e35d5c7b00f /docs/internals/contributing/writing-code/coding-style.txt
parent3a0ed0ce3f2e38c4336da6d68d901c6f3d5926dc (diff)
Fixed #32165 -- Added pre-commit hooks
* Added pre-commit hooks for isort, flake8 and eslint * Added documentation on how to install and use the tool
Diffstat (limited to 'docs/internals/contributing/writing-code/coding-style.txt')
-rw-r--r--docs/internals/contributing/writing-code/coding-style.txt26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt
index 0c91f20268..739ff0f4b9 100644
--- a/docs/internals/contributing/writing-code/coding-style.txt
+++ b/docs/internals/contributing/writing-code/coding-style.txt
@@ -4,6 +4,32 @@ Coding style
Please follow these coding standards when writing code for inclusion in Django.
+.. _coding-style-pre-commit:
+
+Pre-commit checks
+=================
+
+`pre-commit <https://pre-commit.com>`_ is a framework for managing pre-commit
+hooks. These hooks help to identify simple issues before committing code for
+review. By checking for these issues before code review it allows the reviewer
+to focus on the change itself, and it can also help to reduce the number CI
+runs.
+
+To use the tool, first install ``pre-commit`` and then the git hooks::
+
+.. console::
+
+ $ pip install pre-commit
+ $ pre-commit install
+
+On the first commit ``pre-commit`` will install the hooks, these are
+installed in their own environments and will take a short while to
+install on the first run. Subsequent checks will be significantly faster.
+If the an error is found an appropriate error message will be displayed.
+If the error was with ``isort`` then the tool will go ahead and fix them for
+you. Review the changes and re-stage for commit if you are happy with
+them.
+
.. _coding-style-python:
Python style