Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htmlWhitespaceSensitivity is not being taken into account #93

Open
luveqz opened this issue Feb 15, 2024 · 4 comments
Open

htmlWhitespaceSensitivity is not being taken into account #93

luveqz opened this issue Feb 15, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@luveqz
Copy link

luveqz commented Feb 15, 2024

Problem

Even when I set the htmlWhitespaceSensitivity rule to strict, the plugin keeps turning this:

into this:

<p>
  me
  @example.com.
</p>

Or even this:

<img
  @class([
    // This is valid a comment.
    $coverUrl ? "object-center" :"object-left-top",
  ])
/>

into this:

<img
  @class([
    //Thisisvalidacomment.$coverUrl?"object-center":"object-left-top",
  ])
/>

Demo

Open this minimal StackBlitz demo and run:

npm run lint app.blade.php
@JohnathonKoster
Copy link
Contributor

JohnathonKoster commented Feb 15, 2024

The plugin currently overrides this setting for a variety of reasons, and is a non-trivial thing to take into account at this time (#91 (comment)).

The array directive item is a separate issue, not related to whitespace sensitivity that I'd look at separately (the Laravel Pint integration works correctly for this scenario, however).

@JohnathonKoster
Copy link
Contributor

JohnathonKoster commented Feb 15, 2024

@luveqz

I've released v2.1.2 to help prevent the issue that wrecked your array input. If you're curious, it was caused by an internal workaround that prevents items like the following from being shoved to a single-line by prettier:

@props([
    'value',
    'value',
    'value',
    'value',
    'value',
])

This internal workaround was a bit too aggressive with what it was doing so I added a few checks to stop it from going into this logic.

Re. the htmlWhitespaceSensitivity setting, unfortunately this isn't available just yet. This does come up quite a bit though so
I will start digging into it sometime this weekend (but may be a bit before its ready). Hope the array fix helps in the meantime!

@claytonrcarter
Copy link
Contributor

I will start digging into it sometime this weekend

@JohnathonKoster ❤️ and if you would like some additional eyes or help, I would be happy to chip in. We have a number of templates that are mostly HTML w/ just a little Blade sprinkled here and there, so support for htmlWhitespaceSensitivity will be big improvement. I'm happy to help with testing your changes, once you have some! 😄

@JohnathonKoster
Copy link
Contributor

Just an update that this is currently slated for the next major release of the plugin. Hopefully within the next few weeks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants