@sinemacula/coding-standards 1.12.2 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -59
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,10 +98,16 @@ After installing the npm package, extend the shared Biome config from your proje
|
|
|
98
98
|
{
|
|
99
99
|
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
|
100
100
|
"root": true,
|
|
101
|
-
"extends": [
|
|
101
|
+
"extends": [
|
|
102
|
+
"@sinemacula/coding-standards/js/biome.json"
|
|
103
|
+
],
|
|
102
104
|
"files": {
|
|
103
105
|
"ignoreUnknown": true,
|
|
104
|
-
"includes": [
|
|
106
|
+
"includes": [
|
|
107
|
+
"**",
|
|
108
|
+
"!**/node_modules/**",
|
|
109
|
+
"!**/vendor/**"
|
|
110
|
+
]
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
```
|
|
@@ -194,7 +200,9 @@ package_filters = [
|
|
|
194
200
|
```json
|
|
195
201
|
{
|
|
196
202
|
"$schema": "https://unpkg.com/knip@6/schema.json",
|
|
197
|
-
"extends": [
|
|
203
|
+
"extends": [
|
|
204
|
+
"@sinemacula/coding-standards/js/knip.json"
|
|
205
|
+
]
|
|
198
206
|
}
|
|
199
207
|
```
|
|
200
208
|
|
|
@@ -212,20 +220,20 @@ tag = "<version>"
|
|
|
212
220
|
|
|
213
221
|
## What's Included
|
|
214
222
|
|
|
215
|
-
| Path
|
|
216
|
-
|
|
217
|
-
| `src/PhpCsFixerConfig.php`
|
|
218
|
-
| `php/.php-cs-fixer.rules.php`
|
|
219
|
-
| `SineMacula/ruleset.xml`
|
|
220
|
-
| `php/phpstan-base.neon`
|
|
221
|
-
| `js/biome.json`
|
|
222
|
-
| `js/knip.json`
|
|
223
|
-
| `js/eslint/`
|
|
224
|
-
| `markdown/.markdownlint.json`
|
|
225
|
-
| `yaml/.yamllint.yaml`
|
|
226
|
-
| `shell/.shellcheckrc`
|
|
227
|
-
| `security/.gitleaks.toml`
|
|
228
|
-
| `editorconfig/.editorconfig-checker.json` | editorconfig-checker | Disables only the max-line-length check
|
|
223
|
+
| Path | Tool | Description |
|
|
224
|
+
|-------------------------------------------|----------------------|--------------------------------------------------------|
|
|
225
|
+
| `src/PhpCsFixerConfig.php` | PHP CS Fixer | Factory class for building PHP CS Fixer configurations |
|
|
226
|
+
| `php/.php-cs-fixer.rules.php` | PHP CS Fixer | Shared rules array (PSR-12 base + org conventions) |
|
|
227
|
+
| `SineMacula/ruleset.xml` | PHPCS | Auto-discovered coding standard (PSR-12 + exclusions) |
|
|
228
|
+
| `php/phpstan-base.neon` | PHPStan | Base config (org-wide ignored errors + settings) |
|
|
229
|
+
| `js/biome.json` | Biome | JavaScript / TypeScript formatter + linter rules |
|
|
230
|
+
| `js/knip.json` | Knip | Unused-export detection rules |
|
|
231
|
+
| `js/eslint/` | ESLint | Structural, type-aware + Vue rules; runs with Biome |
|
|
232
|
+
| `markdown/.markdownlint.json` | markdownlint | Markdown linting rules |
|
|
233
|
+
| `yaml/.yamllint.yaml` | yamllint | YAML linting rules |
|
|
234
|
+
| `shell/.shellcheckrc` | ShellCheck | Shell script linting rules |
|
|
235
|
+
| `security/.gitleaks.toml` | Gitleaks | Secret-detection ruleset |
|
|
236
|
+
| `editorconfig/.editorconfig-checker.json` | editorconfig-checker | Disables only the max-line-length check |
|
|
229
237
|
|
|
230
238
|
## Rules
|
|
231
239
|
|
|
@@ -235,38 +243,38 @@ native directive - `// phpcs:ignore <code>` for a sniff, `@phpstan-ignore <ident
|
|
|
235
243
|
|
|
236
244
|
### PHPCS sniffs
|
|
237
245
|
|
|
238
|
-
| Sniff
|
|
239
|
-
|
|
240
|
-
| `SineMacula.Attributes.DisallowToolingAttribute`
|
|
241
|
-
| `SineMacula.Classes.RequireFinalClass`
|
|
242
|
-
| `SineMacula.Classes.RequireReadonlyPublicProperty`
|
|
243
|
-
| `SineMacula.Commenting.CommentLineLength`
|
|
244
|
-
| `SineMacula.Commenting.ConsistentEnumCaseComments`
|
|
245
|
-
| `SineMacula.Commenting.MultilineMethodComment`
|
|
246
|
-
| `SineMacula.Commenting.RequireConstantComment`
|
|
247
|
-
| `SineMacula.Commenting.RequireCopyrightTag`
|
|
248
|
-
| `SineMacula.Commenting.RequireNonPromotedParameterComment` | Plain params mixed with promoted ones need a comment.
|
|
249
|
-
| `SineMacula.Commenting.RequirePromotedPropertyComment`
|
|
250
|
-
| `SineMacula.Commenting.SingleLineMemberComment`
|
|
251
|
-
| `SineMacula.Exceptions.DisallowBaseException`
|
|
252
|
-
| `SineMacula.Exceptions.RequireEmptyCatchComment`
|
|
253
|
-
| `SineMacula.Functions.RequireSensitiveParameter`
|
|
254
|
-
| `SineMacula.Metrics.MaxMethodCount`
|
|
255
|
-
| `SineMacula.Metrics.MethodLength`
|
|
256
|
-
| `SineMacula.Namespaces.RequireConcernsNamespace`
|
|
257
|
-
| `SineMacula.Namespaces.RequireContractsNamespace`
|
|
258
|
-
| `SineMacula.Namespaces.RequireEnumsNamespace`
|
|
259
|
-
| `SineMacula.NamingConventions.BooleanMethodName`
|
|
260
|
-
| `SineMacula.NamingConventions.DisallowInterfacePrefix`
|
|
261
|
-
| `SineMacula.NamingConventions.ValidEnumCaseName`
|
|
262
|
-
| `SineMacula.NamingConventions.ValidGlobalFunctionName`
|
|
263
|
-
| `SineMacula.TypeHints.RequireConstantType`
|
|
264
|
-
| `SineMacula.WhiteSpace.PromotedConstructorSpacing`
|
|
246
|
+
| Sniff | Enforces |
|
|
247
|
+
|------------------------------------------------------------|-----------------------------------------------------------------------------|
|
|
248
|
+
| `SineMacula.Attributes.DisallowToolingAttribute` | No IDE/tooling attributes (e.g. `JetBrains\PhpStorm`). |
|
|
249
|
+
| `SineMacula.Classes.RequireFinalClass` | Concrete classes must be `final` or `abstract` (`@inheritable` opts out). |
|
|
250
|
+
| `SineMacula.Classes.RequireReadonlyPublicProperty` | Public properties (declared or promoted) must be `readonly`. |
|
|
251
|
+
| `SineMacula.Commenting.CommentLineLength` | Standalone comment lines must not exceed 80 chars (FQCN/URL exempt). |
|
|
252
|
+
| `SineMacula.Commenting.ConsistentEnumCaseComments` | Enum case docs are all-or-nothing within an enum. |
|
|
253
|
+
| `SineMacula.Commenting.MultilineMethodComment` | A method's doc comment must span multiple lines. |
|
|
254
|
+
| `SineMacula.Commenting.RequireConstantComment` | Every class/interface/enum/trait constant needs a doc comment. |
|
|
255
|
+
| `SineMacula.Commenting.RequireCopyrightTag` | Class/interface/enum/trait docblocks must carry an `@copyright` tag. |
|
|
256
|
+
| `SineMacula.Commenting.RequireNonPromotedParameterComment` | Plain params mixed with promoted ones need a comment. |
|
|
257
|
+
| `SineMacula.Commenting.RequirePromotedPropertyComment` | Every constructor-promoted property needs a doc comment. |
|
|
258
|
+
| `SineMacula.Commenting.SingleLineMemberComment` | A property, constant or enum-case doc comment sits on one line. |
|
|
259
|
+
| `SineMacula.Exceptions.DisallowBaseException` | No throwing the base `\Exception`; throw a domain exception. |
|
|
260
|
+
| `SineMacula.Exceptions.RequireEmptyCatchComment` | An empty catch block must comment its intentional swallow. |
|
|
261
|
+
| `SineMacula.Functions.RequireSensitiveParameter` | Secret-named params need `#[\SensitiveParameter]`. |
|
|
262
|
+
| `SineMacula.Metrics.MaxMethodCount` | A class/interface/trait/enum may declare at most 20 methods (tests exempt). |
|
|
263
|
+
| `SineMacula.Metrics.MethodLength` | A method body may have at most 50 significant lines (tests exempt). |
|
|
264
|
+
| `SineMacula.Namespaces.RequireConcernsNamespace` | Traits must live under a `Concerns` namespace segment. |
|
|
265
|
+
| `SineMacula.Namespaces.RequireContractsNamespace` | Interfaces must live under a `Contracts` namespace segment. |
|
|
266
|
+
| `SineMacula.Namespaces.RequireEnumsNamespace` | Enums must live under an `Enums` namespace segment. |
|
|
267
|
+
| `SineMacula.NamingConventions.BooleanMethodName` | `bool` methods are predicates; command verbs/@imperative exempt. |
|
|
268
|
+
| `SineMacula.NamingConventions.DisallowInterfacePrefix` | Interface names must not use the Hungarian `I` prefix. |
|
|
269
|
+
| `SineMacula.NamingConventions.ValidEnumCaseName` | Enum cases must be `SCREAMING_SNAKE_CASE`. |
|
|
270
|
+
| `SineMacula.NamingConventions.ValidGlobalFunctionName` | Global functions must be declared in `snake_case`. |
|
|
271
|
+
| `SineMacula.TypeHints.RequireConstantType` | Class/interface/enum/trait constants must declare a native type. |
|
|
272
|
+
| `SineMacula.WhiteSpace.PromotedConstructorSpacing` | Blank line above each promoted-constructor parameter. |
|
|
265
273
|
|
|
266
274
|
### PHPStan rules
|
|
267
275
|
|
|
268
|
-
| Identifier
|
|
269
|
-
|
|
276
|
+
| Identifier | Enforces |
|
|
277
|
+
|------------------------------------|-------------------------------------------------------------------|
|
|
270
278
|
| `sineMacula.mutableStaticProperty` | Static properties written at runtime; `@managed-static` opts out. |
|
|
271
279
|
|
|
272
280
|
### ESLint rules
|
|
@@ -274,19 +282,19 @@ native directive - `// phpcs:ignore <code>` for a sniff, `@phpstan-ignore <ident
|
|
|
274
282
|
All rules run in the base layer except `boolean-method-name`, which resolves return types and so requires the opt-in
|
|
275
283
|
type-checked layer.
|
|
276
284
|
|
|
277
|
-
| Rule
|
|
278
|
-
|
|
279
|
-
| `@sinemacula/no-interface-prefix`
|
|
280
|
-
| `@sinemacula/require-readonly-public-property` | Public class properties (declared or promoted) must be `readonly`.
|
|
281
|
-
| `@sinemacula/valid-enum-member-name`
|
|
282
|
-
| `@sinemacula/boolean-method-name`
|
|
283
|
-
| `@sinemacula/no-mutable-static`
|
|
284
|
-
| `@sinemacula/max-methods-per-class`
|
|
285
|
-
| `@sinemacula/no-base-error`
|
|
286
|
-
| `@sinemacula/require-copyright`
|
|
287
|
-
| `@sinemacula/align-doc-tags`
|
|
288
|
-
| `@sinemacula/single-line-property-doc`
|
|
289
|
-
| `@sinemacula/multiline-function-doc`
|
|
285
|
+
| Rule | Enforces |
|
|
286
|
+
|------------------------------------------------|-------------------------------------------------------------------------------------|
|
|
287
|
+
| `@sinemacula/no-interface-prefix` | Interface and type-alias names must not use the Hungarian `I` prefix. |
|
|
288
|
+
| `@sinemacula/require-readonly-public-property` | Public class properties (declared or promoted) must be `readonly`. |
|
|
289
|
+
| `@sinemacula/valid-enum-member-name` | Enum members must be declared in `SCREAMING_SNAKE_CASE`. |
|
|
290
|
+
| `@sinemacula/boolean-method-name` | Boolean-returning methods need an is/has/can prefix; `@imperative` exempt. |
|
|
291
|
+
| `@sinemacula/no-mutable-static` | No mutable exported bindings or mutable `static` class fields; test code exempt. |
|
|
292
|
+
| `@sinemacula/max-methods-per-class` | A single class may declare at most 20 methods; test code exempt. |
|
|
293
|
+
| `@sinemacula/no-base-error` | Throw a domain-specific `Error` subclass, never the base `Error`; test code exempt. |
|
|
294
|
+
| `@sinemacula/require-copyright` | Every file must carry a documentation comment with `@copyright` and `@author`. |
|
|
295
|
+
| `@sinemacula/align-doc-tags` | `@author` and `@copyright` values line up at a single column; autofixable. |
|
|
296
|
+
| `@sinemacula/single-line-property-doc` | A data member's documentation comment sits on one line; autofixable. |
|
|
297
|
+
| `@sinemacula/multiline-function-doc` | A method's documentation comment spans multiple lines; autofixable. |
|
|
290
298
|
|
|
291
299
|
`boolean-method-name` takes `additionalPrefixes`, `additionalPredicates` and `additionalCommandVerbs` (string arrays)
|
|
292
300
|
to widen the accepted vocabulary from a consumer config. `max-methods-per-class` takes `max`, `no-base-error` takes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinemacula/coding-standards",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "Centralized coding standards, static analysis configurations, and code quality tooling for all Sine Macula repositories.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Ben Carey <bdmc@sinemacula.co.uk>",
|