• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

100
Vistas
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 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

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 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda