TypoScript Lint analyzes TypoScript files for syntax errors, coding standard violations, and various quality issues. This package provides both a convenient wrapper command and direct tool access for comprehensive TypoScript code quality checking.
Use the wrapper command for most common scenarios:
# Analyze all TypoScript files in your project
$ bin/qt lint:typoscript
# Analyze specific directory
$ bin/qt lint:typoscript --path packages/my-extension/Configuration/TypoScript/The qt lint:typoscript command provides a convenient wrapper with hybrid path handling:
Automatically discovers and analyzes all TypoScript files using configuration-based path patterns:
$ bin/qt lint:typoscriptThis command:
- Uses optimized configuration file for TYPO3 projects
- Analyzes files matching
packages/**/Configuration/TypoScriptpatterns - Scans both
*.typoscriptand*.tsconfigfiles - Provides informational feedback about path discovery method
Target specific directories using the --path option:
# Analyze specific extension
$ bin/qt lint:typoscript --path packages/my-extension/Configuration/TypoScript/
# Analyze multiple files in a directory
$ bin/qt lint:typoscript --path config/sites/default/When using --path:
- Validates that the target path exists
- Converts to positional arguments for the underlying tool
- Provides feedback about custom path analysis
- Only analyzes files in the specified directory
Use custom configuration file:
$ bin/qt lint:typoscript --config path/to/custom-typoscript-lint.ymlFor advanced use cases or CI/CD integration, use typoscript-lint directly:
Analyze all TypoScript files using the provided configuration:
$ vendor/bin/typoscript-lint -c vendor/cpsit/quality-tools/config/typoscript-lint.ymlTarget specific directories by passing them as positional arguments:
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
packages/my-extension/Configuration/TypoScript/Analyze multiple directories in one command:
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
packages/extension-1/Configuration/TypoScript/ \
packages/extension-2/Configuration/TypoScript/Control output format and destination:
# Checkstyle XML format
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
--format checkstyle \
--output report.xml
# JSON format
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
--format jsonThe provided typoscript-lint.yml configuration is optimized for TYPO3 projects:
paths:
- packages/**/Configuration/TypoScript
- packages/**/Configuration/TSconfig
filePatterns:
- "*.typoscript"
- "*.tsconfig"These patterns automatically discover:
- All TypoScript files in package extensions
- TSconfig files for backend configuration
- Standard TYPO3 file extensions
The configuration includes comprehensive quality checks:
| Rule | Purpose |
|---|---|
| Indentation | Enforces 2-space indentation with consistent formatting |
| DeadCode | Identifies unreachable or unused TypoScript code |
| OperatorWhitespace | Ensures proper spacing around operators |
| RepeatingRValue | Detects duplicate assignments with allowed exceptions |
| DuplicateAssignment | Prevents conflicting property assignments |
| EmptySection | Identifies empty TypoScript sections |
| NestingConsistency | Maintains consistent object nesting patterns |
Some rules include exceptions for common TYPO3 patterns:
sniffs:
- class: RepeatingRValue
parameters:
allowedRightValues:
- "TYPO3\\CMS\\Frontend\\DataProcessing\\DatabaseQueryProcessor"Analyze a single extension during development:
# Using wrapper command
$ bin/qt lint:typoscript --path packages/my-extension/Configuration/TypoScript/
# Using direct tool
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
packages/my-extension/Configuration/TypoScript/Check all TypoScript files in your project:
# Using wrapper command (recommended)
$ bin/qt lint:typoscript
# Using direct tool
$ vendor/bin/typoscript-lint -c vendor/cpsit/quality-tools/config/typoscript-lint.ymlFor automated testing environments:
# Exit with error code on violations
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
--exit-code \
--fail-on-warningsCreate project-specific configuration by extending the base configuration:
# project-typoscript-lint.yml
paths:
- packages/**/Configuration/TypoScript
- config/sites/**/
filePatterns:
- "*.typoscript"
- "*.tsconfig"
- "*.txt" # Legacy TypoScript files
sniffs:
- class: Indentation
parameters:
useSpaces: true
indentPerLevel: 4 # Custom indentation
indentConditions: trueThe wrapper command was enhanced to resolve path handling issues:
- Default Mode: Uses configuration-based path discovery for zero-configuration operation
- Custom Path Mode: Accepts
--pathoption and converts to positional arguments - User Feedback: Provides clear information about which path discovery method is being used
Previously, the --path option caused errors because the underlying tool doesn't support this option format. The hybrid approach now:
- Uses optimal configuration file patterns by default
- Converts
--pathoptions to positional arguments when specified - Validates custom paths before execution
- Provides informative feedback to users
This ensures consistent behavior across all quality tools while leveraging each tool's native capabilities.
If you encounter path-related errors:
# Verify the path exists
$ ls -la packages/my-extension/Configuration/TypoScript/
# Use absolute path if relative path fails
$ bin/qt lint:typoscript --path $(pwd)/packages/my-extension/Configuration/TypoScript/If no TypoScript files are found:
- Verify file extensions match the configuration (
.typoscript,.tsconfig) - Check that files are in expected directory structures
- Use direct tool with specific path to test discovery
To debug configuration problems:
# Test with verbose output
$ vendor/bin/typoscript-lint \
-c vendor/cpsit/quality-tools/config/typoscript-lint.yml \
-v