@sinemacula/coding-standards 1.4.0 → 1.5.1

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.
Files changed (2) hide show
  1. package/README.md +75 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -24,7 +24,8 @@ composer require --dev sinemacula/coding-standards
24
24
  npm install --save-dev @sinemacula/coding-standards
25
25
  ```
26
26
 
27
- The npm package ships only the static configs (`js/`, `markdown/`, `yaml/`, `shell/`, `security/`). The PHP autoloaded code lives in the Composer package.
27
+ The npm package ships only the static configs (`js/`, `markdown/`, `yaml/`, `shell/`, `security/`). The PHP autoloaded
28
+ code lives in the Composer package.
28
29
 
29
30
  ## Usage
30
31
 
@@ -83,13 +84,15 @@ parameters:
83
84
 
84
85
  #### Laravel projects
85
86
 
86
- For Laravel projects, also install [`sinemacula/coding-standards-laravel`](https://github.com/sinemacula/coding-standards-laravel)
87
- and reference its `SineMaculaLaravel` PHPCS standard (which includes this one) in place of `SineMacula`. It
88
- adds the Laravel-specific sniffs and PHPStan rules; see that package's README for setup.
87
+ For Laravel projects, also install
88
+ [`sinemacula/coding-standards-laravel`](https://github.com/sinemacula/coding-standards-laravel) and reference its
89
+ `SineMaculaLaravel` PHPCS standard (which includes this one) in place of `SineMacula`. It adds the
90
+ Laravel-specific sniffs and PHPStan rules; see that package's README for setup.
89
91
 
90
92
  ### Biome (JavaScript / TypeScript)
91
93
 
92
- After installing the npm package, extend the shared Biome config from your project's `biome.json` (or `.qlty/configs/biome.json` when wired through Qlty):
94
+ After installing the npm package, extend the shared Biome config from your project's `biome.json` (or
95
+ `.qlty/configs/biome.json` when wired through Qlty):
93
96
 
94
97
  ```json
95
98
  {
@@ -103,7 +106,9 @@ After installing the npm package, extend the shared Biome config from your proje
103
106
  }
104
107
  ```
105
108
 
106
- `extends` paths are resolved through normal Node module lookup, so the package only needs to be installed (no path math against `node_modules/` required). Project-specific `files.includes` and `files.excludes` stay in the consumer config.
109
+ `extends` paths are resolved through normal Node module lookup, so the package only needs to be installed (no path
110
+ math against `node_modules/` required). Project-specific `files.includes` and `files.excludes` stay in the consumer
111
+ config.
107
112
 
108
113
  ### Knip (JavaScript / TypeScript)
109
114
 
@@ -116,7 +121,8 @@ After installing the npm package, extend the shared Biome config from your proje
116
121
 
117
122
  ### Qlty
118
123
 
119
- Reference this repository as a source in your project's `.qlty/qlty.toml`, pinning `tag` to the latest [release](https://github.com/sinemacula/coding-standards/releases):
124
+ Reference this repository as a source in your project's `.qlty/qlty.toml`, pinning `tag` to the latest
125
+ [release](https://github.com/sinemacula/coding-standards/releases):
120
126
 
121
127
  ```toml
122
128
  [[source]]
@@ -139,15 +145,74 @@ tag = "<version>"
139
145
  | `yaml/.yamllint.yaml` | yamllint | YAML linting rules |
140
146
  | `shell/.shellcheckrc` | ShellCheck | Shell script linting rules |
141
147
  | `security/.gitleaks.toml` | Gitleaks | Secret-detection ruleset |
