Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/playpauseandstop/pre-commit-run-hook-entry

Run pre-commit hook entry. Allow to run pre-commit hooks for text editor formatting / linting needs.
https://github.com/playpauseandstop/pre-commit-run-hook-entry

pre-commit python-3-10 python-3-6 python-3-7 python-3-8 python-3-9 sublime-text-3 vscode

Last synced: about 1 month ago
JSON representation

Run pre-commit hook entry. Allow to run pre-commit hooks for text editor formatting / linting needs.

Awesome Lists containing this project

README

        

=========================
pre-commit-run-hook-entry
=========================

.. image:: https://github.com/playpauseandstop/pre-commit-run-hook-entry/workflows/ci/badge.svg
:target: https://github.com/playpauseandstop/pre-commit-run-hook-entry/actions?query=workflow%3A%22ci%22
:alt: CI Workflow

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:target: https://github.com/pre-commit/pre-commit
:alt: pre-commit

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: black

.. image:: https://img.shields.io/pypi/v/pre-commit-run-hook-entry.svg
:target: https://pypi.org/project/pre-commit-run-hook-entry/
:alt: Latest Version

.. image:: https://img.shields.io/pypi/pyversions/pre-commit-run-hook-entry.svg
:target: https://pypi.org/project/pre-commit-run-hook-entry/
:alt: Python versions

.. image:: https://img.shields.io/pypi/l/pre-commit-run-hook-entry.svg
:target: https://github.com/playpauseandstop/pre-commit-run-hook-entry/blob/main/LICENSE
:alt: BSD License

.. image:: https://coveralls.io/repos/playpauseandstop/pre-commit-run-hook-entry/badge.svg?branch=main&service=github
:target: https://coveralls.io/github/playpauseandstop/pre-commit-run-hook-entry
:alt: Coverage

Run `pre-commit`_ hook entry. Allow to run pre-commit hooks for text editor
formatting / linting needs.

.. _`pre-commit`: https://pre-commit.com/

Danger Zone
===========

**IMPORTANT:** This is highly experimental tool as `pre-commit internals does
not intend to be used in other scripts
`_.
It might be broken after new pre-commit release.

**TO USE WITH CAUTION!**

Requirements
============

- `Python `_ 3.7 or later
- `pre-commit`_ 2.19.0 or later

License
=======

``pre-commit-run-hook-entry`` is licensed under the terms of
`BSD-3-Clause `_ license.

Installation
============

.. code-block:: bash

pip install pre-commit-run-hook-entry

Usage
=====

.. code-block:: bash

pre-commit-run-hook-entry HOOK [ARGS]
pre-commit-which-hook-entry HOOK

Prerequisites
-------------

``pre-commit-run-hook-entry`` only works in directories, where
``pre-commit run --all HOOK`` is executable.

VS Code Integration
-------------------

Example below illustrates how to configure VS Code to use black, flake8 &
mypy pre-commit hooks for formatting & linting,

.. code-block:: json

{
"python.formatting.provider": "black",
"python.formatting.blackPath": "pre-commit-run-hook-entry",
"python.formatting.blackArgs": ["black"],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "pre-commit-run-hook-entry",
"python.linting.flake8Args": ["flake8"],
"python.linting.mypyEnabled": true,
"python.linting.mypyPath": "pre-commit-run-hook-entry",
"python.linting.mypyArgs": ["mypy"]
}

Sublime Text 3 Integration
--------------------------

sublack
~~~~~~~

From one point `sublack `__ has builtin
pre-commit integration, but it seems do not respect settings from
``pyproject.toml``, to fix this use ``pre-commit-run-black-entry`` as
``sublack.black_command``,

.. code-block:: json

{
"sublack.black_command": "pre-commit-run-black-entry"
}

SublimeLinter-flake8
~~~~~~~~~~~~~~~~~~~~

.. code-block:: json

{
"SublimeLinter.linters.flake8.executable": "pre-commit-run-hook-entry",
"SublimeLinter.linters.flake8.args": ["--", "flake8"]
}

SublimeLinter-contrib-mypy
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: json

{
"SublimeLinter.linters.mypy.executable": "pre-commit-run-hook-entry",
"SublimeLinter.linters.mypy.args": ["--", "mypy"]
}

SublimeJsPrettier
~~~~~~~~~~~~~~~~~

First, you need to find out path to prettier hook entry with,

.. code-block:: bash

pre-commit-which-hook-entry prettier

Then, paste command output (````) into plugin config,

.. code-block:: json

{
"js_prettier": {
"prettier_cli_path": ""
}
}

SublimeLinter-eslint
~~~~~~~~~~~~~~~~~~~~

First, you need to find out path to eslint hook entry with,

.. code-block:: bash

pre-commit-which-hook-entry eslint

Then, paste command output (````) into plugin config,

.. code-block:: json

{
"SublimeLinter.linters.eslint.executable": "",
"SublimeLinter.linters.eslint.env": {
"NODE_PATH": "/../../lib/node_modules"
}
}

**IMPORTANT:** If you're using any ``additionalDependencies`` for eslint hook,
you need to configure ``NODE_PATH``, so plugin will be able to find out given
dependencies.

Issues & Feature Requests
=========================

Feel free to submit new issue or feature request `at GitHub
`_