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

TrailingCommaMultiLineRule not included by default #320

Closed
joncjordan opened this issue Nov 4, 2024 · 3 comments · Fixed by #321
Closed

TrailingCommaMultiLineRule not included by default #320

joncjordan opened this issue Nov 4, 2024 · 3 comments · Fixed by #321

Comments

@joncjordan
Copy link
Contributor

Rule(s) related to or rule(s) missing

TrailingCommaMultiLineRule

Expected behavior

The documentation states that TrailingCommaMultiLineRule is included by default, but it doesn't seem to be the case. If you look at \TwigCsFixer\Standard\TwigCsFixer it includes TrailingCommaSingleLineRule but not TrailingCommaMultiLineRule.

Actual behavior

I had to add the .twig-cs-fixer.php file to get this working properly, otherwise this rule was not being applied.

<?php

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

// And then add/remove/override some rules
$ruleset->addRule(new TwigCsFixer\Rules\Punctuation\TrailingCommaMultiLineRule());

$config = new TwigCsFixer\Config\Config();
$config->setRuleset($ruleset);

return $config;
@joncjordan
Copy link
Contributor Author

Hmm I guess this is where it was removed from the standard rules:
#259

Any plans for re-adding it?

@VincentLanglet
Copy link
Owner

The rule wasn't working properly on 2.x version and I had to make some changes in 3.x #265 to fix the bugs.

But sure, I'm opened to adding back this rule.

I didn't have time yet to try it on my personal work codebase. Does it work correctly for you (on a huge codebase ?)

Can you do the PR to add it back ? :)

@joncjordan
Copy link
Contributor Author

I wouldn't say my codebase is huge but I tested it against 175+ files and didn't experience any issues with it, and it fixed all my trailing comma issues in multi-line arrays. But I'm not sure I have any examples of where the bug was produced previously...

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 a pull request may close this issue.

2 participants