Microservices monorepo w/ Prettier & linting

806 views Asked by At

I have a project with 4 microservices in total, 3 in PHP and 1 in JS, in 1 monorepo. I love to use Prettier for both languages and I want to use ESLint for JS and CS Fixer for PHP to assure code quality. Right now I have a Prettier installation and configuration for each package.

/js1
    /.eslintrc.json
    /prettier.config.json
/js2
    /.eslintrc.json
    /prettier.config.json
/js3
    /.eslintrc.json
    /prettier.config.json
/php1
     /prettier.config.json

For the JS packages theres quite some overlap in the configuration. However, there're also specific plugins or settings for Prettier per microservice. The same goes for ESLint for the JS microservices.

I'm thinking about how to

  1. Run Prettier, ESlint and PHPfixer from the root of the project.
  2. Share the configuration, but have microservice-specific config as well.
  3. Optimally run the formatting and linting on staged files as well.

Every solution I found focusses on a frontend-only project and tools like Lerna are not maintained well.

I thought about the following approaches

  1. Use NPM workspaces to install Prettier once on the root, but where do I install Prettier and where its Plugins?
  2. Add Prettier / ESLint scripts to the root packages.json and run them with concurrently (package).
  3. Have a base Prettier config for JS and PHP, extend them in the project directories.

I'm very unclear about what the best practice is, so please share articles, opinions or tools with me.

0

There are 0 answers