[2.0.0-beta4] Use Drupal YAML dumper instead of Symfony?

Created on 16 October 2024, 3 months ago

Problem/Motivation

In https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/modules/ui_p... we use Symfony\Component\Yaml\Yaml

Maybe this is too low level and it will be better to use the Drupal tool: https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Serializatio...

Also, what we are dumping is not compliant with prettier linter with default settings:

  • strings: Symfony does simple quotes, Prettier does double quotes
  • empty objects: Symfony does { }, Prettier does {}
  • arrays of objects: Symfony adds a line break after dash, Prettier doesn't

Proposed resolution

Try using Drupal\Component\Serialization\Yaml instead of Symfony\Component\Yaml\Yaml

Is it still working? If yes, do we dump something closer to prettier?

πŸ“Œ Task
Status

Active

Version

2.0

Component

UI Patterns Legacy [2.x only]

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • First commit to issue fork.
  • Pipeline finished with Success
    3 months ago
    Total: 328s
    #311850
  • πŸ‡ΊπŸ‡¦Ukraine SmovS Lutsk

    I set the Drupal YAML dumper instead of Symfony.
    The Drupal Yaml:encode() sets the indentation to 2 by default as we had.
    I am not sure about the "The level where you switch to inline YAML". parameter.
    We used 10 for this parameter but Drupal Yaml:encode() sets PHP_INT_MAX.

    Please review the MR !245

  • πŸ‡«πŸ‡·France just_like_good_vibes PARIS

    hello, nice work.
    The code now is using Drupal\Component\Serialization\Yaml instead of Symfony\Component\Yaml\Yaml ,
    but we did not really improved yet in terms of prettier compliance. This is because the former class is using the latter class internally.
    Do we introduce something on top to tackle a better prettier compatibility ? There is no ready to use PHP code or library to do that.
    We only need it when we write components in the legacy module. Maybe it is better to let this task to the prettier linter itself?
    I suggest to merge this issue like that.

  • πŸ‡«πŸ‡·France pdureau Paris

    Better prettier compliance would be a nice side effect. Now we use Drupal\Component\Serialization\Yaml, if we can improve prettier compliance with just a few tweaks, let's do it. If not, it is OK.

    But worse prettier compliance is not acceptable. If the change low the compliance, let's keep Symfony\Component\Yaml\Yaml

  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡«πŸ‡·France pdureau Paris

    prettier compliance is the same, so it is mergeable in my opinion

    Do we introduce something on top to tackle a better prettier compatibility ? There is no ready to use PHP code or library to do that.
    We only need it when we write components in the legacy module. Maybe it is better to let this task to the prettier linter itself?

    Yes, let's do nothing more.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024