A react-typescript boilerplate including
- It also adds feature of idetifying errors at compile time rather than scratching our head at runtime?
- An Code formatter
- Supports many languages
- Generate prettier rules here
We already have
eslintas an inner-dependency from react-scripts
To init eslint config run & choose options accordingly
npx eslint --init
- Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style.
- Whenever we inti Git in our project, it automatically comes with features called hooks.
- hooks ex:
- If we want to ensure before we actually create a commit using the
git commit, that our code was properly
formatted, we could write a
Clone / Download this repo.
Inside the project open a terminal and run:
This will install all the project dependencies.
To start the development server run:
Run the below command to get a list of all unformatted code in the project.
yarn run format:check
Run the below command to fix the unformatted code!
yarn run format:fix
We can run the below script present in package.json
yarn run lint
Run parallel commands at once using concurrently
concurrently \"yarn 1st-cmd\" \"yarn run 2st-cmd\" \"yarn run nth-cmd\""
- Another great thing about lint-staged is that it automatically does the git add on the modified files. So, if we are doing prettier — write or eslint — fix, we don’t have to stage the changes manually.
We do format:fix & run our validate script on the staged files
git add .and
git commit -m "message"
the lint-staged kicks in and runs?