getblocklab / block-lab

A WordPress Admin interface and a simple templating system for building custom Gutenberg blocks.
https://getblocklab.com
GNU General Public License v2.0
417 stars 63 forks source link

PHPCS is Throwing Errors #427

Closed stevenkword closed 4 years ago

stevenkword commented 5 years ago

PHPCS is throwing an error against the latest version of the WP Coding Standards. It was addressed previously through the usage of phpcs:ignore, however I believe the ruleset namespaces have since changed have changed. PR incoming.

kienstra commented 5 years ago

Hi @stevenkword, thanks for bringing this up. I'll look at this, and will look at your PR when it's ready.

kienstra commented 5 years ago

It looks like I should have included phpcodesniffer-composer-installer in composer.json, like how the AMP plugin does.

At least locally, npm run lint:php is passing with this diff:

diff --git a/composer.json b/composer.json
index 65c4261..fe7f046 100644
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
         "php": "^5.6 || ^7"
     },
     "require-dev": {
+        "dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
         "brain/monkey": "^2",
         "squizlabs/php_codesniffer": "^3.4",
         "wp-coding-standards/wpcs": "2.1.1"
diff --git a/phpcs.xml b/phpcs.xml
index b337e37..1088de7 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,7 +2,7 @@
 <ruleset name="WordPress Coding Standards for Plugins">
     <description>Generally-applicable sniffs for WordPress plugins</description>

-    <rule ref="WordPress" />
+    <rule ref="WordPress-Core" />

     <rule ref="WordPress.Files.FileName.InvalidClassFileName">
         <exclude-pattern>tests/*</exclude-pattern>
block-lab $
kienstra commented 5 years ago

Question about phpcs

Hi @stevenkword, Hope you're doing great.

Were you able to run phpcs without error in this repo?

Doing npm run lint:php should run that command and shouldn't show any error or warning. As long as composer install was run at some point.

Thanks, Steven!