Unite Your Angular Coding Style With Teammates By Visual Studio Code & ESLint & Prettier
Brief
Hello Visitor ~
Todays I will guide you to setup Visual Studio Code and ESLint and Prettier, let editor auto-format and auto-fix your code for you and your coworker or contributor, it will becomes your lifesaver, free your hands on fixing errors and align coding style with teammates.
Let me read those documents, and organize things for you.
Steps
There are only 3 steps for you, it is very easy to follow my steps to set everything up
- Setup Angular and ESLint
- Integrate Prettier and ESLint
- Setup Visual Studio Code
Setup Angular and ESLint
For Angular project which started at Angular 12
1 | ng add @angular-eslint/schematics |
If your Angular project was started at Angular 11 or belows, you should read and follow this link
Integrate Prettier and ESLint
1 | npm install --save-dev \ |
Create .prettierrc.json
1 | { |
Update eslintrc.json
1 | { |
Setup Visual Studio Code
Create or update extensions.json
1 | { |
Create or update settings.json
1 | // add all these config |
(Optional)Apply Airbnb’s TypeScript coding style to ESLint
1 | npm install --save-dev eslint-config-airbnb-typescript |
Update eslintrc.json
1 | { |
References
ng + eslint
eslint + airbnb-typescript
eslint + prettier
Unite Your Angular Coding Style With Teammates By Visual Studio Code & ESLint & Prettier