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

[vincentlanglet/twig-cs-fixer] add default config and add message #1696

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

JohJohan
Copy link
Contributor

Q A
License MIT
Packagist vincentlanglet/twig-cs-fixer

add default config and add message

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 21, 2024 13:39
Copy link

github-actions bot commented Oct 21, 2024

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1696/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1696/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'vincentlanglet/twig-cs-fixer:^3.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

vincentlanglet/twig-cs-fixer

0.6 vs 3.0
diff --git a/vincentlanglet/twig-cs-fixer/3.0/post-install.txt b/vincentlanglet/twig-cs-fixer/3.0/post-install.txt
new file mode 100644
index 00000000..9926c2fc
--- /dev/null
+++ b/vincentlanglet/twig-cs-fixer/3.0/post-install.txt
@@ -0,0 +1,4 @@
+
+ You can create a `.twig-cs-fixer.dist.php` and configure to your needs 
+ See https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md 
+ For configuration explanation. 

auto-merge was automatically disabled October 21, 2024 13:51

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 21, 2024 13:51
vincentlanglet/twig-cs-fixer/0.6/post-install.txt Outdated Show resolved Hide resolved
vincentlanglet/twig-cs-fixer/0.6/post-install.txt Outdated Show resolved Hide resolved
auto-merge was automatically disabled October 21, 2024 14:08

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 21, 2024 14:08
auto-merge was automatically disabled October 21, 2024 14:09

Head branch was pushed to by a user without write access

@JohJohan JohJohan requested a review from fabpot October 21, 2024 14:09
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 21, 2024 14:10
@fabpot
Copy link
Member

fabpot commented Oct 21, 2024

@VincentLanglet Maybe you can chime in here?

Comment on lines 9 to 15
//$ruleset->addRule(new TwigCsFixer\Rules\File\FileExtensionRule());
//$ruleset->removeRule(TwigCsFixer\Rules\Whitespace\EmptyLinesRule::class);
//$ruleset->overrideRule(
// new TwigCsFixer\Rules\Punctuation\PunctuationSpacingRule(
// ['}' => 1],
// ['{' => 1],
// )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those classes doesn't exists in 0.6 version cf
https://github.com/VincentLanglet/Twig-CS-Fixer/tree/0.6.0/src

I don't think it's worth to have a recipe for < 3.0.0 since I only maintain the latest major.
So it seems better to only create

vincentlanglet/twig-cs-fixer/3.0/

files, no ?

<bg=green;fg=white></>
<bg=green;fg=white> You can edit the `.twig-cs-fixer.php` to your needs </>
<bg=green;fg=white> See https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md </>
<bg=green;fg=white> For configuration explanation: </>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<bg=green;fg=white> For configuration explanation: </>
<bg=green;fg=white> For configuration explanation. </>

?

]
],
"copy-from-recipe": {
".twig-cs-fixer.php": ".twig-cs-fixer.php"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno if we should provide this default config file.

Without config file, I believe my tool is already using TwigCsFixer standard by default. Which means that if you add this config file like this without changing anything in it, it's just a useless file.

So maybe the post-install message is enough ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats true i just wanted to provide the configuration file with default config and examples from the docs so that the user could edit if they like. I let it up for you to decide to keep it or not :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it can work without the config file, I don't know if it's a good idea to add automatically a config.
I'm unsure how other tools work (and if they can work without a config file)...

But the post-install.txt is great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah i think its a good addition as you can indicate you can make changes to the config like adding more rule, if you dont change anything you still get the same results. So i'm for it.

As for others i see php-cs-fixer has config: https://github.com/symfony/recipes/blob/main/friendsofphp/php-cs-fixer/3.0/.php-cs-fixer.dist.php but this doesn't work without it i assume

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the file

Copy link
Member

@diimpp diimpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for contribution.

I assume you've chosen 0.6 due to the last version supporting PHP 7.4, but because of changes in the twig-cs-fixer config file, this recipe will crash for users on 2.0/3.0; hence, you will need to add 0.6, 2.0 (Standard class name is Twig) and 3.0. (I didn't check if 0.6 and 1.0 are any different in the config file syntax)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use the basic Twig standard, another standard and/or add/remove a rule, you can provide your own configuration with a .twig-cs-fixer.php or .twig-cs-fixer.dist.php file

--- vincentlanglet/twig-cs-fixer/0.6/.twig-cs-fixer.php
+++ vincentlanglet/twig-cs-fixer/0.6/.twig-cs-fixer.dist.php

I assume it should be a .dist file.

$ruleset = new TwigCsFixer\Ruleset\Ruleset();

// You can start from a default standard
$ruleset->addStandard(new TwigCsFixer\Standard\TwigCsFixer());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard class at 0.6/1.0 is called Generic.

$ruleset->addStandard(new TwigCsFixer\Standard\Generic());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revert for 0.6 see: #1696 (comment)

auto-merge was automatically disabled October 22, 2024 07:06

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 22, 2024 07:06
@JohJohan JohJohan requested a review from diimpp October 29, 2024 08:40
@diimpp
Copy link
Member

diimpp commented Dec 5, 2024

Folks @VincentLanglet @JohJohan , what do we decide about it? Does this package needs recipe or not?

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Dec 5, 2024

Recipe would be useful to update gitignore file for example.

But providing a .twig-cs-fixer.dist.php file by default is not needed.

@JohJohan
Copy link
Contributor Author

JohJohan commented Dec 5, 2024

Recipe would be useful to update gitignore file for example.

But providing a .twig-cs-fixer.dist.php file by default is not needed.

Okay i will remove the .twig-cs-fixer.dist.php file

auto-merge was automatically disabled December 5, 2024 11:20

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) December 5, 2024 11:20
auto-merge was automatically disabled December 5, 2024 13:07

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) December 5, 2024 13:07
@symfony-recipes-bot symfony-recipes-bot merged commit 1b80c59 into symfony:main Dec 6, 2024
1 of 2 checks passed
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.

5 participants