All Projects → humanmade → Coding Standards

humanmade / Coding Standards

Human Made coding standards for modern code

Labels

Projects that are alternatives of or similar to Coding Standards

Wordplate
WordPlate is a wrapper around WordPress. It's like building any other WordPress website with themes and plugins. Just with sprinkles on top.
Stars: ✭ 1,594 (+1298.25%)
Mutual labels:  wordpress
Plate
Plate: a super stripped-down WordPress starter theme for developers.
Stars: ✭ 110 (-3.51%)
Mutual labels:  wordpress
Nextjs Headless Wordpress
🔥 Nextjs Headless WordPress
Stars: ✭ 110 (-3.51%)
Mutual labels:  wordpress
Wordpress Rest Admin
A frontend for admin area of WordPress, using WP REST API and React. It works with Self-Hosted WordPress
Stars: ✭ 108 (-5.26%)
Mutual labels:  wordpress
Behat Wordpress Extension
WordHat: Behat for WordPress
Stars: ✭ 109 (-4.39%)
Mutual labels:  wordpress
Ionmag
Blogging and news theme for WordPress.
Stars: ✭ 110 (-3.51%)
Mutual labels:  wordpress
Wp Postviews
Enables you to display how many times a post/page had been viewed.
Stars: ✭ 107 (-6.14%)
Mutual labels:  wordpress
Subtitles
Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.
Stars: ✭ 113 (-0.88%)
Mutual labels:  wordpress
Theme
The Themosis framework theme.
Stars: ✭ 109 (-4.39%)
Mutual labels:  wordpress
Wpplugin
Boilerplate for WordPress plugin using autoload, coding standard, webpack, PHP/JS tests, etc.
Stars: ✭ 112 (-1.75%)
Mutual labels:  wordpress
Wordpress App With Flutter
Fully Functional IOS/Android App for WordPress Website with Flutter
Stars: ✭ 109 (-4.39%)
Mutual labels:  wordpress
Frontpress
⚡️ A full front-end AngularJS template for WordPress Rest API.
Stars: ✭ 109 (-4.39%)
Mutual labels:  wordpress
Wp Cache Remember
Helper for the WordPress object cache and transients.
Stars: ✭ 111 (-2.63%)
Mutual labels:  wordpress
Nextjs Wordpress Starter
WebDevStudios Next.js WordPress Starter
Stars: ✭ 104 (-8.77%)
Mutual labels:  wordpress
Frontenberg
A limited frontend preview of the Gutenberg editor
Stars: ✭ 113 (-0.88%)
Mutual labels:  wordpress
Event Espresso Core
Event Espresso 4 Core for WordPress: Build an Event Ticketing Website Today!
Stars: ✭ 107 (-6.14%)
Mutual labels:  wordpress
S3 Uploads
The WordPress Plugin to Store Uploads on Amazon S3
Stars: ✭ 1,573 (+1279.82%)
Mutual labels:  wordpress
Acf Codifier
A wrapper class to help write more readable ACF field declarations.
Stars: ✭ 114 (+0%)
Mutual labels:  wordpress
Laravel5 Woocommerce Api Client
Laravel 5 wrapper for the Woocommerce REST API
Stars: ✭ 113 (-0.88%)
Mutual labels:  wordpress
Wp E2e Tests
Automated end-to-end tests for WordPress.com
Stars: ✭ 111 (-2.63%)
Mutual labels:  wordpress
Human Made Coding Standards
WordPress coding standards, enhanced for modern development.
Build Status
A Human Made project. Maintained by @rmccue and @mikeselander.

This is a codified version of the Human Made style guide. We include phpcs, ESLint, and stylelint rules.

Contributing

We welcome contributions to these standards and want to make the experience as seamless as possible. To learn more about contributing, please reference the CONTRIBUTING.md file.

Setup

Each ruleset is available individually via Composer or NPM. To install the needed ruleset, use one of the following commands:

  • PHPCS: composer require --dev humanmade/coding-standards
  • ESLint: npx install-peerdeps --dev @humanmade/[email protected]
  • stylelint: npm install --save-dev stylelint @humanmade/stylelint-config

Using PHPCS

Run the following command to run the standards checks:

