Skip to content

Conversation

fdr
Copy link
Contributor

@fdr fdr commented Apr 9, 2025

No description provided.

enescakir and others added 6 commits August 4, 2023 16:44
It's a bit much for Tailwind CSS projects.
Currently, unquoted and name-only attributes are placed on a new line,
even when they could fit on the same line. This PR modifies this
behavior to keep them on the same line when possible.

Expected output:

    <input type="hidden" name="my-name" value="my-value" hidden/>

Current output:

    <input type="hidden" name="my-name" value="my-value"
      hidden/>
CSS classes cannot begin with digits. For this reason, Tailwind uses
`\3` to escape them. For instance, `2xl:col-span-10` is transformed into
`.\32xl\:col-span-10 { grid-column: span 10 / span 10; }` in the final
CSS file.

tailwindlabs/tailwindcss#3069

The current Tailwind CSS class sorter implementation does not handle
this correctly. As it cannot identify suitable classes beginning with
digits, it places them at the start of the sorted list.

Expected output:

    divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10

Current output:

    2xl:col-span-10 divide-y divide-gray-200 pb-10 lg:col-span-8 xl:col-span-9

I simply remove the escape characters from the class name.
`erb-formatter` uses the `syntax_tree` gem which has its own
formatting ideas about ruby, but, in our code base, so does Rubocop,
the latter which we configure extensively.  When they disagree, the
result is flip-flopping between tools, and that can fail the clover
build, in this CI step in `.github/workflows/ci.yml`:

    - name: Check that source code formatters and annotations make no changes
      run: git diff --stat --exit-code

This was motivated by an attempt to this `.rubocop.yml` configuration
in clover:

    Layout/DotPosition:
      EnforcedStyle: trailing

In this case, Rubocop moves method-chained periods to the ends of
lines, and then `erb-formatter` moves them back to the beginning
again.  This fails CI.

Given our more extensive rubocop use, and use of the `rubocop-erb` as
we also use it for rewriting, it's simpler to remove `syntax_tree` as
a dependency altogether, and not attempt to format code in
`erb-formatter`.  This keeps `erb-formatter` the rest of its
functionality, such as tag indentation.
@fdr fdr force-pushed the reintegrate-upstream branch from 177852d to df31744 Compare April 9, 2025 06:16
@fdr fdr closed this Apr 9, 2025
@enescakir enescakir deleted the reintegrate-upstream branch April 9, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants