I have a project with a frontend in JS and backend in Python. Frontend had been configured with husky pre-commit hook. Today I've configured Pylint with pre-commit library but husky hooks had been overwritten by that move. Is it possible to combine pre-commit and husky libraries? If not... what's the best way to solve the problem?
Pylint with pre-commit and EsLlint with husky
7.5k Views Asked by Aleksandr Zakharov At
2
There are 2 best solutions below
0
Carter
On
A solution that works better for me, with the latest version of pre-commit (2.14.0) and husky (7.0.2) is to integrate pre-commit into husky, rather than the other way around.
In the ./husky/_/pre-commit file, I added pre-commit run.
See below:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
npx pretty-quick --staged
pre-commit run
Related Questions in GIT
- Push mysql database script to server using git
- Git show's file path
- Git > diffs filtered, show only certain changed classes/files
- Pushing to git repository hosted by Visual studio online without entering user name and password
- How do I create my own Git branch to work on?
- Git init --bare giving error fatal: Out of memory? mmap failed: No such device
- Sub-directory into independent repository and later merge back into main repository
- How to find the Git Revision Hash in a synced SVN repo using SubGit?
- eclipse errors when try to change to master git branch
- How to have Heroku build my development branch on a staging server?
- Is "Merged in" a commit message created by bitbucket, or git?
- Git: Multiple projects under one directory
- Permission denied hg-git
- Is it possible to clone a private git repo without adding ssh keys
- Track file in master repository which is ignored in submodule
Related Questions in ESLINT
- How to to run eslint on *.js.erb files?
- Bypass ESLint's `no-unused-var` for Should in a Mocha test
- where to download com.intellij.lang.javascript.psi
- How to set .eslintrc to recognize 'require'?
- How to disable ESLint react/prop-types rule in a file?
- ESLint: How to set "new-cap" rule's "capIsNewExceptions" option within a file?
- jsx-no-bind in contextual map function
- visual studio code install eslint error for LF or CRLF
- ESLint prefer-const error with conditional reassign
- failAfterError gulpEslint
- Using gulp eslint how do I only report errors and warnings?
- Is it a bad practice to modify function arguments in JavaScript
- Should I use jshint or eslint to lint a jquery plugin?
- Force ESLint to use ES6
- ESLint ignore specific rule for a specific directory
Related Questions in PYLINT
- How to jump/display the column of an error
- pylint does not catch obvious error
- Pylint Error when using metaclass
- Pylint for half-implemented abstract classes
- Pylint on StringIO or buffered text
- Error in astroid 1.3.6 package while installing pylint for python 3.3.4
- Why signature of the form "save()" method should match base Form class in django?
- Error message "python-pylint 'C0103:Invalid constant name"
- git-lint pylint not running pylintrc file
- Named equivalent of W0703
- Why does Cheesecake fail to execute pylint?
- Is it possible to disable pylint missing docstring error for short functions and methods?
- Why doesn't pylint warn me about using nonexistent class members?
- Is it possible to disable specific message in pylint?
- Cannot install pylint on Windows 7 x64, Python 2.7, pip error
Related Questions in PRE-COMMIT.COM
- Precommit check-yaml error : "expected a single document in the stream"
- zsh: command not found: pre-commit but package installed
- Prettier using pre-commit(.com) does not re-stage changes
- Python Black hooks (language: system)
- pygrep pre-commit hook to check string is present
- VSCode integrated source control and pre-commit
- yaml multiline regex
- pre-commit not picking files for pip-tools
- How to run a single pre-commit hook with particular arguments that are different to the yaml definition
- Running pre commits, excluding a directory for multiples hooks
- Pre-commit python mypy checks all files not just committed files
- Is there an option to run automatically a specific pre-commit hook on all the files, even if they have not been modified?
- How to fix InvalidManifestError for pre-commit with black?
- Why does pre-commit fail with "failed to find interpreter for Builtin discover of python_spec='python3.10'"?
- pre-commit Git hooks in AWS SageMaker Studio
Related Questions in GIT-HUSKY
- Cannot execute binary file: Exec format error (code 126)
- Unstaged changes could not be restored due to a merge conflict
- Add Husky(Git Hooks) into Azure DevOps Project
- How to stop a commit if test coverage is below a certain percentage?
- how do i install husky to use commitlint with nested folders?
- Husky Hook does not work properly with Test
- Npx not found when runing pre-commit husky script
- How are devinstall and devuninstall scripts being used?
- husky > pre-commit hook failed (add --no-verify to bypass)
- Pylint with pre-commit and EsLlint with husky
- Unable to setup input stream: unable to set IO streams as raw terminal: The handle is invalid
- Escape hatch for husky v6?
- Use Husky without node installed (use in Docker)
- Can't run commitlint in husky with another custom command
- Protect deleting/renaming file in git repository
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
pre-commit has a "migration mode" for running other existing hook frameworks. It seems that husky is slightly too clever in their hook implementation for detecting what hook you're running -- they base it on the filename that's being executed
the way pre-commit's migration mode works is it takes any existing hook script (in this case, the hook script written by husky to
.git/hooks/pre-commit) and adds the extension.legacy. then during execution it runs that script.but to husky, it looks like the
pre-commit.legacyhook is running (!)a little hack is to define
pre-commit.legacyinpackage.jsonwhich seems to work:package.json
.pre-commit-config.yaml
that said, this seems fragile. pre-commit is designed to support many different programming languages (even though it is written in python, it has native support for 10+ programming languages (including javascript))
A first place replacement might be to just call husky from a
localpre-commit hook:package.json
.pre-commit-config.yamlexecution
this solution however doesn't take advantage of pre-commit's js support, it just invokes the already-existing husky hooks
a more native solution would be to install js hooks directly with pre-commit, for example if you're using eslint:
disclaimer: I am the author of pre-commit