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

Keep code-style of TypoScript #3997

Closed
julianhofmann opened this issue Jan 9, 2024 · 3 comments
Closed

Keep code-style of TypoScript #3997

julianhofmann opened this issue Jan 9, 2024 · 3 comments
Assignees
Labels

Comments

@julianhofmann
Copy link

Feature Request

TYPO3-rector should not change the code style of TypoScript - or handle it in a more configurable way.

As a team, we decide what the formatting of shared TypoScript code should look like. Tools such as helmich/typo3-typoscript-lint and appropriate configuration are used to ensure compliance with the coding guidelines.

Unfortunately, TYPO3-rector internally uses the PrettyPrinter when applying TypoScript rectors and sets (mostly fixed) coding styles.

@sabbelasichon
Copy link
Owner

@julianhofmann Tbh. Keeping existing code style is really difficult to achieve. Same applies for PHP itself. That´s the reason why tools like php-cs-fixer exist.

But feel free to open a Merge Request for all relevant settings which should be configurable.

@julianhofmann
Copy link
Author

I am aware of the difficulty. That's why the issue is formulated relatively openly.

If I have seen this correctly, it is unfortunately not possible to simply adopt the configuration of helmich/typo3-typoscript-lint. That would be the best solution here IMO.

What is unclear to me, is why rector reformats via PrettyPrinter at all?
In my opinion, this is a half-baked solution: a bit of formatting, but then not going into depth due to the possible variety of formatting.
Why not leave the formatting completely to the other available tools?

As I said, I understand the difficulty (and I have great respect for all contributors. Thank you very much!). However, a solution (or MR) requires some understanding of decisions and backgrounds.


Our workaround is to remove the TypoScriptFileProcessor depending on the context in rector configuration:

if (($_ENV['TYPO3_CONTEXT'] ?? '') !== 'Development') {
    $rectorConfig->services()->remove(TypoScriptFileProcessor::class);
}

@sabbelasichon
Copy link
Owner

sabbelasichon commented Jan 24, 2024

@julianhofmann I have added in this PR #4038 all possible options to configure the PrettyPrinter. Would this somehow solve your formatting issues as well?
Keeping all formatting by sniffing in the file is currently impossible for us due to lack of time and knowledge. Feel free to add all possible formatting options from helmich/typo3-typoscript-lint. I am not against it and there are no reasons whatsoever.

@sabbelasichon sabbelasichon self-assigned this Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants