-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Alex Skrypnyk <[email protected]>
- Loading branch information
1 parent
55674fd
commit df53192
Showing
11 changed files
with
125 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ Ssl | |
Suboptimal | ||
TBD | ||
Terminalizer | ||
Twigcs | ||
Twig CS Fixer | ||
UAT | ||
UI | ||
UUID | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Twig CS Fixer | ||
|
||
https://github.com/VincentLanglet/Twig-CS-Fixer | ||
|
||
> The missing checkstyle for twig! | ||
> | ||
> Twig CS Fixer aims to be what phpcs is to php. It checks your codebase for violations on coding standards. | ||
DrevOps comes with [pre-configured Twig-cs-fixer ruleset](../../../../.twig-cs-fixer.php) for Drupal projects. | ||
|
||
## Usage | ||
|
||
```shell | ||
vendor/bin/twig-cs-fixer | ||
``` | ||
or | ||
```shell | ||
ahoy lint-fe | ||
``` | ||
|
||
## Configuration | ||
|
||
See [configuration reference](https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md). | ||
|
||
All global configuration takes place in the [`.twig-cs-fixer.php`](../../../../.twig-cs-fixer.php) file. | ||
|
||
Targets include custom modules and themes. | ||
|
||
Adding or removing targets: | ||
```php | ||
$ruleset = new TwigCsFixer\Ruleset\Ruleset(); | ||
$ruleset->addStandard(new TwigCsFixer\Standard\Twig()); | ||
|
||
$finder = new TwigCsFixer\File\Finder(); | ||
$finder->in(__DIR__ . '/web/modules/custom'); | ||
$finder->in(__DIR__ . '/web/themes/custom'); | ||
|
||
$config = new TwigCsFixer\Config\Config(); | ||
$config->setRuleset($ruleset); | ||
$config->setFinder($finder); | ||
|
||
return $config; | ||
``` | ||
|
||
## Ignoring | ||
|
||
Ignoring rules **globally** takes place in the [`.twig-cs-fixer.php`](../../../../.twig-cs-fixer.php) file: | ||
```php | ||
$finder->exclude('myCustomDirectory'); | ||
``` | ||
|
||
All errors have an identifier with the syntax: `A.B:C:D` with | ||
- `A`: The rule short name (mainly made from the class name) | ||
- `B`: The error identifier (like the error level or a specific name) | ||
- `C`: The line the error occurs | ||
- `D`: The position of the token in the line the error occurs | ||
|
||
The four parts are optional, all those format are working | ||
- `A` | ||
- `A.B` | ||
- `A.B:C` | ||
- `A.B:C:D` | ||
- `A:C` | ||
- `A:C:D` | ||
- `A::D` | ||
|
||
If you need to know the errors identifier you have/want to ignore, you can run | ||
the linter command with the `--debug` option. | ||
|
||
To ignore **all Twig CS Fixer rules** within a file, place in the file header: | ||
```twig | ||
{# twig-cs-fixer-disable #} | ||
``` | ||
|
||
To ignore **a specific rule** within a file, place in the file header: | ||
```twig | ||
{# twig-cs-fixer-disable A.B:C:D #} | ||
``` | ||
|
||
Twig CS Fixer does not support ignoring of the **code blocks**. | ||
|
||
To ignore only the **current line**: | ||
```twig | ||
{# twig-cs-fixer-disable-next-line A.B:C:D #} | ||
``` | ||
|
||
To ignore only the **next line**: | ||
```twig | ||
{# twig-cs-fixer-disable-line A.B:C:D #} | ||
``` | ||
|
||
## Ignoring fail in CI | ||
|
||
This tool runs in CI by default and fails the build if there are any violations. | ||
|
||
Set `DREVOPS_CI_TWIG_CS_FIXER_IGNORE_FAILURE` environment variable to `1` to | ||
ignore failures. The tool will still run and report violations, if any. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters