{"id":15524802,"url":"https://github.com/martin-helmich/typo3-typoscript-lint","last_synced_at":"2025-04-05T09:07:11.474Z","repository":{"id":17955489,"uuid":"20941423","full_name":"martin-helmich/typo3-typoscript-lint","owner":"martin-helmich","description":"Find coding errors in your TypoScript files.","archived":false,"fork":false,"pushed_at":"2024-03-03T12:35:36.000Z","size":512,"stargazers_count":79,"open_issues_count":13,"forks_count":19,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-15T12:54:48.654Z","etag":null,"topics":["continuous-integration","linter","linting","php","typo3","typoscript","typoscript-lint"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martin-helmich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["martin-helmich"],"custom":["https://donate.helmich.me"]}},"created_at":"2014-06-17T22:21:03.000Z","updated_at":"2024-02-28T07:35:31.000Z","dependencies_parsed_at":"2023-11-07T16:26:24.845Z","dependency_job_id":"894dfc80-0a36-4f36-a1fc-b8bd689fa5ff","html_url":"https://github.com/martin-helmich/typo3-typoscript-lint","commit_stats":{"total_commits":246,"total_committers":14,"mean_commits":"17.571428571428573","dds":"0.43089430894308944","last_synced_commit":"3ef0ce9093bc72035ba9be50557a86f8352236d5"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martin-helmich%2Ftypo3-typoscript-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martin-helmich%2Ftypo3-typoscript-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martin-helmich%2Ftypo3-typoscript-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martin-helmich%2Ftypo3-typoscript-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martin-helmich","download_url":"https://codeload.github.com/martin-helmich/typo3-typoscript-lint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312078,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continuous-integration","linter","linting","php","typo3","typoscript","typoscript-lint"],"created_at":"2024-10-02T10:53:14.433Z","updated_at":"2025-04-05T09:07:11.330Z","avatar_url":"https://github.com/martin-helmich.png","language":"PHP","funding_links":["https://github.com/sponsors/martin-helmich","https://donate.helmich.me"],"categories":[],"sub_categories":[],"readme":"TypoScript Lint: CGL validation for TypoScript\n==============================================\n\n![Build status](https://github.com/martin-helmich/typo3-typoscript-lint/actions/workflows/php.yml/badge.svg?branch=master)\n\nAuthor\n------\n\nMartin Helmich (typo3 at martin-helmich dot de)\n\nContents\n--------\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Synopsis](#synopsis)\n- [Why?!](#why)\n- [Getting started](#getting-started)\n  - [Setup](#setup)\n  - [Usage](#usage)\n  - [Example](#example)\n- [Code validation](#code-validation)\n  - [Features](#features)\n  - [Configuration](#configuration)\n- [Articles](#articles)\n- [Future features](#future-features)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\nSynopsis\n--------\n\nThis package contains a tool that can parse TYPO3's configuration language,\n\"TypoScript\", into an syntax tree and perform static code analysis on the\nparsed code. `typoscript-lint` can generate [Checkstyle](http://checkstyle.sourceforge.net/)-compatible output and can be used\nin Continuous Integration environments.\n\nWhy?!\n-----\n\nThis project started of as a private programming excercise. I was writing an\narticle for the [T3N](http://t3n.de) magazine on Continuous Integration for\nTYPO3 projects, introducing tools like [JSHint](http://www.jshint.com/) or [CSSLint](http://csslint.net/),\nand I noticed that no comparable tools exist for TypoScript. So I thought,\n\"What the heck, let's go\" and at some point realized that my little programming\nexcercise might actually be useful to someone. So, that's that. Enjoy.\n\nGetting started\n---------------\n\n### Setup (using Composer)\n\nInstall typo3-typoscript-lint with Composer:\n\n    composer require --dev helmich/typo3-typoscript-lint\n\nOf course, this works best if your TYPO3 project is also Composer-based. If it isn't, you can also install the Linter [globally using the `composer global`](https://getcomposer.org/doc/03-cli.md#global) command:\n\n    composer global require helmich/typo3-typoscript-lint\n\n### Setup (using [Phive](https://phar.io/))\n\nAlternatively, you can also install typo3-typoscript-lint with Phive:\n\n    phive install martin-helmich/typo3-typoscript-lint\n    \nIn this case, it will be installed into the `./tools` folder of your current directory:\n\n    ./tools/typoscript-lint path/to/your.typoscript\n\n### Usage\n\nCall typo3-typoscript-lint as follows:\n\n    vendor/bin/typoscript-lint path/to/your.typoscript\n\nBy default, it will print a report on the console. To generate a checkstyle-format XML file, call as follows:\n\n    vendor/bin/typoscript-lint -f xml -o checkstyle.xml path/to/your.typoscript\n\nTo generate a report formatted according to the GNU Coding Standards, call as follows:\n\n    vendor/bin/typoscript-lint -f gcc path/to/your.typoscript\n\n### Example\n\n[![asciicast](https://asciinema.org/a/1jOJv3Z6onWSdIkTAxAWsGgoy.png)](https://asciinema.org/a/1jOJv3Z6onWSdIkTAxAWsGgoy)\n\nCode validation\n---------------\n\n### Features\n\nCertain aspects of code validation are organized into so-called \"sniffs\" (I\nborrowed the term from PHP's CodeSniffer project). Currently, there are sniffs\nfor checking the following common mistakes or code-smells in TypoScript:\n\n#### Indentation\n\nThe indentation level should be increased with each nested statement. In the\nconfiguration file, you can define whether you prefer\n[tabs or spaces](http://www.jwz.org/doc/tabs-vs-spaces.html) for indentation.\n\n    foo {\n        bar = 2\n      baz = 5\n    # ^----------- This will raise a warning!\n    }\n\nBy default, the indentation sniff expects code inside TypoScript conditions to\nbe **not** indented. You can change this behaviour by setting the\n`indentConditions` flag for the indentation sniff to `true` in your `typoscript-lint.yml`\nconfiguration file (see below).\n\n#### Dead code\n\nCode that was commented out just clutters your source code and obstructs\nreadability. Remove it, that's what you have version control for (you **do**\nuse version control, do you?).\n\n    foo {\n        bar.baz = 5\n        #baz.foo = Hello World\n    #   ^----------- This will raise a warning!\n    }\n\n#### Whitespaces\n\nCheck that no superflous whitespace float around your operators.\n\n    #   v----------- This will raise a warning (one space too much)\n    foo  {\n        bar= 3\n    #      ^-------- This will also raise a warning (one space too few)\n    }\n\n#### Repeating values\n\nIf the same value is assigned to different objects, it might be useful to\nextract this into a TypoScript constant.\n\n    foo {\n        bar = Hello World\n        baz = Hello World\n    #         ^----- Time to extract \"Hello World\" into a constant!\n\nBy default, any value with a length of 8 characters or more will trigger a warning if it is repeated more than once. You can configure this threshold by setting the `valueLengthThreshold` parameter for the `RepeatingRValueSniff` in your configuration file.\n\nIt is also possible to whitelist certain values that are allowed to repeat. You can set those in the `allowedRightValues` parameter in your configuration file.\n\n#### Duplicate assignments\n\nAssigning a value to the same object multiple times. Works across nested statements, too.\n\n    foo {\n        bar = baz\n    #   ^----------- This statement is useless, because foo.bar is unconditionally overwritten!\n    }\n    foo.bar = test\n\nThe sniff is however smart enough to detect conditional overwrites. So the\nfollowing code will *not* raise a warning:\n\n    foo {\n        bar = baz\n    }\n\n    [globalString = ENV:foo = bar]\n    foo.bar = test\n    [global]\n\n#### Nesting consistency\n\nThis sniff checks if nesting assignments are used in a consistent manner. Consider\nthe following example:\n\n    foo {\n        bar = test1\n    }\n\n    foo {\n        baz = test2\n    }\n\nIn this case, the two nested statements might very well be merged into one statement.\n\nConsider another example:\n\n    foo {\n        bar = test1\n    }\n\n    foo.baz {\n        bar = test2\n    }\n\nIn this case, both statements could be nested in each other.\n\n#### Empty blocks\n\nRaises warnings about empty assignment blocks:\n\n    foo {\n    }\n\n#### Discourage config.no_cache = 1\n\nRaises warning about usage of `config.no_cache = 1`.\nInstead USER_INT or COA_INT should be used.\n\n\n### Configuration\n\n`typoscript-lint` looks for a file `typoscript-lint.yml` in the current working directory.\nIf such a file is found, it will be merged with the `typoscript-lint.dist.yml` from the\ninstallation root directory. Have a look at [said file](typoscript-lint.dist.yml) for an\nidea of what you can configure (granted, not much yet):\n\n**Note**: Previous versions of this tool used the filename `tslint.yml` for their\nconfiguration files. This conflicted with the [same-named tool for linting TypeScript](https://palantir.github.io/tslint/),\nand is thus considered deprecated (although the old file names are still supported). \n\n* The paths to lint can be set under the `paths` key:\n\n  ```yaml\n  paths:\n    - directory/with/typoscript\n    - ...\n  ```\n  \n  You can also use the `*` character to match multiple files or directories:\n  \n  ```yaml\n  paths:\n    - typo3conf/ext/yourprefix_*/Configuration/TypoScript\n  ```\n\n* Configure individual sniffs under the `sniff` key in the configuration file. This key\n  consists of a list of objects, each with a `class` key and an optional `parameters`\n  key.\n\n  Since a local configuration file will be merged with the distributed\n  configuration file, you *cannot* disable sniffs by simply removing them from the\n  local configuration file (see this [bug report][issue-deadcode]\n  for more information). To disable a sniff, use the `disabled` configuration\n  property. For example, to disable the `DeadCode` sniff:\n\n  ```yaml\n  sniffs:\n    - class: DeadCode\n      disabled: true\n  ```\n\n* Configure file extensions that should be treated as TypoScript files in the\n  `filePatterns` key. This key may contain a list of glob patterns that inspected files\n  need to match. This is especially relevant when you're running `typoscript-lint`\n  on entire directory trees:\n  \n  ```yaml\n  filePatterns:\n    - \"*.typoscript\"\n    - \"setup.txt\"\n    - # ...\n  ```\n  \n  If you have certain files you want to explicitly *exclude* from linting even if they match the `filePatterns` above, you can specify additional `excludePatterns`:\n  \n  ```yaml\n  filePatterns:\n    - \"*.typoscript\"\n  excludePatterns:\n    - \"Constants.typoscript\"\n  ```\n\nArticles\n--------\n\n- [Code Quality in TYPO3 Projects](https://www.martin-helmich.de/en/blog/codequality-typo3.html)\n- [Continuous Integration in TYPO3 Projects (_German_)](https://t3n.de/magazin/continuous-integration-typo3-236672/)\n- [Integrate TYPO3 Linting with Gitlab CI](https://daniel-siepmann.de/Posts/2018/2018-01-30-gitlab-ci-linting.html) _by Daniel Siepmann_\n- [Integrate Typoscript linter into VIM](https://daniel-siepmann.de/Posts/2018/2018-01-28-typoscript-linter-inside-vim.html) _by Daniel Siepmann_\n\nFuture features\n---------------\n\n- Sniffs for more code smells (ideas are welcome)\n- Full test coverage (no, I did not do TDD. Shame on me.)\n- Automated fixing of found errors\n\n[issue-deadcode]: https://github.com/martin-helmich/typo3-typoscript-lint/issues/1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartin-helmich%2Ftypo3-typoscript-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartin-helmich%2Ftypo3-typoscript-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartin-helmich%2Ftypo3-typoscript-lint/lists"}