From 5941ee46714e7e3e1efb6a51adfc963eb5ae32ce Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Wed, 4 Oct 2023 01:30:14 +0545 Subject: [PATCH] fix: use eslint to format ts,js,json,md and yml, goodbye prettier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prettier is great but introduces additional configuration(config, ignores and scripts), and packages. Eslint is pretty much capable of doing eveything and gives you much control over the opinionated nature of prettier. Prettier describes itself to be "an opinionated code formatter". Opinionated essentially means it’s not for everyone. Prettier makes a lot of hard-coded decisions to provide a minimal configuration interface. That makes it very easy to use (it’s excellent!) and the code consistent across projects. However, on the other hand, it also means you are losing the ability to have fine-grained tweaks to how your code should look like. --- .dockerignore | 1 - README.md | 46 +++++++++++++++++++--------------------------- docs/database.md | 14 +++++++------- docs/linting.md | 17 +++++++++-------- justfile | 2 +- 5 files changed, 36 insertions(+), 44 deletions(-) diff --git a/.dockerignore b/.dockerignore index 010f613f..a139f79c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -58,7 +58,6 @@ LICENSE .swcrc .git .husky -.prettierrc makefile justfile test diff --git a/README.md b/README.md index be59ad1e..8323d750 100644 --- a/README.md +++ b/README.md @@ -90,11 +90,11 @@ env file `Note`: Env files are kept in env folder. The config validation allows 4 environment ['dev', 'prod', 'test','stage']. The env file name should be of format .env.[environment] Ex. (.env.dev). The env to use should be provided while running any script as -NODE_ENV=dev yarn dev +NODE_ENV=dev npm run dev -Start local Postgres server and run `npx cross-env NODE_ENV=dev make migrate` to apply migrations +Start local Postgres server and run `npx cross-env NODE_ENV=dev just migrate` to apply migrations -Now you can start the application witt `npx cross-env NODE_ENV=dev yarn start`. +Now you can start the application witt `npx cross-env NODE_ENV=dev npm run start`. --- @@ -115,27 +115,24 @@ Now you can start the application witt `npx cross-env NODE_ENV=dev yarn start`. - πŸ“ƒ **Swagger** - API Documentation - 🐳 **Docker Compose** - Container Orchestration - πŸ” **Helmet** - secure HTTP headers -- 😴 **Insomnia** - Insomnia config for endpoints - πŸ“ **ESLint** β€” Pluggable JavaScript linter -- πŸ’– **Prettier** - Opinionated Code Formatter ## Available Scripts -- `yarn start` - Start application -- `yarn start:dev` - Start application in watch mode -- `yarn start:prod` - Start built application -- `yarn start:hmr` - Start application with hot module replacement -- `yarn format` - Formats all the files inside src using prettier with config provided in `.prettierrc` -- `yarn lint` - Uses eslint to lint all the files inside src with config provided in `.eslintrc.cjs` -- `yarn orm migration:create` - Uses Mikroorm to create a migration file -- `yarn orm migration:up` - This command is used to run availablexisting migration files. -- `yarn orm migration:down` - This command is used to rollback migration. -- `yarn orm seeder:run` - This command is used to run existing seeders in `src/common/database`. +- `npm run start` - Start application +- `npm run start:dev` - Start application in watch mode +- `npm run start:prod` - Start built application +- `npm run start:hmr` - Start application with hot module replacement +- `npm run lint` - Uses eslint to lint all the files inside src with config provided in `eslint.config.js` +- `npm run orm migration:create` - Uses Mikroorm to create a migration file +- `npm run orm migration:up` - This command is used to run availablexisting migration files. +- `npm run orm migration:down` - This command is used to rollback migration. +- `npm run orm seeder:run` - This command is used to run existing seeders in `src/common/database`. All the scripts require `NODE_ENV` flag Additionally, you can also see the scripts in `justfile` which is a cross platform task runner. You can use it by -installing [just](https://github.com/casey/just#packages) and then running `just