swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

use .prettierrc when it exist (instead of default prettier config with tabWidth: 2)

Open mixalbl4-127 opened this issue 3 years ago • 1 comments

@js2me https://prettier.io/docs/en/configuration.html

mixalbl4-127 avatar Jun 01 '21 05:06 mixalbl4-127

Hi, I simply updated the scripts in my project package.json as follows:

  "scripts": {
    ...
    "generate-api": "ts-node build-scripts/generate-api && eslint --fix \"src/models/swagger-gen/*.ts?(x)\"",
    "build": "yarn generate-api && react-scripts build",
    ...
  },

generate-api - it starts the swagger-typescript-api (customized via build-scripts/generate-api/index.ts file) and then starts the ESlint which also runs the prettier. The files .eslintrc and .prettierrc are used from the project.

build - first generates the API files and then builds my React app in standard way

I think you can easily use this approach regardless of the framework (React, Angular, Vue, ...) or package manager (yarn, npm, ...) you use.

jjaros avatar Oct 06 '22 10:10 jjaros