This linter plugin for Visual Studio Code provides an interface to twigcs. It will be used with files that have the “Twig” language mode.
Visual Studio Code must be installed in order to use this plugin. If Visual Studio Code is not installed, please follow the instructions here.
Before using this plugin, you must ensure that twigcs is installed on your system. The installation can be performed system-wide / project-wide using composer.
Once twigcs is installed, you can proceed to install the vscode-twigcs plugin if it is not yet installed.
The twigcs linter can be installed globally using the Composer Dependency Manager for PHP.
- Install composer.
- Require
twigcspackage by typing the following in a terminal:
composer global require friendsoftwig/twigcsThe twigcs linter can be installed in your project using the Composer Dependency Manager for PHP.
- Install composer.
- Require
twigcspackage by typing the following at the root of your project in a terminal:
composer require --dev friendsoftwig/twigcs- Open Visual Studio Code.
- Press
Ctrl+Pon Windows orCmd+Pon Mac to open the Quick Open dialog. - Type ext install twigcs to find the extension.
- Press Enter or click the cloud icon to install it.
- Restart Visual Studio Code when prompted.
This extension contributes the following variables to the settings :
| Name | Default | Description |
|---|---|---|
twigcs.enabled |
true | If true, will activate the twig linter extension. |
twigcs.enabledWarning |
true | If true, will activate twig warnings. |
twigcs.executablePath |
null | Controls the executable path for the twigcs. |
twigcs.rulesetClass |
null | Controls the custom ruleset class. The \ character must be escaped Ex: \\twigcs\\MyRuleset |
The extension architecture is based off of the Language Server Node Example and phpcs Code Sniffer.
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.
The project is available under MIT license, which allows modification and redistribution for both commercial and non-commercial purposes.
