Name: WordPress Coding Standards Linter for Cloud9
Current Version: 1.0.1 (2018-10-11)
Author: EP4
Contributors: Dave Lavoie
License: GPLv3 or later
Provides a linter in Cloud9 IDE for WordPress development using PHP CodeSniffer (PHPCS) based on WordPress Coding Standards (WPCS) and PHPCompatibility/PHPCompabitityWP rules.
-
From the Cloud9 menu, select Preferences, then Experimental -> SDK and enable Load Custom Plugins, Load Plugins From Workspace and Plugin Manager toggles. For more details about Cloud9 Experimental Features, visit https://docs.c9.io/docs/experimental-features .
-
Open a Terminal from the menu Window -> New Terminal.
-
Run these commands in the terminal for each project where you want to use the plugin:
git clone git@github.com:EP4/c9.ide.language.php.wordpress.git
cd c9.ide.language.php.wordpress
c9 install .
cd ..
rm -fR c9.ide.language.php.wordpress
- If you don't want to activate the plugin manually every time you open your Cloud9 project, you can enable it automatically. Click on the Cloud9 menu, select Open Your Init Script and add the following code:
services.pluginManager.loadPackage([
"~/.c9/plugins/c9.ide.language.php.wordpress/package.json"
])
-
Restart Cloud9.
-
Use Cloud9 as usual, and warnings will be displayed in the IDE when working on PHP files if PHP CodeSniffer detects any error based on PHPCompatibilityWP & WordPress Coding Standards rules.
This plugin will display errors found by PHPCS directly in the IDE, as you can see on the following screenshot:
This plugin will do the following:
- Run PHPCS on the current PHP file using WordPress Coding Standards and PHPCompatibility rules.
- If errors are found, a warning icon will be displayed next to the line number.
- When hovering that icon, a tooltip with a message explaining the error(s) will be displayed.
- In the message, icons will be displayed for helping you distinguish if this is a warning or an error, and if it can be fixed automatically by PHPCBF.
- In the message, the line and column where the error can be found in the code will be displayed inside parentheses.
- In the code, errors will be underlined with a red dotted line, and highlighted in red so you can rapidly identify them. Please note that the highlighted characters might not actually be accurate.
This plugin won't do the following (yet):
- Run PHPCBF and fix issues automatically. You'll have to run PHPCBF from the Terminal, or fix issues manually based on the recommendations given.
- Allow the user to enable or disable specific standards and rules. You'll need to manually edit the settings of the plugin in the phpcs_handler.js file which can be found in the worker directory.
- Update itself automatically. At the moment, all rules must be updated manually. I'll update this plugin once in a while with the most recent rules available.
Since there is no simple way to allow HTML in these tooltips, we use some custom Unicode characters for displaying more meaningful messages:
Displayed Characters | Meaning |
---|---|
🔴 Red Circle | The identified issue is considered to be an error by PHPCS. |
🔶 Yellow Diamond | The identified issue is considered to be a warning by PHPCS. |
✔ Checkmark | The issue can be resolved automatically by running PHPCBF. |
𝗪𝗣𝗖𝗦 | The issue was identified using WordPress Coding Standards Rules. |
𝗣𝗛𝗣𝗖𝗼𝗺𝗽𝗮𝘁𝗶𝗯𝗶𝗹𝗶𝘁𝘆 | The issue was identified using PHPCompatibility Rules. |
➀ to ➈ | Any number displayed in a circle represent the severity level of the issue. ➄ is the default severity and is never displayed. |
(𝟏𝟐𝟑:𝟕𝟖𝟗) | Numbers displayed inside parentheses refer to the line and column where the issue can be found. In this example, look at line 123 and column 789. |
- PHP CodeSniffer : GitHub Repo, Wiki & Analysis of Coding Conventions for WP
- WordPress Coding Standards : GitHub Repo, Wiki & Whitelisting code which flags errors
- PHPCompatibility : GitHub Repo
- PHPCompatibilityWP : GitHub Repo
- Cloud9 : SDK & API
- Removing the
tab-width=0
parameter since the tab-width is already set by WordPress rules and it was now triggering false positives. - Fixing some typos in the README.md file.
- Updating PHP_CodeSniffer library to version 3.3.2.
- Updating WordPress Coding Standards to version 1.1.0.
- Updating PHPCompabitity standards to version 9.0.0.
- Adding PHPCompabitityWP 2.0.0 and PHPCompatibilityParagonie 1.0.0 standards.
- Increasing the stdout max output from 200KB to 500KB.
- Increasing the timeout from 5 to 10 seconds.
- Moving the checkmark icon (✔) after the position in the tooltip.
- Including license files for each coding standards.
- Removing the CSS rule used for hiding the debug bar since the plugin can be used without activating the debug mode now.
- Some code refactoring.
- Updating the 'Installation' section of the docs.
- Updating WordPress Coding Standards with the latest release as of 2017-02-10.
- Updating PHPCompabitity standards with the latest release as of 2017-02-06
Initial release.