Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
How to add eslint rules to prettier in Vue project on VsCode

I would like to add rules to my existing formating rules

Actually I'm using a .vscode/settings.json file with the following

{
 "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "eslint.validate": ["javascript"],
  "vetur.useWorkspaceDependencies": true,
  "vetur.validation.style": false,
  "vetur.format.defaultFormatter.scss": "prettier",
  "vetur.format.defaultFormatter.css": "prettier",
  "vetur.format.defaultFormatter.js": "prettier-eslint",
  "vetur.format.defaultFormatter.html": "prettier",
  "[vue]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "octref.vetur",
  },
  "eslint.format.enable": true
} 

It works well but let's say i want to add a rule for exemple vue-script-indent

I don't know how to add this rules to my existing config

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

vue/script-indent (ESLint rule)

From the eslint-plugin-vue docs:

Create .eslintrc.* file to configure rules. See also: http://eslint.org/docs/user-guide/configuring.

Example .eslintrc.js:

module.exports = {
  extends: [
    // add more generic rulesets here, such as:
    // 'eslint:recommended',
    'plugin:vue/essential'
  ],
  rules: {
    // override/add rules settings here, such as:
    // 'vue/no-unused-vars': 'error'
  }
}

So in your .eslintrc.js, add the script-indent rule to the rules property. Note the eslint-plugin-vue rule names are all prefixed with vue/, so use "vue/script-indent" in the rules property below:

module.exports = {
  extends: [
    'plugin:vue/essential',
  ],
  rules: {
    'vue/script-indent': ['error', 2, {
      baseIndent: 0,
      switchCase: 0,
      ignores: []
    }]
  }
}

Finally, ensure you have the ESLint VS Code extension installed to enable formatting from the IDE.

Prettier

Your workspace settings point to Prettier, so make sure your Prettier options align with the vue/script-indent rule. That is, the tabWidth value in Prettier should match the tab width in vue/script-indent.

For example, to require a 4-space tab width, create .prettierrc in the root of your project with the following JSON:

// .prettierrc
{             👇
  "tabWidth": 4
}

...and update .eslintrc.js to match:

// .eslintrc.js
module.exports = {
  rules: {                         👇
    'vue/script-indent': ['error', 4, {
      baseIndent: 0,
      switchCase: 0,
      ignores: []
    }]
  }
}

Also ensure you have the Prettier VS Code extension installed to enable formatting from the IDE.

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda