Skip to content

Commit

Permalink
feat: twig-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Nov 21, 2024
1 parent 7f6cd19 commit 194382a
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
.phpunit.result.cache
.phpunit.cache
###< phpunit/phpunit ###

###> vincentlanglet/twig-cs-fixer ###
/.twig-cs-fixer.cache
###< vincentlanglet/twig-cs-fixer ###
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ lint-container: ## Lint the Symfony DI container
lint-twig: ## Lint Twig files
@bin/console lint:twig templates/

fix-twig: ## Fix Twig files with Twig CS Fixer
@vendor/bin/twig-cs-fixer lint --fix ./templates

lint-yaml: ## Lint YAML files
@bin/console lint:yaml --parse-tags config/

cs: ## Run all CS checks
cs: fix-php stan

lint: ## Run all lints
lint: lint-php lint-container lint-twig lint-yaml
lint: lint-php lint-container lint-twig lint-yaml fix-twig

ci: ## Run CI locally
ci: coverage warmup cs lint
Expand Down
8 changes: 8 additions & 0 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ function lint_twig(): int
return exit_code('bin/console lint:twig templates/');
}

#[AsTask(name: 'fix-twig', namespace: 'cs', description: 'Lint Twig files', aliases: ['fix-twig'])]
function fix_twig(): int
{
title('fix:twig');

return exit_code('@vendor/bin/twig-cs-fixer lint --fix ./templates');
}

#[AsTask(name: 'yaml', namespace: 'lint', description: 'Lint Yaml files', aliases: ['lint-yaml'])]
function lint_yaml(): int
{
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"symfony/maker-bundle": "^1.61",
"symfony/requirements-checker": "^2.0",
"symfony/stopwatch": "~7.1.0",
"symfony/web-profiler-bundle": "~7.1.0"
"symfony/web-profiler-bundle": "~7.1.0",
"vincentlanglet/twig-cs-fixer": "^3.3"
},
"replace": {
"symfony/polyfill-ctype": "*",
Expand Down
144 changes: 141 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,14 @@
},
"twig/extra-bundle": {
"version": "v3.5.1"
},
"vincentlanglet/twig-cs-fixer": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "0.6",
"ref": "e4da12a48e8138479bd24a675321bcfd84950266"
}
}
}
2 changes: 1 addition & 1 deletion templates/App/Controller/FormAction.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<fieldset>
<legend>&nbsp;Enter your information 🖋&nbsp;</legend>

{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
{{ form(form, {attr: {novalidate: 'novalidate'}}) }}
</fieldset>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion templates/App/Controller/StimulusAction.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</div>

<div col="3/4">
<div {{ stimulus_controller('api', {url: path(ctrl_fqcn('SlugifyAction'))} )}}>
<div {{ stimulus_controller('api', {url: path(ctrl_fqcn('SlugifyAction'))}) }}>
<label for="title">
Enter a blog post title below:
<input type="text" required name="title"
Expand Down
4 changes: 2 additions & 2 deletions templates/_form.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="user-form">
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
</div>
{{ form(form, {attr: {novalidate: 'novalidate'}}) }}
</div>
4 changes: 2 additions & 2 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<input type="checkbox">
<header>
<a href="{{ path(ctrl_fqcn('HomeAction')) }}">
{# <img alt="{{ brand }}" src="img/your-logo.svg">{{ brand_html|raw }}#}
{# <img alt="{{ brand }}" src="img/your-logo.svg">{{ brand_html|raw }} #}
{{ brand_html|raw }}
</a>
</header>
Expand Down Expand Up @@ -53,7 +53,7 @@
</section>

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

<grid>
<div fx="" col="3/4">
Expand Down

0 comments on commit 194382a

Please sign in to comment.