Replies: 5 comments 2 replies
-
@TukuToi I have a feeling this is three questions in one, so I'm going to try and pick it apart and answer them individually.
The precedence order is as per the above list with a
Does that help ? |
Beta Was this translation helpful? Give feedback.
-
It helps to get me started to resolve this problem, yes. I have tried to place the file in all possible directories I knew of which are:
I did not think about the peculiarity that Sublime might use another folder altogether to scan the files In case that helps understand what I want, I just want to "overwrite" a couple WPCS rules, not create a full blown new standard. For example, I want to register my own "esc_" function and stop WPCS from telling me "you are not escaping/please use esc_". I might as well just repeat what worked in past (namely install WPCS in this particular project and not use the global one) I will check now on the Sublime if I can figure out where it scans the files, and try to place the ruleset there. |
Beta Was this translation helpful? Give feedback.
-
More than anything that sounds like a Sublime peculiarity in how it handles PHPCS global vs PHPCS local install as whether you have PHPCS installed globally or locally makes no difference in how it tries to find the rulesets. |
Beta Was this translation helpful? Give feedback.
-
I found https://gist.github.com/andrewlimaza/fe68efd141e2e9e8d8e46407d90b90b2 - looking at those Sublime settings, I see they actually set the standard to that file with I tried that using their sample xml file, which did not work, but it did work with the https://raw.githubusercontent.com/WordPress/WordPress-Coding-Standards/develop/phpcs.xml.dist.sample file. So far so good, then I removed all "customisation" from that sample file and added my own custom rule:
It is supposed to recognise a So now, I guess my only issue left is how do pass a custom rule that uses a class method (although, even if I try just for testing with This might be stuff for a new discussion, I guess. TL;DR: Hope that helps someone struggling with the same, and thanks for pointing me to the right direction! |
Beta Was this translation helpful? Give feedback.
-
As an update, this seems to do the job:
It will not check if the right method is actually used - it seems not capable of that, but at least it checks for the class. This is a bit sad, because I might have classes with distinct methods that do different things, and it would be wrong to use method A when really method B would be the required one, yet I seem I cannot specific it with class::method or class->method syntax... Apart of that It seems I had too much specified the If anyone has an idea or knows how to register class methods for WPCS I am happy to hear 👍 |
Beta Was this translation helpful? Give feedback.
-
In past I have created custom rulesets successfully when using WPCS locally in a project.
I simply installed WPCS in the specific project and then put the custom Ruleset in the project's main directory.
But now I want to add a custom ruleset that applies to my global WPCS instance.
I use WPCS in Sublime Text so I installed it several months ago in my Mac path
/users/username/wpcs
and followed the steps to use WPCS in sublime. This is working perfectly fine.But when I place my new custom rule set into either:
the current directory I am scanning
OR into the
users/username/wpcs
path where WPCS is globally installedOR in its parent directory
users/username/
then that ruleset is not "seen/applied"What am I doing wrong?
As far I understand from the Docs, the custom ruleset (BTW named
phpcs.xml
, so it takes priority if there are others, which is not the case, but just to be safe), if added to either current dir or parent dir should simply be automatically applied?Beta Was this translation helpful? Give feedback.
All reactions