A portable eslint/prettier config setup with vscode.
-
If you don't already have a
package.json
file, create one withnpm init
. -
Then we need to install everything needed by the config:
npx install-peerdeps --dev eslint-config-pete
-
You can see in your package.json there are now a big list of devDependencies.
-
Create a
.eslintrc
file in the root of your project's directory (it should live where package.json does). Your.eslintrc
file should look like this:
{
"extends": [
"pete"
]
}
- Update VSCode settings:
"editor.formatOnSave": true,
// turn it off for JS and JSX, we will do this via eslint
"[javascript]": {
"editor.formatOnSave": false
},
// tell the ESLint plugin to run on save
"eslint.autoFixOnSave": true,
// vetur config
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-expand-multiline",
},
"prettyhtml": {
"printWidth": 100,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
},
"prettier": {
"singleQuote": true,
"trailingComma": "none"
}
}
Credit Wes Bos https://github.com/wesbos/eslint-config-wesbos