This is an auto fixer for TYPO3 TypoScript code style based on martin-helmich/typo3-typoscript-lint of Martin Helmich.
composer require --dev pluswerk/typoscript-auto-fixer
There is a default configuration, so no configuration must be given.
./vendor/bin/tscsf [options] [file] [file] [...]
Option | Description |
---|---|
-t, --typoscript-linter-configuration | Use typoscript-lint.yml file |
-g, --grumphp-configuration | Use grumphp.yml file |
-c, --configuration-file | For both options (-t, -g) a different file path can be given. |
./vendor/bin/tscsf -g -c another-grumphp.yml some.typoscript other.typoscript
The fixes are done based on the typoscript linter configuration. Only if a sniffer class is configured the corresponding fixer is executed.
The configuration is the same as martin-helmich/typo3-typoscript-lint.
If grumphp is used the configuration is done as here: pluswerk/grumphp-typoscript-task.
- EmptySection
- OperatorWhitespace
- Indentation
- NestingConsistency
For details see What is fixed section
Multiple empty lines are reduced to one empty line.
foo.bar = value
another.foo = value2
fixed:
foo.bar = value
another.foo = value2
foo=bar
fixed:
foo = bar
Depending on configuration the indentation is fixed. Possible characters:
- spaces
- tabs
Also the amount of characters can be set. See martin-helmich/typo3-typoscript-lint for details.
- character: space
- indentPerLevel: 2
foo {
bar = value
}
fixed:
foo {
bar = value
}
Empty sections are removed.
bar = value
foo {
}
another = foo
fixed:
bar = value
another = foo
Nesting consistency is built if paths can be merged in a file. Indentation is used like described above in indentation fixer.
foo {
bar = value
}
foo.bar2 = value2
foo {
bar2 {
nested = nested value
}
}
fixed:
foo {
bar = value
bar2 = value2
bar2 {
nested = nested value
}
}