Gnist Design Coding Standards - WordPress

Installs: 54

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

1.0.3 2024-06-06 07:42 UTC

This package is auto-updated.

Last update: 2025-03-06 09:13:28 UTC


README

Installation

Standards can be installed with Composer dependency manager:

$ composer require gnistdesign/gdcs --dev

Usage

Basic usage

When the package is installed via Composer you can check your files with the coding standards via:

$ vendor/bin/phpcs --standard="GnistDesignWP" <path>

Where <path> is at least one file or directory to check, ex ..

Configuration File

To not have to pass all the arguments to the command line, and also make your own project customizations create a phpcs.xml.dist file that contains something like this:

<?xml version="1.0"?>
<ruleset name="MyCustomStandard">
  <description>A custom set of rules to check for a WordPress project</description>

  <!-- Exclude directories -->
  <exclude-pattern>/vendor/*</exclude-pattern>

  <!-- Text domain. -->
  <rule ref="WordPress.WP.I18n">
    <properties>
      <property name="text_domain" type="array">
        <element value="my-textdomain"/>
        <element value="library-textdomain"/>
      </property>
    </properties>
  </rule>

  <!-- Prefix. -->
  <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
    <properties>
      <property name="prefixes" type="array">
        <element value="my_prefix"/>
      </property>
    </properties>
  </rule>

	 <!-- Include the Gnist Design Coding Standard for WordPress. -->
  <rule ref="GnistDesignWP" />
</ruleset>