pluswerk/typoscript-auto-fixer

提供基于Martin Helmich的TypoScript代码检查器的自动修复工具

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

This package is auto-updated.

Last update: 2024-09-09 23:24:13 UTC


README

Packagist Packagist Build Status Coverage Status Quality Score

typoscript-auto-fixer

这是一个基于Martin Helmich的typo3-typoscript-lint的TYPO3 TypoScript代码风格的自动修复工具。

快速指南

Composer

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

默认配置已存在,因此无需提供配置。

用法

基本用法

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

选项

示例

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

配置

修复操作基于typoscript代码检查器的配置。只有当配置了sniffer类时,相应的修复器才会执行。

配置与martin-helmich/typo3-typoscript-lint相同。

如果使用grumphp,配置方式如下: pluswerk/grumphp-typoscript-task

以下sniffer类存在修复器

  • EmptySection
  • OperatorWhitespace
  • Indentation
  • NestingConsistency

详情请见“修复了什么”部分

修复了什么

行中断

多个空行将被缩减为一个空行。

示例

foo.bar = value



another.foo = value2

fixed

foo.bar = value

another.foo = value2

操作符空白(配置类:OperatorWhitespace)

示例

foo=bar

fixed

foo = bar

缩进(配置类:Indentation)

根据配置,缩进将被修复。可能的字符

  • 空格
  • 制表符

还可以设置字符数量。详情请见martin-helmich/typo3-typoscript-lint

示例

  • 字符:空格
  • indentPerLevel: 2
foo {
bar = value
}

fixed

foo {
  bar = value
}

空节(配置类:EmptySection)

空节将被移除。

示例

bar = value

foo {
}

another = foo

fixed

bar = value


another = foo

嵌套一致性(配置类:NestingConsistency)

如果文件中的路径可以合并,则构建嵌套一致性。缩进的使用方式与缩进修复器中描述的相同。

示例

foo {
  bar = value
}

foo.bar2 = value2

foo {
  bar2 {
    nested = nested value
  }
}

fixed

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