Skip to content

Instantly share code, notes, and snippets.

@farnetani
Last active July 24, 2020 23:14
Show Gist options
  • Save farnetani/ed2d1b812181fd2d4c66a78b95de1967 to your computer and use it in GitHub Desktop.
Save farnetani/ed2d1b812181fd2d4c66a78b95de1967 to your computer and use it in GitHub Desktop.
Vscode - configurando JsHint, Prettier, Eslint com editorconfig

Arquivos de Exemplo abaixo

.prettierrc.json

{
  "trailingComma": "none",
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true
}

.jshintrc

{
    "esversion": 6
}

.eslintrc.js

module.exports = {
  root: true,
  env: {
    node: true,
    es6: true,
  },
  extends: [
    'plugin:vue/essential',
    '@vue/standard'
  ],
  parserOptions: {
    ecmaVersion: 2019,
    parser: 'babel-eslint'
  },
  rules: {
    'linebreak-style': 0,
    'jsx-quotes': [2, 'prefer-single'],
    'quotes': [1, 'single', {
      'avoidEscape': true
    }],
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
  }
}

.editorconfig

[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
quote_type = single

Ctrl+Shift+P : workspace.settings (json)

{
    "eslint.validate": [
        "html",
        "vue",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact"
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "vetur.format.defaultFormatter.js": "prettier",

    "prettier.trailingComma": "none",
    "prettier.jsxSingleQuote": true,
    "prettier.singleQuote": true,
    "vetur.format.defaultFormatterOptions": {
        "prettier": {
            "singleQuote": true
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment