Search code examples
javascriptpythonreactjspre-commitpre-commit.com

pre-commit + python + react (js)


I use pre-commit, I want to use it together with .py files, I reformat file black module, but I also have a web folder where the react files are, I have 2 questions at once, what is relevant for reformatting the code for js and how can I unite so that when the pre-commit run is started, the web folder is checked for reformatting the js code

UPDATE: the question that worried me the most is the js and py file conflict, but I used:

  - repo: https://github.com/prettier/prettier
    rev: 2.1.2
    hooks:
      - id: prettier

Solution

  • though pre-commit is written in python, it has support for many different programming languages including javascript

    there's a whole list of supported tools in the pre-commit documentation -- the most popular probably being eslint or prettier (though, tool suggestion is generally off-topic on stack overflow since it's highly opinion based)


    disclaimer: I'm the author of pre-commit