Skip to content

Instantly share code, notes, and snippets.

@merciless
Last active October 16, 2020 06:07
Show Gist options
  • Save merciless/dec56feed417b3984aa4404d7fa17f7f to your computer and use it in GitHub Desktop.
Save merciless/dec56feed417b3984aa4404d7fa17f7f to your computer and use it in GitHub Desktop.
ESLint, Prettier, Vetur + VSCode
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
module.exports = {
root: true,
env: {
node: true,
browser: true,
},
extends: [
'plugin:vue/recommended',
'eslint:recommended',
'prettier/vue',
'plugin:prettier/recommended',
],
rules: {
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
quotes: [2, 'single', { avoidEscape: true }],
},
globals: {
$nuxt: true,
},
parserOptions: {
parser: 'babel-eslint',
},
};
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false
}

I was playing around with setting up ESLint, Prettier, Vetur + VSCode, that was hard but I did it. By the way I'm using nuxt in my project.

Setup

npm install - D eslint babel-eslint eslint-config-prettier eslint-plugin-prettier eslint-plugin-vue eslint-loader prettier

or with yarn

yarn add - D eslint babel-eslint eslint-config-prettier eslint-plugin-prettier eslint-plugin-vue eslint-loader prettier

Then simply create config files listed below. settings.json is vscode config file.
Wish you a good luck. 🤪

{
"editor.formatOnSave": true,
"vetur.validation.template": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment