Skip to content

Commit

Permalink
Style: Add internal rules configuration for the project itself
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Apr 25, 2024
1 parent 2a54925 commit 48837fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecs-internal.php export-ignore
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"@test"
],
"analyze": [
"vendor/bin/ecs check src/ tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi",
"vendor/bin/ecs check --config=ecs-internal.php --ansi",
"vendor/bin/phpstan analyze -c phpstan.neon --ansi"
],
"fix": [
"@composer normalize",
"vendor/bin/ecs check ./src/ ./tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi --fix"
"vendor/bin/ecs check --config=ecs-internal.php --ansi --fix"
],
"lint": [
"vendor/bin/parallel-lint -j 10 -e php ./src ./tests ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php",
Expand Down
22 changes: 22 additions & 0 deletions ecs-internal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

/**
* Internal rules configuration for the lmc/coding-standard project itself
*/
return ECSConfig::configure()
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
->withRootFiles()
->withSets(
[
__DIR__ . '/ecs.php',
],
)
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation'])
->withConfiguredRule(
LineLengthFixer::class,
['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false],
);
5 changes: 4 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@
->withConfiguredRule(ArraySyntaxFixer::class, ['syntax' => 'short'])
// The body of each structure MUST be enclosed by braces. Braces should be properly placed
// @TODO move configuration to BracesPositionFixer after BracesFixer is not included in PSR-12 check anymore
->withConfiguredRule(BracesFixer::class, ['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true])
->withConfiguredRule(
BracesFixer::class,
['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true],
)
// Class, trait and interface elements must be separated with one or none blank line
->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['method' => 'one']])
// Visibility MUST be declared on all properties, methods and class constants
Expand Down

0 comments on commit 48837fb

Please sign in to comment.