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

152
Visualizações
How to apply only single rule or set of rules with prettier (or prettierx)

Would like to use prettier (or prettierx or similar tool) in the following way:

npx prettier --no-defaults --no-semi --write test.js

where --no-defaults is a hypothetical option to ignore & not apply any other rules except for those specified (ONLY apply the --no-semi rule/option in this case). In otherwords, I only want to run prettier and apply a single rule or the set of rules I specify.

I read through the docs and seems there is no obvious way to do this; I realize prettierx is supposed to be less opinionated but also does not seem to offer a way to run without applying its own defaults.

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

0

You can use ESLint for that purpose, a one-liner approach for the above example would look like this:

eslint --fix --rule 'semi: [error, never]' test.js

To define multiple rules, separate them using commas, or use the option multiple times. If adding multiple rules it's recommended to add them to a dedicated file like eslintrc.json or declare them in package.json where they will be automatically parsed by eslint, thus eliminating the need for rule option in command line. More on configuration here.

Caution: Providing rules through command line will merge them with existing eslint config if present in your project, in order to avoid that you can add a flag like this:

eslint --no-eslintrc --fix --rule 'semi: [error, never]' test.js

Most of the layout and formatting rules are fixable by eslint, a comprehensive list is given here. To know more about eslint and other helpful command line flags see here and 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