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 answers
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
- problem to push files on a repository git
- diff3 output in git conflict style, including mergeable hunks
- Git Not In Sync with Local Branch
- Setting up the version control of .dotfiles while the .config is connected to a forked repo
- How to fix overriding the main branch in Git?
- I can't add text to "Message" in VS Code when committing to Git
- How can i redirect pull request from main branch to another branch
- Xcode commits (possibly outside of any branch) disappeared, how to get them back?
- Git/TortoiseGit : how to apply ONLY the changes from ONE commit from branch A, to branch B?
- How can I reintroduce username an password on git using fedora?
- GIT SKIP EMPTY DIRECTORIES
- Git smudge run once per checkout or per commit?
- I can't find ~/.profile or ~/.bashrc in C:/Users/<user>/.ssh folder
- Set environment variable during push for GitHub Actions
- Android WebRTC compile
Related Questions in ESLINT
- Eslint rule to prevent space around a typescript generic
- multiple file components and false positives with eslint
- ESLint rules for var / let and/or uninitialised variables
- Unknown word (CssSyntaxError) in JSX File (react js)
- Is it possible to auto-import files with webpack or React so that I don't need to `import` every time
- Is there a way to lint event listener types in JS/TS?
- Why does typescript infer the type of SVG imports as "any" in NextJs 14
- Error: Failed to load plugin 'unicorn' declared in '.eslintrc.js': Cannot find module 'eslint/use-at-your-own-risk'
- ESlint Plugin That Enforces Function Parameter Names
- ESLint rule for preventing exports that match a pattern
- @typescript-eslint/no-unsafe-assignment with conf library
- VSCode eslint and nx rules not highlighting errors in the code
- SyntaxError: Cannot use import statement outside a module on importing MuiOtpInput
- Deploying v2 cloud functions 'unable to resolve path to module ...'
- Problems migrating ESLint code formatting rules to @stylistic/eslint-plugin
Related Questions in PYLINT
- Python (pylint): Catching general exceptions in validation procedures
- How to catch potentially undefined variables with pylint or mypy?
- FileNotFoundError in VSCode when using pylint extension
- Pylint syntax error not suppressing despite the `disable` comment
- Python class method type overloading returns invalid type according to Pylint
- PyLint --init-hook via subprocess.run() not working (maybe escape problems)
- Python Linter to catch user shadowed function names
- Pylint configuration problems
- Issue changing Pylint naming convention in VS Code
- Pylint error: concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly
- Pylint in VSCode is not reading the configuration in settings.json
- Make errors when using external commands
- pylint - how do you enable all optinal checkers / extensions?
- How to install the "pylint3" package on ubuntu 20.4?
- VS Code highlights first character
Related Questions in PRE-COMMIT.COM
- just: error: Justfile does not contain recipes when pre-committing
- Is there a way to change Github Action event name in between?
- Why is pre-comit run --all-files -v is not checking Python files
- ansible-lint during pre-commit in CI/CD
- Cannot find implementation or library stub for module named
- How to use a config from pyproject.toml inside pre-commit-config.yaml
- Kubeconform helm pre-commit plugin is skipping files
- pre-commit - validate json-like files
- Bump2version + pre-commit hook in python code
- git pre-commit hook isort and black keep failing for a python project
- How to set the path for repository local pre-commit hooks
- pre-commit run --all-files An error has occurred: InvalidManifestError: while configure pytest
- Mypy error is not reproducible in local environment
- Pyright not detect current pyenv environment
- Mypy directory exclude in pyproject.toml file not working for pre-commit
Related Questions in GIT-HUSKY
- Pre-commit hook error: "npx: not found" when trying to commit through VS Code
- How to add husky and commitlint to angular project
- Why Git pre-push does not allow me to run the input selection but fails upon select command in my interactive script?
- Why I am unable to trigger the custom version bump script upon merging in master?
- pre-push in husky not work when my test fail in nest js
- Cannot execute binary file: Exec format error (code 126)
- husky pre-commit hook not triggered
- Pre-commit Husky doesn't run npx lint-staged
- Source control and terminal conflict (version.json typechange)
- Husky git hook deletes changes in unstaged files when lint staged fails
- For Husky pre-push hook, how can I make "echo" command to display information in VSCode Output?
- Husky: cannot spawn .husky/commit-msg: No such file or directory
- husly pre push to git add dist?
- Regex not working with husky commit-msg hook
- How can I give a file as an input to the precommit hook in angular
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?
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)
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