142
- | `editorconfig/.editorconfig-checker.json` | editorconfig-checker | Disables only the max-line-length check (formatters own wrapping) |
148
+ | `editorconfig/.editorconfig-checker.json` | editorconfig-checker | Disables only the max-line-length check |
149
+
150
+ ## Rules
151
+
152
+ These are the custom rules this package enforces on top of PSR-12. A deliberate exception can be bypassed with the
153
+ native directive - `// phpcs:ignore <code>` for a sniff, `@phpstan-ignore <identifier>` for a rule.
154
+
155
+ ### PHPCS sniffs
156
+
157
+ | Sniff | Enforces |
158
+ |-------|----------|
159
+ | `SineMacula.Attributes.DisallowToolingAttribute` | No IDE/tooling attributes (e.g. `JetBrains\PhpStorm`). |
160
+ | `SineMacula.Classes.RequireFinalClass` | Concrete classes must be `final` or `abstract` (`@inheritable` opts out). |
161
+ | `SineMacula.Classes.RequireReadonlyPublicProperty` | Public properties (declared or promoted) must be `readonly`. |
162
+ | `SineMacula.Commenting.CommentLineLength` | Standalone comment lines must not exceed 80 chars (FQCN/URL exempt). |
163
+ | `SineMacula.Commenting.ConsistentEnumCaseComments` | Enum case docs are all-or-nothing within an enum. |
164
+ | `SineMacula.Commenting.RequireConstantComment` | Every class/interface/enum/trait constant needs a doc comment. |
165
+ | `SineMacula.Commenting.RequireCopyrightTag` | Class/interface/enum/trait docblocks must carry an `@copyright` tag. |
166
+ | `SineMacula.Commenting.RequireNonPromotedParameterComment` | Plain params mixed with promoted ones need a comment. |
167
+ | `SineMacula.Commenting.RequirePromotedPropertyComment` | Every constructor-promoted property needs a doc comment. |
168
+ | `SineMacula.Exceptions.DisallowBaseException` | No throwing the base `\Exception`; throw a domain exception. |
169
+ | `SineMacula.Functions.RequireSensitiveParameter` | Secret-named params need `#[\SensitiveParameter]`. |
170
+ | `SineMacula.Metrics.MaxMethodCount` | A class/interface/trait/enum may declare at most 20 methods. |
171
+ | `SineMacula.Metrics.MethodLength` | A method body may have at most 50 significant lines. |
172
+ | `SineMacula.Namespaces.RequireConcernsNamespace` | Traits must live under a `Concerns` namespace segment. |
173
+ | `SineMacula.Namespaces.RequireContractsNamespace` | Interfaces must live under a `Contracts` namespace segment. |
174
+ | `SineMacula.Namespaces.RequireEnumsNamespace` | Enums must live under an `Enums` namespace segment. |
175
+ | `SineMacula.NamingConventions.BooleanMethodName` | `bool`-returning methods must read as predicates. |
176
+ | `SineMacula.NamingConventions.DisallowInterfacePrefix` | Interface names must not use the Hungarian `I` prefix. |
177
+ | `SineMacula.NamingConventions.ValidEnumCaseName` | Enum cases must be `SCREAMING_SNAKE_CASE`. |
178
+ | `SineMacula.NamingConventions.ValidGlobalFunctionName` | Global functions must be declared in `snake_case`. |
179
+ | `SineMacula.TypeHints.RequireConstantType` | Class/interface/enum/trait constants must declare a native type. |
180
+
181
+ ### PHPStan rules
182
+
183
+ | Identifier | Enforces |
184
+ |------------|----------|
185
+ | `sineMacula.mutableStaticProperty` | No mutable static state; use instance state or a constant instead. |
186
+
187
+ ## Requirements
188
+
189
+ - PHP ^8.3 (Composer package)
190
+ - Node.js (npm package)
191
+
192
+ ## Testing
193
+
194
+ ```bash
195
+ composer test # PHPUnit suite for the custom sniffs and PHPStan rule
196
+ composer test:coverage # suite with Clover coverage output
197
+ composer analyse # PHPStan static analysis
198
+ composer check # static analysis and lint via qlty
199
+ composer format # format via qlty
200
+ composer smells # duplication / complexity smells via qlty
201
+ ```
202
+
203
+ ## Changelog
204
+
205
+ See [CHANGELOG.md](CHANGELOG.md) for a list of notable changes.
143
206
 
144
207
  ## Contributing
145
208
 
146
- Contributions are welcome via GitHub pull requests.
209
+ Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on branching, commits, code
210
+ quality, and pull requests.
147
211
 
148
212
  ## Security
149
213
 
150
- If you discover a security issue, please contact Sine Macula directly rather than opening a public issue.
214
+ If you discover a security vulnerability, please report it responsibly. See [SECURITY.md](SECURITY.md) for the
215
+ disclosure policy and contact details.
151
216
 
152
217
  ## License
153
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinemacula/coding-standards",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
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>",