Skip to content

Commit

Permalink
feat: lint twig files with twigstan
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Oct 18, 2024
1 parent 49bb27a commit b9ea9dd
Show file tree
Hide file tree
Showing 15 changed files with 666 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ jobs:
run: castor lint:php
- name: PHPStan static analysis
run: castor stan
- name: Lint Twig templates with twigstan
run: castor lint:twigstan

# The end. 🙃
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 ###

###> twigstan/twigstan ###
.twigstan
###< twigstan/twigstan ###
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: ## Outputs this help screen
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements

# You can modify the coverage threshold here
COVERAGE_THRESHOLD = 100
COVERAGE_THRESHOLD = 94

## —— Symfony binary 💻 ————————————————————————————————————————————————————————
start: ## Serve the application with the Symfony binary
Expand Down
13 changes: 11 additions & 2 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// use function Castor\parallel;

// You can modify the coverage threshold here
const COVERAGE_THRESHOLD = 100;
const COVERAGE_THRESHOLD = 94;

function title(string $name): void
{
Expand Down Expand Up @@ -205,6 +205,14 @@ function lint_twig(): int
return exit_code('bin/console lint:twig templates/');
}

#[AsTask(name: 'twig', namespace: 'stan', description: 'Lint Twig files with twigstan', aliases: ['lint-twigstan'])]
function lint_twigstan(): int
{
title('lint:twigstan');

return exit_code(' vendor/bin/twigstan');
}

#[AsTask(name: 'yaml', namespace: 'lint', description: 'Lint Yaml files', aliases: ['lint-yaml'])]
function lint_yaml(): int
{
Expand All @@ -220,7 +228,8 @@ function lint_all(): int
$ec1 = lint_php();
$ec2 = lint_container();
$ec3 = lint_twig();
$ec4 = lint_yaml();
$ec4 = lint_twigstan();
$ec5 = lint_yaml();

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

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",
"twigstan/twigstan": "dev-main"
},
"replace": {
"symfony/polyfill-ctype": "*",
Expand Down
Loading

0 comments on commit b9ea9dd

Please sign in to comment.