pluswerk/typoscript-auto-fixer

Provides an auto fixer based on the TypoScript linter from Martin Helmich

v0.0.1 2019-12-09 09:31 UTC

This package is auto-updated.

Last update: 2024-10-09 23:28:29 UTC


README

Packagist Packagist Build Status Coverage Status Quality Score

typoscript-auto-fixer

This is an auto fixer for TYPO3 TypoScript code style based on martin-helmich/typo3-typoscript-lint of Martin Helmich.

Quick guide

Composer

composer require --dev pluswerk/typoscript-auto-fixer

There is a default configuration, so no configuration must be given.

Usage

Basic usage

./vendor/bin/tscsf [options] [file] [file] [...]

Options

Example

./vendor/bin/tscsf -g -c another-grumphp.yml some.typoscript other.typoscript

Configuration

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.

Fixers exist for following sniffer classes

  • EmptySection
  • OperatorWhitespace
  • Indentation
  • NestingConsistency

For details see What is fixed section

What is fixed

Line breaks

Multiple empty lines are reduced to one empty line.

Example

foo.bar = value



another.foo = value2

fixed:

foo.bar = value

another.foo = value2

Operator whitespaces (configuration class: OperatorWhitespace)

Example

foo=bar

fixed:

foo = bar

Indentation (configuration class: Indentation)

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.

Example

  • character: space
  • indentPerLevel: 2
foo {
bar = value
}

fixed:

foo {
  bar = value
}

Empty section (configuration class: EmptySection)

Empty sections are removed.

Example

bar = value

foo {
}

another = foo

fixed:

bar = value


another = foo

Nesting consistency (configuration class: NestingConsistency)

Nesting consistency is built if paths can be merged in a file. Indentation is used like described above in indentation fixer.

Example

foo {
  bar = value
}

foo.bar2 = value2

foo {
  bar2 {
    nested = nested value
  }
}

fixed:

foo {
  bar = value
  bar2 = value2
  bar2 {
    nested = nested value
  }
}