{"id":13549110,"url":"https://github.com/humanmade/coding-standards","last_synced_at":"2025-04-07T09:15:23.249Z","repository":{"id":37444933,"uuid":"75812837","full_name":"humanmade/coding-standards","owner":"humanmade","description":"Human Made coding standards for modern code","archived":false,"fork":false,"pushed_at":"2024-09-24T17:42:24.000Z","size":9362,"stargazers_count":154,"open_issues_count":44,"forks_count":18,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-03-31T08:07:26.654Z","etag":null,"topics":["eslint-config","eslint-rules","phpcs","stylelint-config","wordpress"],"latest_commit_sha":null,"homepage":"https://engineering.hmn.md/how-we-work/style/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humanmade.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-07T07:54:15.000Z","updated_at":"2025-03-14T03:58:10.000Z","dependencies_parsed_at":"2024-03-16T20:26:15.850Z","dependency_job_id":"15cc8033-40b1-41ef-b5ee-394e6865e021","html_url":"https://github.com/humanmade/coding-standards","commit_stats":{"total_commits":584,"total_committers":26,"mean_commits":22.46153846153846,"dds":0.6660958904109588,"last_synced_commit":"331324c4af6d17adbc60a2e6304b74d95474e04a"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Fcoding-standards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Fcoding-standards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Fcoding-standards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Fcoding-standards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humanmade","download_url":"https://codeload.github.com/humanmade/coding-standards/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247622988,"owners_count":20968575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint-config","eslint-rules","phpcs","stylelint-config","wordpress"],"created_at":"2024-08-01T12:01:18.361Z","updated_at":"2025-04-07T09:15:23.214Z","avatar_url":"https://github.com/humanmade.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"\u003ctable width=\"100%\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"left\" width=\"70%\"\u003e\n\t\t\t\u003cstrong\u003eHuman Made Coding Standards\u003c/strong\u003e\u003cbr /\u003e\n\t\t\tWordPress coding standards, enhanced for modern development.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\" width=\"30%\"\u003e\n\t\t\t\u003ca href=\"https://packagist.org/packages/humanmade/coding-standards\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/humanmade/coding-standards.svg\" /\u003e\u003c/a\u003e\n\t\t\t\u003ca href=\"https://www.npmjs.com/package/@humanmade/eslint-config\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@humanmade/eslint-config?label=%40humanmade%2Feslint-config\" /\u003e\u003c/a\u003e\n\t\t\t\u003ca href=\"https://www.npmjs.com/package/@humanmade/stylelint-config\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@humanmade/stylelint-config?label=%40humanmade%2Fstylelint-config\" /\u003e\u003c/a\u003e\n\t\t\t\u003cimg src=\"https://travis-ci.com/humanmade/coding-standards.svg?branch=master\" alt=\"Build Status\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\n\t\t\tA \u003cstrong\u003e\u003ca href=\"https://hmn.md/\"\u003eHuman Made\u003c/a\u003e\u003c/strong\u003e project.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\" width=\"30%\"\u003e\n\t\t\t\u003cimg src=\"https://hmn.md/content/themes/hmnmd/assets/images/hm-logo.svg\" width=\"100\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\nThis is a codified version of [the Human Made style guide](http://engineering.hmn.md/how-we-work/style/). We include phpcs, ESLint, and stylelint rules.\n\n## Contributing\n\nWe 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](CONTRIBUTING.md) file.\n\n## Setup\n\nEach ruleset is available individually via Composer or NPM. To install the needed ruleset, use one of the following commands:\n\n - PHPCS: `composer require --dev humanmade/coding-standards`\n - ESLint: `npx install-peerdeps --dev @humanmade/eslint-config@latest`\n - stylelint: `npm install --save-dev stylelint @humanmade/stylelint-config`\n\n## Using PHPCS\n\nRun the following command to run the standards checks:\n\n```\nvendor/bin/phpcs --standard=vendor/humanmade/coding-standards .\n```\n\nWe use the [DealerDirect phpcodesniffer-composer-installer](https://github.com/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.   \n\nThe 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.\n\nYou can add this to your Travis YAML file as a test:\n\n```yaml\nscript:\n  - phpunit\n  - vendor/bin/phpcs --standard=vendor/humanmade/coding-standards .\n```\n\n### Excluding Files\n\nThis standard includes special support for a `.phpcsignore` file (in the future, this should be [built into phpcs itself](https://github.com/squizlabs/PHP_CodeSniffer/issues/1884)). Simply place a `.phpcsignore` file in your root directory (wherever you're going to run `phpcs` from).\n\nThe 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:\n\n```\n# Exclude our tests directory.\ntests/\n\n# Exclude any file ending with \".inc\"\n*\\.inc\n```\n\nNote that the patterns should match [the PHP_CodeSniffer style](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders): `*` is translated to `.*` for convenience, but all other characters work like a regular expression.\n\nPatterns 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.**\n\n\n### Advanced/Extending\n\nIf 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`):\n\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cruleset\u003e\n\t\u003c!-- Files or directories to check --\u003e\n\t\u003cfile\u003e.\u003c/file\u003e\n\n\t\u003c!-- Path to strip from the front of file paths inside reports (displays shorter paths) --\u003e\n\t\u003carg name=\"basepath\" value=\".\" /\u003e\n\n\t\u003c!-- Set a minimum PHP version for PHPCompatibility --\u003e\n\t\u003cconfig name=\"testVersion\" value=\"7.2-\" /\u003e\n\n\t\u003c!-- Use HM Coding Standards --\u003e\n\t\u003crule ref=\"vendor/humanmade/coding-standards\" /\u003e\n\n\t\u003c!-- Add VIP-specific rules --\u003e\n\t\u003crule ref=\"WordPress-VIP\" /\u003e\n\u003c/ruleset\u003e\n```\n\nYou can then reference this file when running phpcs:\n\n```\nvendor/bin/phpcs --standard=phpcs.ruleset.xml .\n```\n\n\n#### Excluding/Disabling Checks\n\nYou can also customise the rule to exclude elements if they aren't applicable to the project:\n\n```xml\n\u003crule ref=\"vendor/humanmade/coding-standards\"\u003e\n\t\u003c!-- Disable short array syntax --\u003e\n\t\u003cexclude name=\"HM.Debug.ForceShortArray\" /\u003e\n\u003c/rule\u003e\n```\n\nRules can also be disabled inline. [phpcs rules can be disabled](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file) with a `// @codingStandardsIgnoreLine` comment, and [ESLint rules can be disabled](http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) with a `/* eslint disable ... */` comment.\n\nTo 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.\n\n\n## Included Checks\n\nThe phpcs standard is based upon the `WordPress-VIP` standard from [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards), with [customisation and additions](HM/ruleset.xml) to match our style guide.\n\n## Using ESLint\n\nThe ESLint package contains an [ESLint](https://eslint.org/) 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](https://github.com/humanmade/linter-bot). See [the `@humanmade/eslint-config` package README](packages/eslint-config-humanmade/readme.md) for more information on configuring ESLint to use the Human Made coding standards.\n\nOnce you have installed the [`@humanmade/eslint-config` npm package](https://www.npmjs.com/package/@humanmade/eslint-config), 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 .`\n\nAlternatively, you can create your own configuration and extend these rules:\n\n`.eslintrc`\n```json\n{\n  \"extends\": \"@humanmade\"\n}\n```\n\n## Using stylelint\n\nThe stylelint package contains a [stylelint](https://stylelint.io/) 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](https://github.com/humanmade/linter-bot). See [the `@humanmade/stylelint` package README](packages/stylelint-config/readme.md) for more information on configuring stylelint to use the Human Made coding standards.\n\nTo 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.\n\n```json\n{\n  \"extends\": \"@humanmade/stylelint-config\",\n  \"rules\": {\n    ...\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Fcoding-standards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanmade%2Fcoding-standards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Fcoding-standards/lists"}