Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #1

Merged
merged 2 commits into from Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
175 changes: 174 additions & 1 deletion README.md
@@ -1 +1,174 @@
# TODO
# Itineris WP Coding Standards

[![Packagist Version](https://img.shields.io/packagist/v/itinerisltd/itineris-wp-coding-standards.svg)](https://packagist.org/packages/itinerisltd/itineris-wp-coding-standards)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/itinerisltd/itineris-wp-coding-standards.svg)](https://packagist.org/packages/itinerisltd/itineris-wp-coding-standards)
[![Packagist Downloads](https://img.shields.io/packagist/dt/itinerisltd/itineris-wp-coding-standards.svg)](https://packagist.org/packages/itinerisltd/itineris-wp-coding-standards)
[![GitHub License](https://img.shields.io/github/license/itinerisltd/itineris-wp-coding-standards.svg)](https://github.com/ItinerisLtd/itineris-wp-coding-standards/blob/master/LICENSE)
[![Hire Itineris](https://img.shields.io/badge/Hire-Itineris-ff69b4.svg)](https://www.itineris.co.uk/contact/)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Goal](#goal)
- [Installation](#installation)
- [Usage](#usage)
- [PrettyCI](#prettyci)
- [Required Readings](#required-readings)
- [FAQs](#faqs)
- [Will you add support for older PHP versions?](#will-you-add-support-for-older-php-versions)
- [It looks awesome. Where can I find some more goodies like this?](#it-looks-awesome-where-can-i-find-some-more-goodies-like-this)
- [This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?](#this-isnt-on-wporg-where-can-i-give-a-%EF%B8%8F%EF%B8%8F%EF%B8%8F%EF%B8%8F%EF%B8%8F-review)
- [Feedback](#feedback)
- [Change Log](#change-log)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Goal

[Itineris WP Coding Standards](https://github.com/ItinerisLtd/itineris-wp-coding-standards) is a project with rulesets for code style and quality tools to be used in Itineris WordPress projects.

It is a mix with [PSR-1](https://www.php-fig.org/psr/psr-1/), [PSR-2](https://www.php-fig.org/psr/psr-2), [PSR-4](https://www.php-fig.org/psr/psr-4/), [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) and [Automattic/VIP-Coding-Standards](https://github.com/Automattic/VIP-Coding-Standards).

Whenever there's a conflict between PSR and WPCS, always prefer PSR.

Currently, it works for WordPress plugins.
Using it on [Bedrock](https://github.com/roots/bedrock) or [Sage](https://github.com/roots/sage) requires some tweaking.

## Installation

```bash
$ composer require --dev itinerisltd/itineris-wp-coding-standards
```

## Usage

First, create [`phpcs.xml`](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset) on project root:
```xml
<?xml version="1.0"?>
<ruleset name="MyAwesomePlugin">
<!-- Check all files under project root -->
<file>./</file>

<!-- Show sniff codes in all reports -->
<arg value="s"/>

<!-- Install custom rulesets -->
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs,vendor/automattic/vipwpcs,vendor/itinerisltd/itineris-wp-coding-standards"/>

<!-- Use Itineris WP Coding Standards -->
<rule ref="Itineris"/>

<!-- TODO: Change everything below! -->
<!-- TODO: Exclude specific rules if necessary -->

<!-- TODO: Exclude some files -->
<exclude-pattern>/my-awesome-plugin.php</exclude-pattern>
<exclude-pattern>/tests/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>

<!-- TODO: Define minimum supported WordPress version -->
<config name="minimum_supported_wp_version" value="4.9"/>

<!-- TODO: Define expected text domains -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="wc-worldpay,woocommerce"/>
</properties>
</rule>
</ruleset>
```

Then, define a composer script:
```json
# composer.json
{
"scripts": {
"check-style": "phpcs --colors -p"
}
}
```

Run the command:
```php
$ composer check-style
```

## PrettyCI

Create [`.prettyci.composer.json`](https://prettyci.com/documentation) at project root:
```php
# .prettyci.composer.json
{
"require-dev": {
"itinerisltd/itineris-wp-coding-standards": "^999.999.999"
}
}
```

To make [PrettyCI](https://prettyci.com) works, ensure:
- you created [`.prettyci.composer.json`](https://prettyci.com/documentation) at project root
- you created [`phpcs.xml`](#usage) at project root
- versions in `.prettyci.composer.json` are the same as in `composer.json`

## Required Readings

- [Whitelisting code which flags errors](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors)
- [Flagged superglobal usage in WordPress VIP](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Flagged-superglobal-usage-in-WordPress-VIP)
- [Fixing errors for input data](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Fixing-errors-for-input-data)
- [Sanitizing array input data](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Sanitizing-array-input-data)
- [Customizable sniff properties](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties)

## FAQs

### Will you add support for older PHP versions?

Never! This plugin will only works on [actively supported PHP versions](https://secure.php.net/supported-versions.php).

Don't use it on **end of life** or **security fixes only** PHP versions.

### It looks awesome. Where can I find some more goodies like this?

- Articles on [Itineris' blog](https://www.itineris.co.uk/blog/)
- More projects on [Itineris' GitHub profile](https://github.com/itinerisltd)
- Follow [@itineris_ltd](https://twitter.com/itineris_ltd) and [@TangRufus](https://twitter.com/tangrufus) on Twitter
- Hire [Itineris](https://www.itineris.co.uk/services/) to build your next awesome site

### This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?

Thanks! Glad you like it. It's important to make my boss know somebody is using this project. Instead of giving reviews on wp.org, consider:

- tweet something good with mentioning [@itineris_ltd](https://twitter.com/itineris_ltd)
- star this [Github repo](https://github.com/ItinerisLtd/itineris-wp-coding-standards)
- watch this [Github repo](https://github.com/ItinerisLtd/itineris-wp-coding-standards)
- write blog posts
- submit pull requests
- [hire Itineris](https://www.itineris.co.uk/services/)

## Feedback

**Please provide feedback!** We want to make this library useful in as many projects as possible.
Please submit an [issue](https://github.com/ItinerisLtd/itineris-wp-coding-standards/issues/new) and point out what you do and don't like, or fork the project and make suggestions.
**No issue is too small.**

## Change Log

Please see [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently.

## Security

If you discover any security related issues, please email [hello@itineris.co.uk](mailto:hello@itineris.co.uk) instead of using the issue tracker.

## Credits

[Itineris WP Coding Standards](https://github.com/ItinerisLtd/itineris-wp-coding-standards) is a [Itineris Limited](https://www.itineris.co.uk/) project created by [Tang Rufus](https://typist.tech).

Full list of contributors can be found [here](https://github.com/ItinerisLtd/itineris-wp-coding-standards/graphs/contributors).

## License

[Itineris WP Coding Standards](https://github.com/ItinerisLtd/itineris-wp-coding-standards) is licensed under the [MIT License](https://opensource.org/licenses/MIT).
Please see [License File](./LICENSE) for more information.
110 changes: 55 additions & 55 deletions composer.json
@@ -1,60 +1,60 @@
{
"name": "itinerisltd/itineris-wp-coding-standards",
"type": "phpcodesniffer-standard",
"description": "PHP_CodeSniffer rules for Itineris WordPress projects",
"keywords": [
"phpcs",
"standards",
"wordpress",
"itineris"
],
"homepage": "https://itinerisltd.github.io/itineris-wp-coding-standards/",
"license": "MIT",
"authors": [
{
"name": "Itineris Limited",
"email": "hello@itineris.co.uk",
"homepage": "https://itineris.co.uk/",
"role": "Company"
},
{
"name": "Tang Rufus",
"email": "tangrufus@gmail.com",
"homepage": "https://typist.tech/",
"role": "Developer"
}
],
"require": {
"php": "^7.1",
"automattic/vipwpcs": "^0.3.0",
"wp-coding-standards/wpcs": "^1.1"
"name": "itinerisltd/itineris-wp-coding-standards",
"type": "phpcodesniffer-standard",
"description": "PHP_CodeSniffer rules for Itineris WordPress projects",
"keywords": [
"phpcs",
"standards",
"wordpress",
"itineris"
],
"homepage": "https://itinerisltd.github.io/itineris-wp-coding-standards/",
"license": "MIT",
"authors": [
{
"name": "Itineris Limited",
"email": "hello@itineris.co.uk",
"homepage": "https://itineris.co.uk/",
"role": "Company"
},
"require-dev": {
"roave/security-advisories": "dev-master"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
},
"prefer-stable": true,
"scripts": {
"pretag": [
"composer update",
"composer normalize",
"doctoc README.md",
"github_changelog_generator --no-verbose"
]
{
"name": "Tang Rufus",
"email": "tangrufus@gmail.com",
"homepage": "https://typist.tech/",
"role": "Developer"
}
],
"require": {
"php": "^7.1",
"automattic/vipwpcs": "^0.3.0",
"wp-coding-standards/wpcs": "^1.1"
},
"require-dev": {
"roave/security-advisories": "dev-master"
},
"config": {
"preferred-install": {
"*": "dist"
},
"support": {
"email": "hello@itineris.co.uk",
"issues": "https://github.com/ItinerisLtd/itineris-wp-coding-standards/issues",
"source": "https://github.com/ItinerisLtd/itineris-wp-coding-standards"
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
},
"prefer-stable": true,
"scripts": {
"pretag": [
"composer update",
"composer normalize",
"doctoc README.md",
"github_changelog_generator --no-verbose"
]
},
"support": {
"email": "hello@itineris.co.uk",
"issues": "https://github.com/ItinerisLtd/itineris-wp-coding-standards/issues",
"source": "https://github.com/ItinerisLtd/itineris-wp-coding-standards"
}
}