newsuk/nuk-wp-phpcs-config

PHPCS configuration for WordPress VIP plugins and themes

Installs: 3 960

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 14

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

v0.4.0 2024-04-29 08:36 UTC

This package is auto-updated.

Last update: 2024-04-29 08:38:18 UTC


README

NUK WP PHPCS config

This library contains WordPress VIP PHPCS configuration for NewsUK plugins and themes.

Requirements

  • PHP 8.2
  • WordPress 6.2

Installation

Composer install:

composer require --dev newsuk/nuk-wp-phpcs-config

Using the ruleset

Create a phpcs.xml.dist file in your project and add the following to use NewsUK ruleset:

<?xml version="1.0"?>
<ruleset name="NewsUK WP PHPCS Rules">
	<rule ref="NewsUK"/>
</ruleset>

💡 It is recommended to use the NewsUK or NewsPress ruleset as it is without customising or overriding rules unless necessary.

Override or add custom rules

You can also override or add custom rules to the config as follows.

<?xml version="1.0"?>
<ruleset name="NewsUK WP PHPCS Rules">
	<rule ref="NewsUK"/>
	<!-- Overriding the existing text_domain -->
	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" type="array">
				<element value="your_plugin_domain"/>
			</property>
		</properties>
	</rule>
</ruleset>

Composer scripts

Add the following to scripts section in composer.json file to run linting.

"lint": "phpcs .",
"lint:fix": "phpcbf .",