-
Notifications
You must be signed in to change notification settings - Fork 9
Linting
Michael Rudloff edited this page Sep 23, 2021
·
1 revision
- Install Prettier extension
- Press
CTRL + ,to open VSC settings and search for Prettier- Set
format on save: true - Check off
Prettier: require config
- Set
- Type into the terminal
npm install -D prettier - Create a new file
.prettierrcand put an empty object into it{} - In package.json, create a script called "format": prettier --write "src
-
Install ESLint extension
-
npm install -D eslint eslint-config-prettier -
Create a
.eslintrc.jsonfilePut the following code into this file
{ "extends": ["eslint:recommended", "prettier"], "parserOptions": { "ecmaVersion": 2021 }, "env": { "es6": true, "browser": true, "node": true, "commonjs": true }, "settings": {} }
In scripts in package.json
"scripts": {
"format": "prettier --write \"**/*.{js,jsx}\"",
"lint": "eslint \"**/*.{js,jsx}\" --quiet",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix"
},
Now to run format or lint your code, simply run npm run { command } - for example, npm run format, npm run lint, npm run lint:fix