Skip to content

Commit acf7581

Browse files
Mile23paul-m
authored andcommitted
Issue #2876449 by Mile23: Update STANDARDS.md
1 parent c78c030 commit acf7581

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

STANDARDS.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
HOWTO: Drupal Examples For Developers Coding Standards
2-
=======================================================
1+
Developing with Coding Standards for Examples for Developers
2+
============================================================
33

44
Examples uses mostly the same coding standards as Drupal core.
55

@@ -9,7 +9,7 @@ those used by Examples, please file an issue so that Examples can follow core.
99
Examples uses the `phpcs` tool to allow for checking PHP coding standards. We
1010
use the `drupal/coder` project for Drupal-specific coding standards.
1111

12-
We also use `eslint` for JavaScript coding standards.
12+
We also use `eslint` for JavaScript coding standards, and `csslint` for CSS.
1313

1414
Examples has a `phpcs.xml.dist` file at the root of the project. phpcs uses this
1515
file to specify the current coding standards 'sniffs' which code in the project
@@ -30,34 +30,28 @@ Drupal-specific coding standards. We're currently locked to Coder version
3030
Installing phpcs
3131
----------------
3232

33-
Use Composer to add Drupal's Coder project to your root Drupal project. Coder
34-
contains the PHP_CodeSniffer rules we need, and also requires `phpcs`.
33+
Current versions of Drupal 8 core require phpcs and Coder as dev dependencies.
34+
That means they're already probably installed in your core vendor/ directory.
3535

36-
Then tell `phpcs' where our Drupal-specific rules are.
36+
We need to tell `phpcs` to use the Drupal coding standard provided by Coder,
37+
because it isn't configured that way by default.
3738

3839
Like this:
3940

4041
$ cd my/drupal/root/
41-
$ composer require drupal/coder 8.2.8
42-
// Composer installs Coder, which requires PHP_CodeSniffer as well.
43-
// Configure phpcs to use the Drupal standard rules...
44-
$ ./vendor/bin/phpcs --config-set installed_paths /path/to/drupal/vendor/drupal/coder/coder_sniffer/
42+
$ ./vendor/bin/phpcs --config-set installed_paths /full/path/to/drupal/vendor/drupal/coder/coder_sniffer/
4543
// phpcs now knows how to find the Drupal standard. You can test it:
4644
$ cd core
4745
$ ../vendor/bin/phpcs -e --standard=Drupal
4846
// Shows you a bunch of Drupal-related sniffs.
4947

50-
Note that there is an issue to require Coder and phpcs as part of Drupal core:
51-
https://www.drupal.org/node/2744463 Once this issue is fixed, you shouldn't need
52-
to install phpcs before using it.
53-
5448
Running phpcs
5549
-------------
5650

5751
Now you can run phpcs:
5852

5953
$ cd modules/examples
60-
$ ../../vendor/bin/phpcs -p -s
54+
$ ../../vendor/bin/phpcs -ps
6155
// phpcs uses Exampes' phpcs.xml.dist to verify coding standards.
6256
// -p shows you progress dots.
6357
// -s shows you sniff errors in the report.

0 commit comments

Comments
 (0)