Closed yamenarahman closed 4 years ago
Hi @yamenarahman, check the documentation on https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#genericformattingspaceafternot
You can use it on your configuration file phpcs.xml
like this:
<?xml version="1.0"?>
<ruleset name="PersonalPhpCs">
<rule ref="PSR2"/> <!-- based on PSR2 -->
<!-- ... more configuration ... -->
<rule ref="Generic.Formatting.SpaceAfterNot"/>
</ruleset>
Here's a working example with many other rules: https://github.com/eclipxe13/enum/blob/master/phpcs.xml.dist
@eclipxe13 Thanks for your reply, one last question:
How can I make this rule global so I don't have to put phpcs.xml
in every project?
Where can I find the root file or global phpcs.xml? if it's located in composer global packages, how can I protect this file from resetting when I self-update or upgrade composer global packages?
Thanks.
How can I make this rule global so I don't have to put phpcs.xml in every project?
I don't like globals, but that is not the point. Make your own standard and put the rules equally available as PSR2, I think doctrine/coding-standard might inspire you. So, If you are installing phpcs globally your standards can also be installed the same way.
Where can I find the root file or global phpcs.xml?
phpcs
includes some standards, check vendor/squizlabs/php_codesniffer/src/Standards/
how can I protect this file from resetting when I self-update or upgrade composer global packages?
When run phpcs
(globally or locally installed) it will search for different config files (ruleset.xml
, ruleset.xml.dist
, phpcs.xml
, phpcs.xml.dist
) and will take the first it can find. It is a configuration file, so it will not be overriden or removed, but it could be incompatible with new phpcs versions.
A few notes:
I recommend to you to use a standard per project, even when it looks the same, each project can be slightly different or with customizations from a bigger standard.
I don't think this is the place to answer this questions, I think that has nothing to do with ikappas/vscode-phpcs/
. You can use gitter https://gitter.im/squizlabs/PHP_CodeSniffer and I'm sure that you can get help over there.
Please, read the documentation about how to use phpcs
.
I hope I provided you some guidance, but I will not answer a very off-topic issue.
Thanks for your time @eclipxe13 Appreciated!
How can I add this rule:
<rule ref="Generic.Formatting.SpaceAfterNot" />