vendor/bin/phpcs --standard=vendor/humanmade/coding-standards .

We use the DealerDirect phpcodesniffer-composer-installer package to handle installed_paths for PHPCS when first installing the HM ruleset. If you an error such as ERROR: Referenced sniff "WordPress-Core" does not exist, delete the composer.lock file and vendor directories and re-install Composer dependencies.

The final . here specifies the files you want to test; this is typically the current directory (.), but you can also selectively check files or directories by specifying them instead.

You can add this to your Travis YAML file as a test:

script:
  - phpunit
  - vendor/bin/phpcs --standard=vendor/humanmade/coding-standards .

Excluding Files

This standard includes special support for a .phpcsignore file (in the future, this should be built into phpcs itself). Simply place a .phpcsignore file in your root directory (wherever you're going to run phpcs from).

The format of this file is similar to .gitignore and similar files: one pattern per line, comment lines should start with a #, and whitespace-only lines are ignored:

# Exclude our tests directory.
tests/

# Exclude any file ending with ".inc"
*\.inc

Note that the patterns should match the PHP_CodeSniffer style: * is translated to .* for convenience, but all other characters work like a regular expression.

Patterns are relative to the directory that the .phpcsignore file lives in. On load, they are translated to absolute patterns: e.g. */tests/* in /your/dir/.phpcsignore will become /your/dir/.*/tests/.* as a regular expression. This differs from the regular PHP_CodeSniffer practice.

Advanced/Extending

If you want to add further rules (such as WordPress.com VIP-specific rules) or customize PHPCS defaults, you can create your own custom standard file (e.g. phpcs.ruleset.xml):

<?xml version="1.0"?>
<ruleset>
	<!-- Files or directories to check -->
	<file>.</file>

	<!-- Path to strip from the front of file paths inside reports (displays shorter paths) -->
	<arg name="basepath" value="." />

	<!-- Set a minimum PHP version for PHPCompatibility -->
	<config name="testVersion" value="7.2-" />

	<!-- Use HM Coding Standards -->
	<rule ref="vendor/humanmade/coding-standards" />

	<!-- Add VIP-specific rules -->
	<rule ref="WordPress-VIP" />
</ruleset>

You can then reference this file when running phpcs:

vendor/bin/phpcs --standard=phpcs.ruleset.xml .

Excluding/Disabling Checks

You can also customise the rule to exclude elements if they aren't applicable to the project:

<rule ref="vendor/humanmade/coding-standards">
	<!-- Disable short array syntax -->
	<exclude name="HM.Debug.ForceShortArray" />
</rule>

Rules can also be disabled inline. phpcs rules can be disabled with a // @codingStandardsIgnoreLine comment, and ESLint rules can be disabled with a /* eslint disable ... */ comment.

To find out what these codes are, specify -s when running phpcs, and the code will be output as well. You can specify a full code, or a partial one to disable groups of errors.

Included Checks

The phpcs standard is based upon the WordPress-VIP standard from WordPress Coding Standards, with customisation and additions to match our style guide.

Using ESLint

The ESLint package contains an ESLint configuration which you can use to validate your JavaScript code style. While it is possible to run ESLint via phpcs, we recommend you install and use eslint via npm directly or use linter-bot. See the @humanmade/eslint-config package README for more information on configuring ESLint to use the Human Made coding standards.

Once you have installed the @humanmade/eslint-config npm package, you may simply specify that your own project-level ESLint file extends the humanmade configuration. If you install this globally (npm install -g @humanmade/eslint-config) you can also reference the configuration directly from the command line via eslint -c humanmade .

Alternatively, you can create your own configuration and extend these rules:

.eslintrc

{
  "extends": "@humanmade"
}

Using stylelint

The stylelint package contains a stylelint configuration which you can use to validate your CSS and SCSS code style. We recommend you install and use stylelint via npm directly or use linter-bot. See the @humanmade/stylelint package README for more information on configuring stylelint to use the Human Made coding standards.

To integrate the Human Made rules into your project, add a .stylelintrc file and extend these rules. You can also add your own rules and overrides for further customization.

{
  "extends": "@humanmade/stylelint-config",
  "rules": {
    ...
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].