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 29, 2024
1 parent 0f45fb1 commit 9c04d9d
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 107 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 ###
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ lint-container: ## Lint the Symfony DI container
lint-twig: ## Lint Twig files
@bin/console lint:twig templates/

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

fix-twig-cs-fixer: ## 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/

fix: ## Run all fixers
fix: fix-php
fix: fix-php fix-twig-cs-fixer

lint: ## Run all linters
lint: stan lint-php lint-container lint-twig lint-yaml
lint: stan lint-php lint-container lint-twig lint-twig-cs-fixer lint-yaml

ci: ## Run CI locally
ci: coverage warmup lint
Expand Down
24 changes: 21 additions & 3 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ function fix_all(): int
{
title('fix:all');
$ec1 = fix_php();
$ec2 = fix_twig_cs_fixer();
io()->newLine();

return success($ec1);
return success($ec1 + $ec2);
}
#[AsTask(name: 'container', namespace: 'lint', description: 'Lint the Symfony DI container', aliases: ['lint-container'])]
function lint_container(): int
Expand All @@ -204,6 +205,22 @@ function lint_twig(): int
return exit_code('bin/console lint:twig templates/');
}

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

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

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

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 All @@ -220,9 +237,10 @@ function lint_all(): int
$ec2 = lint_php();
$ec3 = lint_container();
$ec4 = lint_twig();
$ec5 = lint_yaml();
$ec5 = lint_twig_cs_fixer();
$ec6 = lint_yaml();

return success($ec1 + $ec2 + $ec3 + $ec4 + $ec5);
return success($ec1 + $ec2 + $ec3 + $ec4 + $ec5 + $ec6);

// if you want to speed up the process, you can run these commands in parallel
// parallel(
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"symfony/maker-bundle": "^1.61",
"symfony/requirements-checker": "^2.0",
"symfony/stopwatch": "~7.2.0",
"symfony/web-profiler-bundle": "~7.2.0"
"symfony/web-profiler-bundle": "~7.2.0",
"vincentlanglet/twig-cs-fixer": "^3.3"
},
"replace": {
"symfony/polyfill-ctype": "*",
Expand Down
Loading

0 comments on commit 9c04d9d

Please sign in to comment.