├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .github
└── dependabot.yml
├── .gitignore
├── .nvmrc
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── Required-Strict
└── ruleset.xml
├── Required
├── bootstrap.php
└── ruleset.xml
├── composer.json
├── lerna.json
├── package-lock.json
├── package.json
└── packages
├── eslint-config
├── README.md
├── index.js
└── package.json
└── stylelint-config
├── README.md
├── index.js
├── package.json
└── scss.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = tab
6 | indent_size = 4
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [{*.json,*.yml}]
15 | indent_style = space
16 | indent_size = 2
17 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /Required
3 | /**/node_modules/*
4 | !.*.js
5 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: [ './packages/eslint-config' ],
3 | };
4 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "composer"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | day: "tuesday"
8 | time: "06:00"
9 | timezone: "Europe/Zurich"
10 | open-pull-requests-limit: 3
11 | - package-ecosystem: "npm"
12 | directory: "/"
13 | schedule:
14 | interval: "weekly"
15 | day: "tuesday"
16 | time: "06:00"
17 | timezone: "Europe/Zurich"
18 | open-pull-requests-limit: 3
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | composer.lock
3 | node_modules/
4 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | 20
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 | ## [6.0.0] - 2024-02-09
8 |
9 | ### Changed
10 | * PHP: Update wp-coding-standards/wpcs from 2.3.0 to 3.0.1.
11 | Announcement: https://make.wordpress.org/core/2023/08/21/wordpresscs-3-0-0-is-now-available/
12 | * PHP: Update slevomat/coding-standard from 8.8.0 to [8.14.1](https://github.com/slevomat/coding-standard/releases/tag/8.14.1).
13 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.11.10 to [2.11.17](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.17).
14 | * JS: Increase minimum peer dependency of `@wordpress/eslint-plugin` from 13 to 17.
15 | * JS: Increase minimum peer dependency of `prettier` from 2.6 to 3.0.
16 |
17 | ## [5.0.0] - 2023-01-27
18 |
19 | ### Changed
20 | * PHP: Remove `minimum_supported_wp_version` and `testVersion`.
21 | Migration guide: Add the following to the `phpcs.xml.dist` file to restore previous behaviour.
22 | ```yml
23 |
24 |
25 |
26 |
27 | ```
28 | * PHP: Introduce `Required-Strict` ruleset for stricter rules.
29 | * PHP: Update slevomat/coding-standard from 8.6.4 to [8.8.0](https://github.com/slevomat/coding-standard/releases/tag/8.8.0).
30 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.11.9 to [2.11.10](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.10).
31 |
32 | ## [4.0.0] - 2022-12-08
33 |
34 | ### Changed
35 | * JS: Increase minimum peer dependency of `@wordpress/eslint-plugin` from 10 to 13.
36 | * JS: Increase minimum peer dependency of `prettier` to 2.6.
37 | * CSS: Increase minimum peer dependency of `@wordpress/stylelint-config` to 21.
38 | * PHP: Increase minimum PHP requirement to 7.2.
39 | * PHP: Update slevomat/coding-standard from 7.0.18 to [8.6.4](https://github.com/slevomat/coding-standard/releases/tag/8.6.4).
40 | * PHP: Update phpcompatibility/phpcompatibility-wp from 2.1.3 to [2.1.4](https://github.com/PHPCompatibility/PHPCompatibilityWP/releases/tag/2.1.4).
41 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.11.2 to [2.11.9](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.9).
42 |
43 |
44 | ## [3.0.0] - 2022-02-11
45 |
46 | ### Added
47 | * CSS: Add SCSS preset for stylelint-config.
48 |
49 | ### Changed
50 | * PHP: Update slevomat/coding-standard from 7.0.12 to [7.0.18](https://github.com/slevomat/coding-standard/releases/tag/7.0.18).
51 | * PHP: Update phpcompatibility/phpcompatibility-wp from 2.1.1 to [2.1.3](https://github.com/PHPCompatibility/PHPCompatibilityWP/releases/tag/2.1.3).
52 | * PHP: Allow to install on PHP 8.
53 | * JS: Increase minimum peer dependency of `eslint` from 7 to 8.
54 | * JS: Increase minimum peer dependency of `@wordpress/eslint-plugin` from 8/9 to 10.
55 | * CSS: Increase minimum peer dependency of `stylelint` from 13 to 14.
56 | * CSS: Increase minimum peer dependency of `@wordpress/stylelint-config` from 19 to 20.
57 |
58 | ### Fixed
59 | * CSS: Correctly set rules for `function-url-quotes` and `at-rule-no-unknown`.
60 |
61 | ## [2.2.0] - 2021-07-15
62 |
63 | ### Changed
64 | * PHP: Update slevomat/coding-standard from 6.4.1 to [7.0.12](https://github.com/slevomat/coding-standard/releases/tag/7.0.12).
65 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.11.0 to [2.11.2](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.2).
66 |
67 | ## [2.1.0] - 2021-04-13
68 |
69 | ### Changed
70 | * JS: Allow `@wordpress/eslint-plugin` v9 as dependency.
71 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.10.2 to [2.11.0](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.0).
72 |
73 | ## [2.0.0] - 2021-02-26
74 |
75 | ### Changed
76 | * PHP: Update sirbrillig/phpcs-variable-analysis from 2.10.0 to [2.10.2](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.10.2).
77 | * PHP: Increase `testVersion` for PHP Compatibility check to 7.4.
78 | * PHP: Increase `minimum_supported_wp_version` to 5.3.
79 | * CSS: Replace `stylelint-config-wordpress` with `@wordpress/stylelint-config`.
80 | * JS: Allow `@wordpress/eslint-plugin` v8 as dependency, remove v6.
81 |
82 | ### Added
83 | * PHP Rule `SlevomatCodingStandard.TypeHints.ReturnTypeHint`: Require type hints for return values.
84 | * PHP Rule `SlevomatCodingStandard.TypeHints.ParameterTypeHint`: Require type hints for parameters.
85 | * PHP Rule `SlevomatCodingStandard.TypeHints.UselessConstantTypeHint`: Disallow useless `@var` annotations.
86 | * PHP Rule `SlevomatCodingStandard.Classes.ClassConstantVisibility`: Require declaring the visibility of class constants.
87 | * PHP Rule `SlevomatCodingStandard.Functions.RequireArrowFunction`: Require short closures/arrow functions if possible.
88 | * PHP Rule `SlevomatCodingStandard.Functions.ArrowFunctionDeclaration`: Require specific style of arrow functions.
89 |
90 | ## [1.6.0] - 2020-12-12
91 |
92 | ### Changed
93 | * Update slevomat/coding-standard from 6.3.8 to [6.4.1](https://github.com/slevomat/coding-standard/releases/tag/6.4.1).
94 | * Update sirbrillig/phpcs-variable-analysis from 2.8.2 to [2.10.0](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.10.0) for PHP 7.4 support.
95 | * PHP: Add `@subpackage` to list of disallowed annotations.
96 | * CSS: Use renamed `declaration-property-unit-allowed-list` rule to avoid a deprecation warning. [[#103](https://github.com/wearerequired/coding-standards/issues/103)]
97 |
98 | ## [1.5.1] - 2020-06-15
99 |
100 | ### Changed
101 | * Update sirbrillig/phpcs-variable-analysis from 2.8.1 to [2.8.2](https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.8.2).
102 | * Update slevomat/coding-standard from 6.3.7 to [6.3.8](https://github.com/slevomat/coding-standard/releases/tag/6.3.8).
103 | * CSS: Always require quotes in `url()` unless empty.
104 | * CSS: Allow at-rules used by postcss-mixins.
105 | * Support `eslint` peer dependency up to 7.x.
106 | * Support `@wordpress/eslint-plugin` peer dependency up to 7.x.
107 |
108 | ## [1.5.0] - 2020-05-26
109 |
110 | ### Added
111 | * [@wearerequired/eslint-config](https://www.npmjs.com/package/@wearerequired/eslint-config) for linting JavaScript files.
112 | * [@wearerequired/stylelint-config](https://www.npmjs.com/package/@wearerequired/stylelint-config) for linting (S)CSS files.
113 |
114 | ### Changed
115 | * Update slevomat/coding-standard from 6.3.5 to [6.3.7](https://github.com/slevomat/coding-standard/releases/tag/6.3.7).
116 |
117 | ## [1.4.1] - 2020-05-18
118 |
119 | ### Changed
120 | * Update slevomat/coding-standard from 6.3.3 to [6.3.5](https://github.com/slevomat/coding-standard/releases/tag/6.3.5).
121 | * Update wp-coding-standards/wpcs from 2.2.1 to [2.3.0](https://github.com/wordpress/wordpress-coding-standards/releases/tag/2.3.0).
122 |
123 | ## [1.4.0] - 2020-05-04
124 |
125 | ### Changed
126 | * Update slevomat/coding-standard from 6.2.0 to [6.3.3](https://github.com/slevomat/coding-standard/releases/tag/6.3.3).
127 | * PHP: Disable `Generic.Commenting.DocComment.MissingShort` due to false-positives.
128 | * PHP: Allow the use of `json_encode()` and filesystem functions.
129 | * PHP: Allow `@global` and `@throws` annotations in PHPDoc.
130 |
131 | ## [1.3.0] - 2020-04-01
132 |
133 | ### Added
134 | * Re-enable rules `SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions` and `SlevomatCodingStandard.Namespaces.UnusedUses` rules.
135 | * Rule `SlevomatCodingStandard.Commenting.DocCommentSpacing`: Require specific order of PHPDoc annotations with empty newline between specific groups.
136 | * Rule `SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions` with `includeSpecialFunctions` set: Require root namespace for special compiled PHP functions to benefit of performance optimizations by the Zend engine.
137 |
138 | ### Changed
139 | * Update slevomat/coding-standard from 6.1.4 to [6.2.0](https://github.com/slevomat/coding-standard/releases/tag/6.2.0).
140 |
141 | ## [1.2.1] - 2020-03-20
142 |
143 | ### Removed
144 | * Disable rule `SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions` due to performance issues.
145 | * Disable rule `SlevomatCodingStandard.Namespaces.UnusedUses` due to performance issues.
146 |
147 | ## [1.2.0] - 2020-02-27
148 |
149 | ### Added
150 | * Rule `SlevomatCodingStandard.Namespaces.UnusedUses`: Disallow unused namespace imports.
151 | * Rule `SlevomatCodingStandard.Commenting.ForbiddenAnnotations`: Disallow annotations for `@package`, `@author`, `@created`, `@copyright`, `@version`, `@access`, and `@license`.
152 | * Rule `SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator`: Require use of null coalesce operator (`??`) when possible.
153 | * Rule `SlevomatCodingStandard.Classes.ModernClassNameReference`: Class names should be referenced via `::class` constant when possible.
154 | * Rule `SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions`: References to types named Exception or ending with Exception/Error must be referenced via a fully qualified name.
155 | * Rule `SlevomatCodingStandard.TypeHints.LongTypeHints`: Use shorthand scalar typehint variants in phpDocs.
156 | * Set PHP_CodeSniffer to cache results between runs.
157 |
158 | ### Changed
159 | * Update slevomat/coding-standard from 5.0.4 to [6.1.4](https://github.com/slevomat/coding-standard/releases/tag/6.1.4).
160 | * Update wp-coding-standards/wpcs from 2.2.0 to [2.2.1](https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/2.2.1).
161 | * Allow use of shorthand ternary operator.
162 |
163 | ## [1.1.0] - 2020-01-02
164 |
165 | ### Changed
166 | * Updated readme to mention all included checks.
167 | * Declare PHP 7.1 requirement.
168 | * Allow short array syntax.
169 | * Update and use exact versions for requirements.
170 | * phpcompatibility/phpcompatibility-wp: 2.1.0
171 | * sirbrillig/phpcs-variable-analysis: 2.8.0
172 | * slevomat/coding-standard: 5.0.4
173 | * wp-coding-standards/wpcs: 2.2.0
174 |
175 | ## [1.0.0] - 2019-03-15
176 |
177 | ### Added
178 | * [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) for adopting default coding standards of WordPress.
179 | * [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis) for problematic variable use.
180 | * [Slevomat Coding Standard](https://github.com/slevomat/coding-standard) for PHP >=7 development.
181 |
182 | [Unreleased]: https://github.com/wearerequired/coding-standards/compare/5.0.0...HEAD
183 | [6.0.0]: https://github.com/wearerequired/coding-standards/compare/5.0.0...6.0.0
184 | [5.0.0]: https://github.com/wearerequired/coding-standards/compare/4.0.0...5.0.0
185 | [4.0.0]: https://github.com/wearerequired/coding-standards/compare/3.0.0...4.0.0
186 | [3.0.0]: https://github.com/wearerequired/coding-standards/compare/2.2.0...3.0.0
187 | [2.2.0]: https://github.com/wearerequired/coding-standards/compare/2.1.0...2.2.0
188 | [2.1.0]: https://github.com/wearerequired/coding-standards/compare/2.0.0...2.1.0
189 | [2.0.0]: https://github.com/wearerequired/coding-standards/compare/1.6.0...2.0.0
190 | [1.6.0]: https://github.com/wearerequired/coding-standards/compare/1.5.1...1.6.0
191 | [1.5.1]: https://github.com/wearerequired/coding-standards/compare/1.5.0...1.5.1
192 | [1.5.0]: https://github.com/wearerequired/coding-standards/compare/1.4.1...1.5.0
193 | [1.4.1]: https://github.com/wearerequired/coding-standards/compare/1.4.0...1.4.1
194 | [1.4.0]: https://github.com/wearerequired/coding-standards/compare/1.3.0...1.4.0
195 | [1.3.0]: https://github.com/wearerequired/coding-standards/compare/1.2.1...1.3.0
196 | [1.2.1]: https://github.com/wearerequired/coding-standards/compare/1.2.0...1.2.1
197 | [1.2.0]: https://github.com/wearerequired/coding-standards/compare/1.1.0...1.2.0
198 | [1.1.0]: https://github.com/wearerequired/coding-standards/compare/1.0.0...1.1.0
199 | [1.0.0]: https://github.com/wearerequired/coding-standards/compare/4c576a1...1.0.0
200 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | The required coding standards represent the best practices for enabling a consistent code style across the team. As the way we work evolves over time, our coding standards likewise need to evolve.
4 |
5 | ## Rule Changes
6 |
7 | For changing or adding rules please start a new issue and/or submit a pull request for discussion.
8 |
9 | ## Releasing
10 |
11 | All notable changes to this project must be documented in the [CHANGELOG.md](CHANGELOG.md) file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12 |
13 | The project consists of one PHP package (published on [packagist.org](https://packagist.org/users/wearerequired/)) and two JavaScript packages (published on [npmjs.com](https://www.npmjs.com/org/wearerequired)). All packages must be published with the same version.
14 | For dependent package management this project uses [Lerna](https://lerna.js.org/).
15 |
16 | ### Releasing Packages
17 |
18 | If you haven't yet, run `npm install`.
19 |
20 | Lerna automatically releases all outdated packages. To check which packages are outdated and will be released, type `npm run publish:check`.
21 |
22 | If you have the ability to publish packages, you must have [2FA enabled](https://docs.npmjs.com/about-two-factor-authentication). Confirm that you're logged in to npm, by running `npm whoami`. If you're not logged in, run `npm adduser` to login.
23 |
24 | #### Development Release
25 |
26 | Run the following command to release a dev version of the outdated packages.
27 |
28 | ```shell
29 | npm run publish:dev
30 | ```
31 |
32 | Lerna will ask you which version number you want to choose for all packages. For a `dev` release, you'll more likely want to choose the "prerelease" option.
33 |
34 | Lerna will then publish to npm, commit the `package.json` changes and create the git tags.
35 |
36 | **Note**: If Lerna doesn't detect any changes since only the PHP package was updated use `--force-publish`.
37 |
38 | ```shell
39 | npm run publish:dev -- --force-publish
40 | ```
41 |
42 | #### Production Release
43 |
44 | To release a production version for the outdated packages, run the following command:
45 |
46 | ```shell
47 | npm run publish:prod
48 | ```
49 |
50 | Choose the correct version based on the [CHANGELOG.md](CHANGELOG.md) file, confirm your choices and let Lerna do its magic.
51 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # required Coding Standards
2 |
3 | [![eslint-config version][eslint-config-version]](https://www.npmjs.com/package/@wearerequired/eslint-config) [![phpcodesniffer version][phpcodesniffer-version]](https://packagist.org/packages/wearerequired/coding-standards) [![stylelint-config version][stylelint-config-version]](https://www.npmjs.com/package/@wearerequired/stylelint-config)
4 |
5 | The required coding standards represent the best practices for enabling a consistent code style across the team. The standards do not only contain stylistic rules. They are also defined to prevent potential security vulnerabilities or to leverage more modern syntax for enhanced performance.
6 | This project is inspired by the [Human Made Coding Standards](https://github.com/humanmade/coding-standards) project.
7 |
8 | For the JavaScript coding standard head over to [@wearerequired/eslint-config](packages/eslint-config).
9 | For the (S)CSS coding standard head over to [@wearerequired/stylelint-config](packages/stylelint-config).
10 |
11 | For team members: Please contact our internal handbook if you need help with [setting up the coding standards in your environment](https://handbook.required.com/development/coding-standards/).
12 |
13 | ## required PHP Coding Standard
14 |
15 | ### Setup
16 |
17 | 1. `composer require --dev dealerdirect/phpcodesniffer-composer-installer wearerequired/coding-standards`
18 | 2. Run the standards checks using the following command:
19 |
20 | ```
21 | vendor/bin/phpcs .
22 | ```
23 |
24 | 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.
25 |
26 | You can add this to your Travis CI configuration as a test:
27 |
28 | ```yaml
29 | script:
30 | - phpunit
31 | - vendor/bin/phpcs .
32 | ```
33 |
34 | **Bonus**: To make things easier, you can add something as follows to your `composer.json` file:
35 |
36 | ```json
37 | {
38 | "scripts": {
39 | "format": "vendor/bin/phpcbf --report-summary --report-source .",
40 | "lint": "vendor/bin/phpcs --report-summary --report-source ."
41 | }
42 | }
43 | ```
44 |
45 | After that, run `composer lint` to run the standards checks and `composer format` to try auto-fixing of errors and warnings.
46 |
47 | #### Excluding Files
48 |
49 | This 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)). You can place a `.phpcsignore` file in your root directory (wherever you're going to run `phpcs` from).
50 |
51 | 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:
52 |
53 | ```
54 | # Exclude our tests directory.
55 | tests/
56 |
57 | # Exclude any file ending with ".inc"
58 | *\.inc
59 | ```
60 |
61 | Note 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.
62 |
63 | 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.**
64 |
65 | #### Advanced/Extending
66 |
67 | You can create your own custom standard file (e.g. `phpcs.xml.dist`) if you want to extend these coding standards:
68 |
69 | ```xml
70 |
71 |
72 | Project specific coding standard.
73 |
74 |
75 | .
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | ```
88 |
89 | You can then reference this file when running phpcs:
90 |
91 | ```
92 | vendor/bin/phpcs
93 | ```
94 |
95 | An example for a custom rule is to validate the text domain:
96 |
97 | ```xml
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | ```
106 |
107 | or to ensure the correct prefix is used:
108 |
109 | ```xml
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | ```
119 |
120 | If the project is a WordPress theme you have to set the following rule:
121 |
122 | ```xml
123 |
124 |
125 |
126 |
127 |
128 | ```
129 |
130 | ### Included Checks
131 |
132 | The phpcs standard is based upon the `WordPress-Core`, `WordPress-Docs`, and `WordPress-Extra` rules from the [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards). It also uses [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis) for problematic variable use and some `SlevomatCodingStandard` rules from the [Slevomat Coding Standard](https://github.com/slevomat/coding-standard). Most of the sniffs are also providing automatic errors fixing for `phpcbf`.
133 |
134 |
135 | ## EditorConfig
136 |
137 | The [EditorConfig](https://editorconfig.org/) standard helps developers define and maintain consistent coding styles between different editors and IDEs. This way it's easier to follow the given coding standards in a project, without the need to fiddle with IDE settings.
138 |
139 | The recommended `.editorconfig` file for a WordPress project looks like this:
140 |
141 | ```editorconfig
142 | root = true
143 |
144 | [*]
145 | charset = utf-8
146 | indent_style = tab
147 | indent_size = 4
148 | end_of_line = lf
149 | insert_final_newline = true
150 | trim_trailing_whitespace = true
151 |
152 | [*.md]
153 | trim_trailing_whitespace = false
154 |
155 | [{*.json,*.yml}]
156 | indent_style = space
157 | indent_size = 2
158 | ```
159 |
160 |
161 |
162 | [](https://required.com/en/lets-get-in-touch/)
163 |
164 | [phpcodesniffer-version]: https://img.shields.io/packagist/v/wearerequired/coding-standards?label=phpcodesniffer-standard
165 | [eslint-config-version]: https://img.shields.io/npm/v/@wearerequired/eslint-config?label=eslint-config
166 | [stylelint-config-version]: https://img.shields.io/npm/v/@wearerequired/stylelint-config?label=stylelint-config
167 |
--------------------------------------------------------------------------------
/Required-Strict/ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | required Strict Coding Standards
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Required/bootstrap.php:
--------------------------------------------------------------------------------
1 | config->files;
57 | $ignored = $runner->config->ignored;
58 |
59 | // Find exclusion files.
60 | $did_change = false;
61 | foreach ( $paths as $path ) {
62 | // Only use ignore files for directories.
63 | if ( ! is_dir( $path ) ) {
64 | continue;
65 | }
66 |
67 | // Find an ignore file.
68 | $directory = $path;
69 | $ignore_file = $directory . '/.phpcsignore';
70 | if ( ! file_exists( $ignore_file ) ) {
71 | continue;
72 | }
73 | if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
74 | echo "\tAdding exclusion rules from $ignore_file\n";
75 | }
76 |
77 | $extra_ignores = get_ignores_from_file( $ignore_file, $directory );
78 | if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
79 | foreach ( $extra_ignores as $rule ) {
80 | echo "\t\t=> $rule\n";
81 | }
82 | }
83 |
84 | $did_change = true;
85 | $ignored = array_merge( $ignored, $extra_ignores );
86 | }
87 |
88 | if ( $did_change ) {
89 | $runner->config->ignored = $ignored;
90 | }
91 | }
92 |
93 | if ( ! empty( $GLOBALS['runner'] ) ) {
94 | attach_to_runner( $GLOBALS['runner'] );
95 | }
96 |
--------------------------------------------------------------------------------
/Required/ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | required Coding Standards
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 | ./bootstrap.php
20 |
21 | */node_modules/*
22 | */vendor/*
23 | *\.min\.*
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | warning
113 |
114 |
115 |
116 |
117 | warning
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
224 |
229 |
232 |
235 |
239 |
240 |
241 |
242 |
243 |
244 |
245 | 0
246 |
247 |
248 |
249 |
250 |
251 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wearerequired/coding-standards",
3 | "description": "required Coding Standards",
4 | "type": "phpcodesniffer-standard",
5 | "license": "GPL-2.0-or-later",
6 | "config": {
7 | "sort-packages": true,
8 | "allow-plugins": {
9 | "dealerdirect/phpcodesniffer-composer-installer": true
10 | }
11 | },
12 | "minimum-stability": "dev",
13 | "prefer-stable": true,
14 | "require": {
15 | "php": "^7.2 || ^8.0",
16 | "phpcompatibility/phpcompatibility-wp": "2.1.5",
17 | "sirbrillig/phpcs-variable-analysis": "2.11.18",
18 | "slevomat/coding-standard": "8.15.0",
19 | "wp-coding-standards/wpcs": "3.1.0"
20 | },
21 | "suggest": {
22 | "dealerdirect/phpcodesniffer-composer-installer": "Automatically adds this package's ruleset to the installed_paths option of PHP_CodeSniffer"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/lerna/schemas/lerna-schema.json",
3 | "packages": ["packages/*"],
4 | "version": "6.0.0",
5 | "command": {
6 | "publish": {
7 | "tagVersionPrefix": ""
8 | },
9 | "version": {
10 | "message": "Publish %s",
11 | "signGitTag": true,
12 | "tagVersionPrefix": ""
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@wearerequired/coding-standards",
3 | "version": "0.0.0",
4 | "description": "required Coding Standards",
5 | "repository": {
6 | "type": "git",
7 | "url": "git+https://github.com/wearerequired/coding-standards.git"
8 | },
9 | "keywords": [
10 | "eslint",
11 | "eslintconfig",
12 | "config",
13 | "stylelint",
14 | "stylelintrc"
15 | ],
16 | "author": "required gmbh",
17 | "license": "GPL-2.0-or-later",
18 | "bugs": {
19 | "url": "https://github.com/wearerequired/coding-standards/issues"
20 | },
21 | "homepage": "https://github.com/wearerequired/coding-standards/tree/master/packages/eslint-config#readme",
22 | "private": true,
23 | "devDependencies": {
24 | "@wearerequired/eslint-config": "file:packages/eslint-config",
25 | "lerna": "^8.0.2",
26 | "prettier": "npm:wp-prettier@3.0.3"
27 | },
28 | "scripts": {
29 | "publish:check": "lerna updated",
30 | "publish:dev": "lerna publish --dist-tag next",
31 | "publish:prod": "lerna publish",
32 | "lint-js": "eslint .",
33 | "lint-js:fix": "npm run lint-js -- --fix"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/eslint-config/README.md:
--------------------------------------------------------------------------------
1 | # required JavaScript Coding Standard
2 |
3 | required coding standard for JavaScript, based on the rules provided by [`@wordpress/eslint-plugin`](https://developer.wordpress.org/block-editor/packages/packages-eslint-plugin/).
4 |
5 | ## Installation
6 |
7 | This package is an ESLint shareable configuration and requires `eslint` and `@wordpress/eslint-plugin` to be installed. To install this config and the peerDependencies run:
8 |
9 | ```bash
10 | npx install-peerdeps --dev @wearerequired/eslint-config@latest
11 | ```
12 |
13 | ## Usage
14 |
15 | To opt-in to the default configuration, extend your own project's `.eslintrc.js` file:
16 |
17 | ```js
18 | module.exports = {
19 | extends: [ '@wearerequired/eslint-config' ],
20 | };
21 | ```
22 |
23 |
24 |
25 | [](https://required.com/en/lets-get-in-touch/)
26 |
--------------------------------------------------------------------------------
/packages/eslint-config/index.js:
--------------------------------------------------------------------------------
1 | // See @wordpress/prettier-config.
2 | const prettierConfig = {
3 | useTabs: true,
4 | tabWidth: 4,
5 | printWidth: 100, // Default 80.
6 | singleQuote: true,
7 | trailingComma: 'es5',
8 | bracketSpacing: true,
9 | parenSpacing: true,
10 | bracketSameLine: false,
11 | semi: true,
12 | arrowParens: 'always',
13 | };
14 |
15 | module.exports = {
16 | root: true,
17 | env: {
18 | browser: true,
19 | es6: true,
20 | },
21 | extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
22 | rules: {
23 | 'prettier/prettier': [ 'error', prettierConfig ],
24 | },
25 | settings: {
26 | 'import/core-modules': [
27 | 'react',
28 | 'react-dom',
29 | 'lodash',
30 | 'lodash-es',
31 | 'jquery',
32 | 'moment',
33 | '@wordpress/a11y',
34 | '@wordpress/annotations',
35 | '@wordpress/api-fetch',
36 | '@wordpress/autop',
37 | '@wordpress/blob',
38 | '@wordpress/block-directory',
39 | '@wordpress/block-editor',
40 | '@wordpress/block-library',
41 | '@wordpress/block-serialization-default-parser',
42 | '@wordpress/blocks',
43 | '@wordpress/components',
44 | '@wordpress/compose',
45 | '@wordpress/core-data',
46 | '@wordpress/data',
47 | '@wordpress/data-controls',
48 | '@wordpress/date',
49 | '@wordpress/deprecated',
50 | '@wordpress/dom',
51 | '@wordpress/dom-ready',
52 | '@wordpress/edit-post',
53 | '@wordpress/editor',
54 | '@wordpress/element',
55 | '@wordpress/escape-html',
56 | '@wordpress/format-library',
57 | '@wordpress/hooks',
58 | '@wordpress/html-entities',
59 | '@wordpress/i18n',
60 | '@wordpress/is-shallow-equal',
61 | '@wordpress/keyboard-shortcuts',
62 | '@wordpress/keycodes',
63 | '@wordpress/list-reusable-blocks',
64 | '@wordpress/media-utils',
65 | '@wordpress/notices',
66 | '@wordpress/nux',
67 | '@wordpress/plugins',
68 | '@wordpress/primitives',
69 | '@wordpress/priority-queue',
70 | '@wordpress/redux-routine',
71 | '@wordpress/reusable-blocks',
72 | '@wordpress/rich-text',
73 | '@wordpress/server-side-render',
74 | '@wordpress/shortcode',
75 | '@wordpress/token-list',
76 | '@wordpress/url',
77 | '@wordpress/viewport',
78 | '@wordpress/warning',
79 | '@wordpress/wordcount',
80 | ],
81 | },
82 | };
83 |
--------------------------------------------------------------------------------
/packages/eslint-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@wearerequired/eslint-config",
3 | "version": "6.0.0",
4 | "description": "required coding standard for JavaScript.",
5 | "repository": {
6 | "type": "git",
7 | "url": "git+https://github.com/wearerequired/coding-standards.git"
8 | },
9 | "keywords": [
10 | "eslint",
11 | "eslintconfig",
12 | "config",
13 | "javascript",
14 | "coding",
15 | "standard"
16 | ],
17 | "author": "required gmbh",
18 | "license": "GPL-2.0-or-later",
19 | "bugs": {
20 | "url": "https://github.com/wearerequired/coding-standards/issues"
21 | },
22 | "homepage": "https://github.com/wearerequired/coding-standards/tree/master/packages/eslint-config#readme",
23 | "peerDependencies": {
24 | "@wordpress/eslint-plugin": ">=17",
25 | "eslint": ">=8",
26 | "prettier": ">=3"
27 | },
28 | "publishConfig": {
29 | "access": "public"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/stylelint-config/README.md:
--------------------------------------------------------------------------------
1 | # required (S)CSS Coding Standard
2 |
3 | required coding standard for (S)CSS, based on the rules provided by [`@wordpress/stylelint-config`](https://developer.wordpress.org/block-editor/packages/packages-stylelint-config/).
4 |
5 | ## Installation
6 |
7 | This package is an stylelint shareable configuration and requires `stylelint` and `@wordpress/stylelint-config` to be installed. To install this config and the peerDependencies run:
8 |
9 | ```bash
10 | npx install-peerdeps --dev @wearerequired/stylelint-config@latest
11 | ```
12 |
13 | ## Usage
14 |
15 | To opt-in to the default configuration, extend your own project's `stylelint.config.js` file:
16 |
17 | ```js
18 | module.exports = {
19 | extends: [ '@wearerequired/stylelint-config' ],
20 | };
21 | ```
22 |
23 | ### SCSS Preset
24 |
25 | In addition to the default preset, there is also a SCSS preset. This preset extends both `@wearerequired/stylelint-config` and [`stylelint-config-recommended-scss`](https://github.com/stylelint-scss/stylelint-config-recommended-scss).
26 |
27 | ```js
28 | module.exports = {
29 | extends: [ '@wearerequired/stylelint-config/scss' ],
30 | };
31 | ```
32 |
33 |
34 |
35 | [](https://required.com/en/lets-get-in-touch/)
36 |
--------------------------------------------------------------------------------
/packages/stylelint-config/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: '@wordpress/stylelint-config',
3 | rules: {
4 | 'max-line-length': 100,
5 | 'max-empty-lines': 1,
6 | 'rule-empty-line-before': [
7 | 'always',
8 | {
9 | except: [ 'first-nested' ],
10 | ignore: [ 'after-comment' ],
11 | },
12 | ],
13 | 'comment-empty-line-before': [
14 | 'always',
15 | {
16 | except: [ 'first-nested' ],
17 | ignore: [ 'stylelint-commands' ],
18 | },
19 | ],
20 | 'at-rule-empty-line-before': [
21 | 'always',
22 | {
23 | except: [ 'blockless-after-blockless', 'first-nested' ],
24 | ignore: [ 'after-comment' ],
25 | },
26 | ],
27 | 'media-feature-parentheses-space-inside': 'always',
28 | 'function-parentheses-space-inside': 'always-single-line',
29 | 'function-comma-space-after': 'always-single-line',
30 | 'number-leading-zero': 'never',
31 | 'selector-class-pattern': [
32 | // See https://en.bem.info/methodology/naming-convention/#two-dashes-style.
33 | '^(?(?:[a-z][a-z0-9]*)(?:-[a-z0-9]+)*)(?(?:__[a-z][a-z0-9]*(?:-[a-z0-9]+)*))?(?(?:--[a-z][a-z0-9]*)(?:-[a-z0-9]+)*)?$',
34 | {
35 | resolveNestedSelectors: true,
36 | message:
37 | 'Selector should use lowercase and hyphens to separate words or in BEM style: block-name__elem-name--mod-name (selector-class-pattern)',
38 | },
39 | ],
40 | 'function-url-quotes': [
41 | 'always',
42 | {
43 | except: [ 'empty' ],
44 | },
45 | ],
46 | // At-rules used by postcss-mixins.
47 | 'at-rule-no-unknown': [ true, { ignoreAtRules: [ 'define-mixin', 'mixin' ] } ],
48 | },
49 | };
50 |
--------------------------------------------------------------------------------
/packages/stylelint-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@wearerequired/stylelint-config",
3 | "version": "6.0.0",
4 | "description": "required coding standard for (S)CSS.",
5 | "repository": {
6 | "type": "git",
7 | "url": "git+https://github.com/wearerequired/coding-standards.git"
8 | },
9 | "keywords": [
10 | "stylelint",
11 | "stylelintrc",
12 | "config",
13 | "css",
14 | "scss",
15 | "postcss",
16 | "coding standard"
17 | ],
18 | "author": "required gmbh",
19 | "license": "GPL-2.0-or-later",
20 | "bugs": {
21 | "url": "https://github.com/wearerequired/coding-standards/issues"
22 | },
23 | "homepage": "https://github.com/wearerequired/coding-standards/tree/master/packages/stylelint-config#readme",
24 | "peerDependencies": {
25 | "@wordpress/stylelint-config": "^21",
26 | "stylelint": "^14"
27 | },
28 | "publishConfig": {
29 | "access": "public"
30 | },
31 | "dependencies": {
32 | "stylelint-config-recommended-scss": "^8.0.0"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/packages/stylelint-config/scss.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: [ './', 'stylelint-config-recommended-scss' ].map( require.resolve ),
3 |
4 | plugins: [ 'stylelint-scss' ],
5 |
6 | rules: {
7 | 'at-rule-empty-line-before': [
8 | 'always',
9 | {
10 | except: [ 'blockless-after-blockless', 'first-nested' ],
11 | ignore: [ 'after-comment' ],
12 | ignoreAtRules: [ 'else' ],
13 | },
14 | ],
15 | 'block-opening-brace-space-before': 'always',
16 | 'block-closing-brace-newline-after': [
17 | 'always',
18 | {
19 | ignoreAtRules: [ 'if', 'else' ],
20 | },
21 | ],
22 | 'at-rule-name-space-after': 'always',
23 | 'scss/at-else-closing-brace-newline-after': 'always-last-in-chain',
24 | 'scss/at-else-closing-brace-space-after': 'always-intermediate',
25 | 'scss/at-else-empty-line-before': 'never',
26 | 'scss/at-if-closing-brace-newline-after': 'always-last-in-chain',
27 | 'scss/at-if-closing-brace-space-after': 'always-intermediate',
28 | 'scss/selector-no-redundant-nesting-selector': true,
29 | },
30 | };
31 |
--------------------------------------------------------------------------------