Home > Enterprise >  Is it possible to add pre-commit configuration file to a non-root folder?
Is it possible to add pre-commit configuration file to a non-root folder?

Time:09-09

I set up a pre-commit plugin for one of my projects.

Right now, the .pre-commit-config.yaml configuration file is located on the root of the project (as indicated by the official doc https://pre-commit.com/#usage).

Is it possible to move it to a separate folder and adjust it somehow to be read from there?

Current state (output of dir command):

.pre-commit-config.yaml                                                                                                                                                                                                                                                                                                                      
.pylintrc                                                                                                                                                                      
ci                                                                                                                                                                             
commons                                                                                                                                                                        
doc
...         

What I would like to have (or similar):

.pylintrc                                                                                                                                                                      
ci                                                                                                                                                                             
commons                                                                                                                                                                        
doc
precommit\.pre-commit-config.yaml
...         

CodePudding user response:

yes -- but you shouldn't fight the convention unless you've got a very good reason to do so as it's likely to confuse your contributors and be more annoying to use and you'll be fighting the convention

all of the pre-commit commands support a --config option which allows you to put the configuration anywhere


disclaimer: I wrote pre-commit

  • Related