3

I have had a lot of issues setting up phpcs and vscode — they worked perfectly for a while, but then after reorganizing some folders, I moved my wpcs repo somewhere else. Now trying to reconfigure phpcs and cannot figure out what the problem is. I keep getting an error that Universal.WhiteSpace.DisallowInlineTabs does not exist. Here is a screenshot enter image description here

Any idea what's going on?

Jamie
  • 1,909
  • 3
  • 22
  • 47

2 Answers2

6

I used homebrew to install phpcs instead of composer. Because I didn't want to switch to composer I started using PHPCSUtils's 'Non-Composer based integration' but realized that I didn't want to have to manually update the package every time a new release came out.

Instead I cloned PHPCSUtils and PHPCSExtras into directories in the same parent folder as my WPCS directory. Then I symlinked them into the WPCS folder

git clone git@github.com:WordPress/WordPress-Coding-Standards.git wpcs
git clone git@github.com:PHPCSStandards/PHPCSExtra.git
git clone git@github.com:PHPCSStandards/PHPCSUtils.git
cd wpcs
ln -s ../PHPCSUtils/PHPCSUtils PHPCSUtils
ln -s ../PHPCSExtra/Universal Universal
ln -s ../PHPCSExtra/NormalizedArrays NormalizedArrays
Aaron
  • 76
  • 2
2

A couple of months ago an existing WordPress sniff was replaced with a more robust Universal sniff (part of the PHPCSExtra package).

Commit: https://github.com/WordPress/WordPress-Coding-Standards/commit/8997d689294fbf880b427873e7fa254237f3b87f

Despite the PHPCSExtra package being a required packed by WordPress-Coding-Standards, it did not automatically install for me. I believe my issue was a default "minimum-stability": "stable" setting which prevented PHPCSExtra (still in alpha) from installing.

I resolved this by installing the following packages manually.

NOTE: I'm using PHPCS + WPCS globally. Remove global if attempting to install locally for a single project.

composer global require phpcsstandards/phpcsutils:@alpha
composer global require phpcsstandards/phpcsextra:@alpha

Adding the @alpha flag for each package overrides your default minimum-stability setting.

Hope this helps!

dswebsme
  • 156
  • 4