Skip to content

Commit 194382a

Browse files
committed
feat: twig-cs-fixer
1 parent 7f6cd19 commit 194382a

10 files changed

+174
-11
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@
3030
.phpunit.result.cache
3131
.phpunit.cache
3232
###< phpunit/phpunit ###
33+
34+
###> vincentlanglet/twig-cs-fixer ###
35+
/.twig-cs-fixer.cache
36+
###< vincentlanglet/twig-cs-fixer ###

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ lint-container: ## Lint the Symfony DI container
7171
lint-twig: ## Lint Twig files
7272
@bin/console lint:twig templates/
7373

74+
fix-twig: ## Fix Twig files with Twig CS Fixer
75+
@vendor/bin/twig-cs-fixer lint --fix ./templates
76+
7477
lint-yaml: ## Lint YAML files
7578
@bin/console lint:yaml --parse-tags config/
7679

7780
cs: ## Run all CS checks
7881
cs: fix-php stan
7982

8083
lint: ## Run all lints
81-
lint: lint-php lint-container lint-twig lint-yaml
84+
lint: lint-php lint-container lint-twig lint-yaml fix-twig
8285

8386
ci: ## Run CI locally
8487
ci: coverage warmup cs lint

castor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ function lint_twig(): int
205205
return exit_code('bin/console lint:twig templates/');
206206
}
207207

208+
#[AsTask(name: 'fix-twig', namespace: 'cs', description: 'Lint Twig files', aliases: ['fix-twig'])]
209+
function fix_twig(): int
210+
{
211+
title('fix:twig');
212+
213+
return exit_code('@vendor/bin/twig-cs-fixer lint --fix ./templates');
214+
}
215+
208216
#[AsTask(name: 'yaml', namespace: 'lint', description: 'Lint Yaml files', aliases: ['lint-yaml'])]
209217
function lint_yaml(): int
210218
{

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
"symfony/maker-bundle": "^1.61",
5858
"symfony/requirements-checker": "^2.0",
5959
"symfony/stopwatch": "~7.1.0",
60-
"symfony/web-profiler-bundle": "~7.1.0"
60+
"symfony/web-profiler-bundle": "~7.1.0",
61+
"vincentlanglet/twig-cs-fixer": "^3.3"
6162
},
6263
"replace": {
6364
"symfony/polyfill-ctype": "*",

composer.lock

Lines changed: 141 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

symfony.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,14 @@
183183
},
184184
"twig/extra-bundle": {
185185
"version": "v3.5.1"
186+
},
187+
"vincentlanglet/twig-cs-fixer": {
188+
"version": "3.3",
189+
"recipe": {
190+
"repo": "github.com/symfony/recipes-contrib",
191+
"branch": "main",
192+
"version": "0.6",
193+
"ref": "e4da12a48e8138479bd24a675321bcfd84950266"
194+
}
186195
}
187196
}

templates/App/Controller/FormAction.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<fieldset>
6565
<legend>&nbsp;Enter your information 🖋&nbsp;</legend>
6666

67-
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
67+
{{ form(form, {attr: {novalidate: 'novalidate'}}) }}
6868
</fieldset>
6969
{% endif %}
7070
{% endblock %}

templates/App/Controller/StimulusAction.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</div>
6565

6666
<div col="3/4">
67-
<div {{ stimulus_controller('api', {url: path(ctrl_fqcn('SlugifyAction'))} )}}>
67+
<div {{ stimulus_controller('api', {url: path(ctrl_fqcn('SlugifyAction'))}) }}>
6868
<label for="title">
6969
Enter a blog post title below:
7070
<input type="text" required name="title"

templates/_form.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div id="user-form">
2-
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
3-
</div>
2+
{{ form(form, {attr: {novalidate: 'novalidate'}}) }}
3+
</div>

templates/base.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<input type="checkbox">
2525
<header>
2626
<a href="{{ path(ctrl_fqcn('HomeAction')) }}">
27-
{# <img alt="{{ brand }}" src="img/your-logo.svg">{{ brand_html|raw }}#}
27+
{# <img alt="{{ brand }}" src="img/your-logo.svg">{{ brand_html|raw }} #}
2828
{{ brand_html|raw }}
2929
</a>
3030
</header>
@@ -53,7 +53,7 @@
5353
</section>
5454

5555
<footer>
56-
<h5>{{ brand|raw }} v{{ sf_version }} ({{ 'frankenphp' in php_sapi ? php_sapi : 'PHP '~php_sapi }} {{ php_version }})</h5>
56+
<h5>{{ brand|raw }} v{{ sf_version }} ({{ 'frankenphp' in php_sapi ? php_sapi : 'PHP ' ~ php_sapi }} {{ php_version }})</h5>
5757

5858
<grid>
5959
<div fx="" col="3/4">

0 commit comments

Comments
 (0)