VS Code IDE autoformatters
brianteeman opened this issue ยท 9 comments
Is anyone able to help with what it takes to create an IDE autoformatter for Visual Studio Code?
Ah I would be interested too ๐
But i guess this should help:
https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs
&&
settings: editor.formatOnType: true
But i have not tryed it yet.
I'nt the file we need this: https://github.com/joomla/coding-standards/blob/master/Joomla/ruleset.xml ?
@zero-24 that is just the PHPCS 2.x ruleset, it only applies to PHPCS 2.x. VS will need a VS specific solution, just like the one specific to PHP storm's set up or the one for eclipse etc
It's different from the linter plugins for VS or phpstorm than connects into PHPCS.
see https://code.visualstudio.com/docs/getstarted/settings
What would need to be created is a settings.json
for VS which is configured for PHP Language specific editor settings
I will assume that the configuration will meet some basics of the Joomla code style but will not meet the full code style (the same is true of all the IDE formatters).
Just came across this guide https://github.com/tommcfarlin/phpcs-wpcs-vscode
once you have PHPCS and the Joomla standard installed, edit your VS settings.json (easy now that the alpha release is out on composer... but note there is a small bug in the current alpha release that has been fixed in the master branch.
// Place your settings in the settings.json file to overwrite the default settings
{
"phpcs.enable": true,
"phpcs.standard": "Joomla",
}
And this will enable PHPCS and will also tell it to use the Joomla standard
note: for the CMS it's recommended to use the example ruleset for the CMS to ignore certain rules and folders (especially ignoring the vendor/3rd-party-code folders)
to install one of the included example rulesets
./vendor/bin/phpcs --config-set installed_paths /path/to/project/vendor/joomla/coding-standards/Joomla/ExampleRulesets
then edit your VS settings.json
{
"phpcs.enable": true,
"phpcs.standard": "Joomla-CMS",
}
Cool I give that a try next week - thanks!!!
You are welcome. I also forked and attempted to rewrite the guide for working the Joomla CS
https://github.com/photodude/phpcs-vscode
@brianteeman did you give it a try? Can this be closed now?
its on my very long todo list still but i guess it can be closed