-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.php
145 lines (138 loc) · 4.52 KB
/
ecs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
declare(strict_types=1);
/**
* /ecs.php
*
* Configuration for `EasyCodingStandard` tool.
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
* @see https://raw.githubusercontent.com/tarlepp/symfony-flex-backend/master/ecs.php
*/
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer;
use PhpCsFixer\Fixer\NamespaceNotation\NoBlankLinesBeforeNamespaceFixer;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/bin',
__DIR__ . '/config',
]);
$ecsConfig->sets([SetList::PSR_12, SetList::CLEAN_CODE, SetList::COMMON]);
$ruleConfigurations = [
[
IncrementStyleFixer::class,
[
'style' => 'post',
],
],
[
CastSpacesFixer::class,
[
'space' => 'none',
],
],
[
YodaStyleFixer::class,
[
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
],
[
ConcatSpaceFixer::class,
[
'spacing' => 'one',
],
],
[
CastSpacesFixer::class,
[
'space' => 'none',
],
],
[
OrderedImportsFixer::class,
[
'imports_order' => ['class', 'function', 'const'],
],
],
[
NoSuperfluousPhpdocTagsFixer::class,
[
'remove_inheritdoc' => false,
'allow_mixed' => true,
'allow_unused_params' => false,
],
],
[
DeclareEqualNormalizeFixer::class,
[
'space' => 'single',
],
],
[
BlankLineBeforeStatementFixer::class,
[
'statements' => ['continue', 'declare', 'return', 'throw', 'try'],
],
],
[
BinaryOperatorSpacesFixer::class,
[
'operators' => [
'&' => 'align',
],
],
],
/* erik: use same syntax as VSC auto formatter */
[
DeclareEqualNormalizeFixer::class,
[
'space' => 'none',
],
],
];
array_map(static fn ($parameters) => $ecsConfig->ruleWithConfiguration(...$parameters), $ruleConfigurations);
$ecsConfig->skip([
// skip directory by absolute
__DIR__ . '/migrations',
__DIR__ . '/node_modules',
__DIR__ . '/frontend',
__DIR__ . '/storybook',
__DIR__ . '/translations',
__DIR__ . '/vendor',
NoMultilineWhitespaceAroundDoubleArrowFixer::class => null,
PhpdocNoPackageFixer::class => null,
PhpdocSummaryFixer::class => null,
PhpdocSeparationFixer::class => null,
BlankLineAfterOpeningTagFixer::class => null,
ClassAttributesSeparationFixer::class => null,
NoBlankLinesBeforeNamespaceFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
SingleLineThrowFixer::class => null,
PhpdocAlignFixer::class => null,
PhpdocToCommentFixer::class => null,
NativeFunctionInvocationFixer::class => null,
]);
};