Nova

Extensions


Readme

PHP_CodeSniffer automatically lints all open PHP files using phpcs, then reports errors and warnings in Nova's Issues sidebar and the editor gutter.

PHP_CodeSniffer can fix issues discovered by phpcs automatically using phpcbf.

Requirements

PHP_CodeSniffer requires the following tools to be installed on your Mac:

The extension will do its best to find an installation of PHP_CodeSniffer on your system in the following order:

  1. Using the path you define in the extension's configuration
  2. Path to the default Composer installation; vendor/bin/phpcs and vendor/bin/phpcbf.
  3. Path to the default Phive installation; tools/bin/phpcs and tools/bin/phpcbf.
  4. Global installation; phpcs and phpcbf.

If the extension doesn't find an installation it will fall back to the version of PHP_CodeSniffer bundled with the extension.

The bundled PHP_CodeSniffer will not know how to locate any rulesets installed via Composer or Phive, so if you need to use phpcs rulesets installed via Composer or Phive make sure you use the same method to install PHP_CodeSniffer.

If you have a custom ruleset for phpcs somewhere that you'd like to use, you can choose to use that "standard" by setting the path in Project → Project Settings → PHP_CodeSniffer.

Configuration

To configure global preferences, open Extensions → Extension Library → PHP_CodeSniffer then select PHP_CodeSniffer's Preferences tab.

You can also configure preferences on a per-project basis in Project → Project Settings → PHP_CodeSniffer.


Changelog

Version 1.2.1 - March 17, 2021

  • Tweak - Update readme to reflect the changes introduced in v1.2.0.
  • Tweak - Update the description of some extension settings.
  • Tweak - Use the same default standard PHP_CodeSniffer uses, instead of defaulting to the WordPress standard.

Version 1.2.0 - March 17, 2021

  • Add - Bundle phpcs and phpcbf phar files with extension.
  • Tweak - Fall back to bundled phar files when no global/composer/phive installation detected.

Version 1.1.1 - March 12, 2021

  • Add - Link to mailing list for bug reports instead of my personal email.

Version 1.1.0 - March 11, 2021

  • Tweak - Provide free-form input for custom ruleset.
  • Fix - Issues are now indicated at the right column when indenting with tabs.
  • Add - Command for fixing issues with phpcbf.

Version 1.0.5 - February 24, 2021

  • Add - Support for a phpcs.xml.dist file for defining code sniffing rules.
  • Add - An error notification if phpcs fails to run.

Version 1.0.4

  • Add - Support for the Advanced PHP syntax extension.

Version 1.0.3

  • Fix - Progress and verbose output from phpcs is now suppressed correctly to prevent JSON parsing issues.

Version 1.0.2

  • Fix - List of available PHPCS styles not showing up in project preferences.

Version 1.0.1

  • Add option to choose whether to run phpcs on save or on change.

Version 1.0.0

Initial release.


License

MIT License

Copyright (c) 2020 Kristófer Reykjalín Þorláksson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.