summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-11-12 13:37:22 +0200
committerGitHub <noreply@github.com>2021-11-12 12:37:22 +0100
commit5ea2cbe2eb8461c1c00ae0058819d5d44f665e03 (patch)
tree2d6f389efaa4be6b3d76835e637d15cfa0116f7a
parent13e01f031fced54bbe06d93b86604d5fbef6c934 (diff)
downloadpylint-git-5ea2cbe2eb8461c1c00ae0058819d5d44f665e03.tar.gz
Add documentation on adding ``pylint`` to ``pre-commit`` (#5292)
-rw-r--r--doc/tutorial.rst1
-rw-r--r--doc/user_guide/index.rst1
-rw-r--r--doc/user_guide/pre-commit-integration.rst46
3 files changed, 48 insertions, 0 deletions
diff --git a/doc/tutorial.rst b/doc/tutorial.rst
index b7ff5559c..156fea427 100644
--- a/doc/tutorial.rst
+++ b/doc/tutorial.rst
@@ -1,3 +1,4 @@
+.. _tutorial:
========
Tutorial
diff --git a/doc/user_guide/index.rst b/doc/user_guide/index.rst
index e25db0f99..95daa4748 100644
--- a/doc/user_guide/index.rst
+++ b/doc/user_guide/index.rst
@@ -12,3 +12,4 @@ User Guide
message-control
options
ide-integration
+ pre-commit-integration
diff --git a/doc/user_guide/pre-commit-integration.rst b/doc/user_guide/pre-commit-integration.rst
new file mode 100644
index 000000000..62dfbcfd0
--- /dev/null
+++ b/doc/user_guide/pre-commit-integration.rst
@@ -0,0 +1,46 @@
+.. _pre-commit-integration:
+
+Pre-commit integration
+======================
+
+``pylint`` can be used as a `pre-commit <https://pre-commit.com>`_ hook.
+
+Since ``pylint`` needs to import modules and dependencies to work correctly, the
+hook only works with a local installation of ``pylint`` (in your environment).
+If you installed ``pylint`` locally it can be added to ``.pre-commit-config.yaml``
+as follows:
+
+.. sourcecode:: yaml
+
+ - repo: local
+ hooks:
+ - id: pylint
+ name: pylint
+ entry: pylint
+ language: system
+ types: [python]
+ args:
+ [
+ "-rn", # Only display messages
+ "-sn", # Don't display the score
+ ]
+
+You can use ``args`` to pass command line arguments as described in the :ref:`tutorial`.
+A hook with more arguments could look something like this:
+
+.. sourcecode:: yaml
+
+ - repo: local
+ hooks:
+ - id: pylint
+ name: pylint
+ entry: pylint
+ language: system
+ types: [python]
+ args:
+ [
+ "-rn", # Only display messages
+ "-sn", # Don't display the score
+ "--rcfile=pylintrc", # Link to your config file
+ "--load-plugins=pylint.extensions.docparams", # Load an extension
+ ]