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

286
Visualizações
Sorting tailwind classes inside a variable

I installed a prettier plugin for tailwind which works fine when sorting class names inside className attribute. However, it does not sort class names inside a variable like const className = 'pt-1 p-3'.

Is there anything I could do to make the sorting possible?

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

0

It looks like the plugin is only looking for the class and className JSX attributes for the string of utility-classes to sort. You can see that here in the plugin code:

function transformJavaScript(ast, { env }) {
  visit(ast, {
    JSXAttribute(node) {
      if (!node.value) {
        return
      }
      if (['class', 'className'].includes(node.name.name)) {

      ...

https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/main/src/index.js#L318

about 4 years ago · Juan Pablo Isaza Relatório

0

not allowed to fixed it in a constant ; because it is an attribut standard of the JSX. try to restract a class for it and thanks

about 4 years ago · Juan Pablo Isaza Relatório

0

I don't think there's currently a way to do this with the prettier-plugin-tailwindcss. However, if you're open to close alternatives, there's the vscode plugin Headwind.

Unfortunately, Headwind only runs on save or keybind (it's not integrated into the Prettier process for CI/CD, automation), and you must be using vscode for development. But if that fits your use case, you can use regexes to customize where in your source code Headwind runs. Instructions are 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