Skip to content

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

Notifications You must be signed in to change notification settings

pluswerk/typoscript-auto-fixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

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
  }
}

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages