@brnshkr/config 0.0.1-beta.2 → 0.0.1-beta.4
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 +177 -228
- package/conf/.gitignore.dist +15 -0
- package/conf/Makefile +3778 -0
- package/conf/Makefile.dist +13 -0
- package/conf/bunfig.dist.toml +5 -0
- package/conf/commitlint.dist.mjs +1 -0
- package/conf/editorconfig.dist +19 -0
- package/conf/launch.dist.json +31 -0
- package/conf/markdownlint.dist.mjs +1 -0
- package/conf/spelling/defaults.json +185 -0
- package/conf/tsconfig.dist.json +3 -0
- package/conf/tsconfig.json +31 -27
- package/conf/vitest.dist.mjs +1 -0
- package/conf/vscode-css-custom-data.dist.json +95 -0
- package/conf/vscode-extensions.dist.json +21 -0
- package/conf/vscode-settings.dist.jsonc +338 -0
- package/dist/commitlint/index.d.mts +72 -0
- package/dist/commitlint/index.mjs +239 -0
- package/dist/eslint/index.d.mts +3897 -1383
- package/dist/eslint/index.mjs +2784 -419
- package/dist/markdownlint/index.d.mts +2304 -0
- package/dist/markdownlint/index.mjs +440 -0
- package/dist/shared.mjs +405 -65
- package/dist/spelling/index.d.mts +30 -0
- package/dist/spelling/index.mjs +2 -0
- package/dist/spelling/spelling.test.d.mts +1 -0
- package/dist/spelling/spelling.test.mjs +12 -0
- package/dist/stylelint/index.d.mts +47 -9
- package/dist/stylelint/index.mjs +145 -47
- package/dist/vitest/index.d.mts +73 -0
- package/dist/vitest/index.mjs +181 -0
- package/package.json +192 -105
- package/conf/tsconfig.json.example +0 -3
- package/dist/scripts/eslint.mjs +0 -16
- package/dist/scripts/stylelint.mjs +0 -29
- /package/conf/{eslint.config.mjs.example → eslint.dist.mjs} +0 -0
- /package/conf/{stylelint.config.mjs.example → stylelint.dist.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<h1 id="top">
|
|
2
2
|
<a href="#top">
|
|
3
|
-
<img
|
|
3
|
+
<img
|
|
4
|
+
src="https://raw.githubusercontent.com/brnshkr/brand/refs/heads/master/images/projects/config.png"
|
|
5
|
+
alt="@brnshkr/config project logo"
|
|
6
|
+
title="@brnshkr/config"
|
|
7
|
+
>
|
|
4
8
|
</a>
|
|
5
9
|
|
|
6
10
|
[![Semantic Versioning 2.0.0][semver-2.0.0-shield-url]][semver-2.0.0-url]
|
|
@@ -18,23 +22,25 @@ _[☄️ Bug Reports / Feature Requests »][issues-url]_
|
|
|
18
22
|
<!-- omit in toc -->
|
|
19
23
|
## Table of Contents
|
|
20
24
|
|
|
21
|
-
<!--
|
|
25
|
+
<!--
|
|
26
|
+
NOTICE:
|
|
27
|
+
GitHub strips emojis in anchors, but multi-codepoint characters may leave invisible remnants,
|
|
28
|
+
causing anchors to differ and require URL encoding.
|
|
29
|
+
-->
|
|
22
30
|
- [👋 About the Project](#-about-the-project)
|
|
31
|
+
- [📚 Documentation](#-documentation)
|
|
23
32
|
- [☕ JS](#-js)
|
|
24
33
|
- [🧰 Prerequisites](#-prerequisites)
|
|
25
34
|
- [🚀 Installation](#-installation)
|
|
26
|
-
- [✋ Manual](#-manual)
|
|
27
35
|
- [🎨 Custom](#-custom)
|
|
28
36
|
- [👀 Usage](#-usage)
|
|
29
|
-
- [
|
|
37
|
+
- [🧩 Custom ESLint Rules](#-custom-eslint-rules)
|
|
30
38
|
- [🐘 PHP](#-php)
|
|
31
39
|
- [🧰 Prerequisites](#-prerequisites-1)
|
|
32
40
|
- [🚀 Installation](#-installation-1)
|
|
33
|
-
- [🤖 Automatic](#-automatic)
|
|
34
|
-
- [✋ Manual](#-manual-1)
|
|
35
41
|
- [🎨 Custom](#-custom-1)
|
|
36
42
|
- [👀 Usage](#-usage-1)
|
|
37
|
-
- [
|
|
43
|
+
- [🧩 Custom PHPStan Rules](#-custom-phpstan-rules)
|
|
38
44
|
- [🔨 TODOs / Roadmap](#-todos--roadmap)
|
|
39
45
|
- [❤️ Contributing](#️-contributing)
|
|
40
46
|
- [💄 Commit Style](#-commit-style)
|
|
@@ -47,10 +53,22 @@ _[☄️ Bug Reports / Feature Requests »][issues-url]_
|
|
|
47
53
|
|
|
48
54
|
## 👋 About the Project
|
|
49
55
|
|
|
50
|
-
**@brnshkr/config** is a centralized, opinionated collection of shared configuration files,
|
|
56
|
+
**@brnshkr/config** is a centralized, opinionated collection of shared configuration files,
|
|
57
|
+
tooling, and workflows for JavaScript and PHP projects.
|
|
58
|
+
It helps standardizing linting, formatting, static analysis, and development workflows across repositories
|
|
59
|
+
— reducing setup time, preventing config drift, and improving code quality and consistency.
|
|
51
60
|
|
|
52
61
|
> ❗ **Note** ❗
|
|
53
|
-
> While you're more than welcome to use this in your own projects, the configurations are tailored specifically
|
|
62
|
+
> While you're more than welcome to use this in your own projects, the configurations are tailored specifically
|
|
63
|
+
> for the [@brnshkr][@brnshkr-organization-url] ecosystem and may not be a perfect fit elsewhere.
|
|
64
|
+
|
|
65
|
+
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
66
|
+
|
|
67
|
+
## 📚 Documentation
|
|
68
|
+
|
|
69
|
+
This README covers installation and usage. The full reference — custom rules, config builders, the Composer plugin,
|
|
70
|
+
the shared [`Makefile`](https://github.com/brnshkr/config/blob/master/docs/Makefile.md), and the development setup
|
|
71
|
+
— lives in [`./docs`](https://github.com/brnshkr/config/blob/master/docs), organized by stack and tool.
|
|
54
72
|
|
|
55
73
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
56
74
|
|
|
@@ -58,7 +76,7 @@ _[☄️ Bug Reports / Feature Requests »][issues-url]_
|
|
|
58
76
|
|
|
59
77
|
### 🧰 Prerequisites
|
|
60
78
|
|
|
61
|
-
- Node.js >= v24 or Bun >= v1.
|
|
79
|
+
- Node.js >= v24.15 or Bun >= v1.4 (Older versions may work, but are untested)
|
|
62
80
|
- Any JavaScript package manager (Bun, Yarn, PNPM, NPM)
|
|
63
81
|
|
|
64
82
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
@@ -93,71 +111,75 @@ pnpm add -D -E @brnshkr/config
|
|
|
93
111
|
npm i -D -E @brnshkr/config
|
|
94
112
|
```
|
|
95
113
|
|
|
96
|
-
|
|
114
|
+
Take a look at the `peerDependencies` in the [package.json](./package.json) file
|
|
115
|
+
and install the ones you need for the modules you want to use.
|
|
116
|
+
Copy the starter `Makefile` once, and let it write the rest:
|
|
97
117
|
|
|
98
|
-
|
|
118
|
+
```sh
|
|
119
|
+
cp -v ./node_modules/@brnshkr/config/conf/Makefile.dist ./Makefile \
|
|
120
|
+
&& make startup
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`make startup` installs each stack, writes every config and `.gitignore` the project is missing, and never
|
|
124
|
+
touches a file that is already there.
|
|
99
125
|
|
|
100
126
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
101
127
|
|
|
102
|
-
####
|
|
128
|
+
#### 🎨 Custom
|
|
103
129
|
|
|
104
|
-
Take a look at the
|
|
105
|
-
You can then copy the specific configs to your project:
|
|
130
|
+
Take a look at the function signatures for exact details.
|
|
106
131
|
|
|
107
132
|
<!-- omit in toc -->
|
|
108
|
-
#####
|
|
133
|
+
##### ESLint
|
|
109
134
|
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
```
|
|
135
|
+
```js
|
|
136
|
+
// ./conf/eslint.mjs
|
|
113
137
|
|
|
114
|
-
|
|
115
|
-
##### ESLint
|
|
138
|
+
import { getConfig } from '@brnshkr/config/eslint';
|
|
116
139
|
|
|
117
|
-
|
|
118
|
-
cp -v ./node_modules/@brnshkr/config/conf/eslint.config.mjs.example ./conf/eslint.config.mjs
|
|
140
|
+
export default getConfig(/* customize */);
|
|
119
141
|
```
|
|
120
142
|
|
|
121
143
|
<!-- omit in toc -->
|
|
122
144
|
##### Stylelint
|
|
123
145
|
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
```
|
|
146
|
+
```js
|
|
147
|
+
// ./conf/stylelint.mjs
|
|
127
148
|
|
|
128
|
-
|
|
129
|
-
##### All
|
|
149
|
+
import { getConfig } from '@brnshkr/config/stylelint';
|
|
130
150
|
|
|
131
|
-
|
|
132
|
-
cp -v ./node_modules/@brnshkr/config/conf/tsconfig.json.example ./tsconfig.json \
|
|
133
|
-
&& cp -v ./node_modules/@brnshkr/config/conf/eslint.config.mjs.example ./conf/eslint.config.mjs \
|
|
134
|
-
&& cp -v ./node_modules/@brnshkr/config/conf/stylelint.config.mjs.example ./conf/stylelint.config.mjs
|
|
151
|
+
export default getConfig(/* customize */);
|
|
135
152
|
```
|
|
136
153
|
|
|
137
|
-
|
|
154
|
+
<!-- omit in toc -->
|
|
155
|
+
##### markdownlint
|
|
138
156
|
|
|
139
|
-
|
|
157
|
+
```js
|
|
158
|
+
// ./conf/markdownlint.mjs
|
|
140
159
|
|
|
141
|
-
|
|
160
|
+
import { getConfig } from '@brnshkr/config/markdownlint';
|
|
161
|
+
|
|
162
|
+
export default getConfig(/* customize */);
|
|
163
|
+
```
|
|
142
164
|
|
|
143
165
|
<!-- omit in toc -->
|
|
144
|
-
#####
|
|
166
|
+
##### commitlint
|
|
145
167
|
|
|
146
168
|
```js
|
|
147
|
-
// ./
|
|
169
|
+
// ./conf/commitlint.mjs
|
|
148
170
|
|
|
149
|
-
import { getConfig } from '@brnshkr/config/
|
|
171
|
+
import { getConfig } from '@brnshkr/config/commitlint';
|
|
150
172
|
|
|
151
173
|
export default getConfig(/* customize */);
|
|
152
174
|
```
|
|
153
175
|
|
|
154
176
|
<!-- omit in toc -->
|
|
155
|
-
#####
|
|
177
|
+
##### Vitest
|
|
156
178
|
|
|
157
179
|
```js
|
|
158
|
-
// ./
|
|
180
|
+
// ./conf/vitest.mjs
|
|
159
181
|
|
|
160
|
-
import { getConfig } from '@brnshkr/config/
|
|
182
|
+
import { getConfig } from '@brnshkr/config/vitest';
|
|
161
183
|
|
|
162
184
|
export default getConfig(/* customize */);
|
|
163
185
|
```
|
|
@@ -181,7 +203,7 @@ A few possible ways are listed below:
|
|
|
181
203
|
Example call, adjust as needed
|
|
182
204
|
|
|
183
205
|
```sh
|
|
184
|
-
bun eslint --config ./conf/eslint.
|
|
206
|
+
bun eslint --config ./conf/eslint.mjs --cache --cache-location ./.cache/eslint.cache.json --max-warnings 0
|
|
185
207
|
```
|
|
186
208
|
|
|
187
209
|
<!-- omit in toc -->
|
|
@@ -190,70 +212,95 @@ bun eslint --config ./conf/eslint.config.mjs --cache --cache-location ./.cache/e
|
|
|
190
212
|
Example call, adjust as needed
|
|
191
213
|
|
|
192
214
|
```sh
|
|
193
|
-
bun stylelint --config ./conf/stylelint.
|
|
215
|
+
bun stylelint --config ./conf/stylelint.mjs --config-basedir ./ --cache --cache-location ./.cache/stylelint.cache.json --max-warnings 0 "**/*.{css,ejs,html,less,postcss,scss,svelte,svg,vue}"
|
|
194
216
|
```
|
|
195
217
|
|
|
196
218
|
<!-- omit in toc -->
|
|
197
|
-
|
|
219
|
+
###### markdownlint
|
|
198
220
|
|
|
199
|
-
|
|
221
|
+
Example call, adjust as needed
|
|
222
|
+
|
|
223
|
+
```sh
|
|
224
|
+
bun markdownlint-cli2 --config ./conf/markdownlint.mjs "**/*.md"
|
|
225
|
+
```
|
|
200
226
|
|
|
201
227
|
<!-- omit in toc -->
|
|
202
|
-
######
|
|
228
|
+
###### commitlint
|
|
203
229
|
|
|
204
|
-
|
|
230
|
+
Example call, adjust as needed
|
|
205
231
|
|
|
206
232
|
```sh
|
|
207
|
-
bun ./
|
|
233
|
+
bun commitlint --config ./conf/commitlint.mjs --edit
|
|
208
234
|
```
|
|
209
235
|
|
|
210
236
|
<!-- omit in toc -->
|
|
211
|
-
|
|
237
|
+
##### Option 2 — Run Make Targets (@brnshkr Convention)
|
|
238
|
+
|
|
239
|
+
For these targets to work you need to follow the convention of putting your configuration files into the `./conf` directory
|
|
240
|
+
(Exactly how it is done in this project as well; see [`./conf`](https://github.com/brnshkr/config/blob/master/conf)).
|
|
212
241
|
|
|
213
|
-
|
|
242
|
+
Your own Makefile includes this one. Copy the starter rather than writing the include by hand: it guards the
|
|
243
|
+
include, so a fresh clone can `make bootstrap` before anything is installed.
|
|
214
244
|
|
|
215
245
|
```sh
|
|
216
|
-
|
|
246
|
+
cp -v ./node_modules/@brnshkr/config/conf/Makefile.dist ./Makefile
|
|
217
247
|
```
|
|
218
248
|
|
|
249
|
+
A target appears once the tool it runs is installed, so `make help` lists what your repository actually has,
|
|
250
|
+
`make ci` runs all of it, and `make startup` writes any config you are still missing.
|
|
251
|
+
The full reference is [`docs/Makefile.md`](https://github.com/brnshkr/config/blob/master/docs/Makefile.md).
|
|
252
|
+
|
|
219
253
|
<!-- omit in toc -->
|
|
220
|
-
|
|
254
|
+
###### ESLint (TypeScript Only)
|
|
221
255
|
|
|
222
|
-
|
|
223
|
-
If you need a VSCode setup and have the specific [`extensions`](https://github.com/brnshkr/config/blob/master/.vscode/extensions.json) installed you can take a look at the `Project specific` section in [`./.vscode/settings.json`](https://github.com/brnshkr/config/blob/master/.vscode/settings.json).
|
|
256
|
+
Expected configuration file: `./conf/eslint.mjs`
|
|
224
257
|
|
|
225
|
-
|
|
258
|
+
```sh
|
|
259
|
+
make eslint
|
|
260
|
+
```
|
|
226
261
|
|
|
227
|
-
|
|
262
|
+
<!-- omit in toc -->
|
|
263
|
+
###### Stylelint
|
|
264
|
+
|
|
265
|
+
Expected configuration file: `./conf/stylelint.mjs`
|
|
266
|
+
|
|
267
|
+
```sh
|
|
268
|
+
make stylelint
|
|
269
|
+
```
|
|
228
270
|
|
|
229
271
|
<!-- omit in toc -->
|
|
230
|
-
|
|
272
|
+
###### markdownlint
|
|
231
273
|
|
|
232
|
-
|
|
274
|
+
Expected configuration file: `./conf/markdownlint.mjs`
|
|
233
275
|
|
|
234
276
|
```sh
|
|
235
|
-
|
|
236
|
-
&& bun install-hooks
|
|
277
|
+
make markdownlint
|
|
237
278
|
```
|
|
238
279
|
|
|
239
280
|
<!-- omit in toc -->
|
|
240
|
-
|
|
281
|
+
###### commitlint
|
|
282
|
+
|
|
283
|
+
Expected configuration file: `./conf/commitlint.mjs`
|
|
241
284
|
|
|
242
|
-
|
|
243
|
-
|
|
285
|
+
```sh
|
|
286
|
+
make commitlint
|
|
287
|
+
```
|
|
244
288
|
|
|
245
289
|
<!-- omit in toc -->
|
|
246
|
-
|
|
290
|
+
#### IDE Setup
|
|
291
|
+
|
|
292
|
+
When using the recommended way of putting config files into the `./conf` directory
|
|
293
|
+
it might be necessary to instruct your IDE to read these files correctly.
|
|
294
|
+
If you need a VS Code setup and have the specific [`extensions`](https://github.com/brnshkr/config/blob/master/.vscode/extensions.json)
|
|
295
|
+
installed you can take a look at the `Project specific` section in [`./.vscode/settings.json`](https://github.com/brnshkr/config/blob/master/.vscode/settings.json).
|
|
296
|
+
|
|
297
|
+
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
247
298
|
|
|
248
|
-
|
|
299
|
+
### 🧩 Custom ESLint Rules
|
|
249
300
|
|
|
250
|
-
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
- `bun run test` — Run Vitest test suite
|
|
254
|
-
- `bun test-update` — Run Vitest test suite and update snapshots
|
|
255
|
-
- `bun run build` — Build the project and generate types
|
|
256
|
-
- `bun watch` — Build the project in watch mode
|
|
301
|
+
The default ESLint configuration ships a small `brnshkr` plugin that contributes a handful
|
|
302
|
+
of project-specific rules, all enabled out of the box. Each rule is documented with examples
|
|
303
|
+
in the [Custom ESLint Rules docs](https://github.com/brnshkr/config/blob/master/docs/js/eslint/rules/index.md).
|
|
257
304
|
|
|
258
305
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
259
306
|
|
|
@@ -275,108 +322,25 @@ Here are some frequently used examples:
|
|
|
275
322
|
#### Composer
|
|
276
323
|
|
|
277
324
|
```sh
|
|
278
|
-
composer
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
This repository provides two ways to integrate configuration files and setup tools into your project:
|
|
282
|
-
|
|
283
|
-
- [**Automatic setup**](#-automatic) via the Composer plugin
|
|
284
|
-
- [**Manual setup**](#-manual-1) by copying the example configuration files yourself
|
|
285
|
-
|
|
286
|
-
#### 🤖 Automatic
|
|
287
|
-
|
|
288
|
-
If you allow this package to run as a Composer plugin (Composer will prompt you on first install), several helper commands become available.
|
|
289
|
-
The most commonly used is the automatic setup command which installs packages for selected modules, copies example config files into your repository, and can optionally create a `Makefile` and/or a `.gitignore` file.
|
|
290
|
-
|
|
291
|
-
Run the automatic setup with defaults:
|
|
292
|
-
|
|
293
|
-
```sh
|
|
294
|
-
composer brnshkr:config:setup
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
Run the automatic setup with all flags enabled:
|
|
298
|
-
|
|
299
|
-
```sh
|
|
300
|
-
composer brnshkr:config:setup -gofacme
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
Take a look at the [plugin commands](#plugin-commands) section to see a full list of available commands.
|
|
304
|
-
|
|
305
|
-
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
306
|
-
|
|
307
|
-
#### ✋ Manual
|
|
308
|
-
|
|
309
|
-
Take a look at the `suggest`ed packages in the [composer.json](./composer.json) file and install the ones you need for the modules you want to use.
|
|
310
|
-
You can then copy the specific configs to your project:
|
|
311
|
-
|
|
312
|
-
<!-- omit in toc -->
|
|
313
|
-
##### PHP CS Fixer
|
|
314
|
-
|
|
315
|
-
```sh
|
|
316
|
-
cp -v ./vendor/brnshkr/config/conf/php-cs-fixer.php.example ./conf/php-cs-fixer.php \
|
|
317
|
-
&& cp -v ./vendor/brnshkr/config/conf/php-cs-fixer.php.example ./conf/php-cs-fixer.php.example \
|
|
318
|
-
&& cp -v ./vendor/brnshkr/config/conf/php-cs-fixer.dist.php.example ./conf/php-cs-fixer.dist.php
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
<!-- omit in toc -->
|
|
322
|
-
##### Rector
|
|
323
|
-
|
|
324
|
-
```sh
|
|
325
|
-
cp -v ./vendor/brnshkr/config/conf/rector.php.example ./conf/rector.php \
|
|
326
|
-
&& cp -v ./vendor/brnshkr/config/conf/rector.php.example ./conf/rector.php.example \
|
|
327
|
-
&& cp -v ./vendor/brnshkr/config/conf/rector.dist.php.example ./conf/rector.dist.php
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
<!-- omit in toc -->
|
|
331
|
-
##### PHPStan
|
|
332
|
-
|
|
333
|
-
```sh
|
|
334
|
-
cp -v ./vendor/brnshkr/config/conf/phpstan.php.example ./conf/phpstan.php \
|
|
335
|
-
&& cp -v ./vendor/brnshkr/config/conf/phpstan.php.example ./conf/phpstan.php.example \
|
|
336
|
-
&& cp -v ./vendor/brnshkr/config/conf/phpstan.dist.php.example ./conf/phpstan.dist.php
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
<!-- omit in toc -->
|
|
340
|
-
##### Twig CS Fixer
|
|
341
|
-
|
|
342
|
-
```sh
|
|
343
|
-
cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.php.example ./conf/twig-cs-fixer.php \
|
|
344
|
-
&& cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.php.example ./conf/twig-cs-fixer.php.example \
|
|
345
|
-
&& cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.dist.php.example ./conf/twig-cs-fixer.dist.php
|
|
325
|
+
composer r --dev brnshkr/config
|
|
346
326
|
```
|
|
347
327
|
|
|
348
|
-
|
|
349
|
-
|
|
328
|
+
Take a look at the `suggest`ed packages in the [composer.json](./composer.json) file and install the ones
|
|
329
|
+
you need for the modules you want to use.
|
|
330
|
+
Copy the starter `Makefile` once, and let it write the rest:
|
|
350
331
|
|
|
351
332
|
```sh
|
|
352
|
-
cp -v ./vendor/brnshkr/config/conf/Makefile.
|
|
333
|
+
cp -v ./vendor/brnshkr/config/conf/Makefile.dist ./Makefile \
|
|
334
|
+
&& make startup
|
|
353
335
|
```
|
|
354
336
|
|
|
355
|
-
|
|
356
|
-
|
|
337
|
+
`make startup` installs each stack, writes every config and `.gitignore` the project is missing, and never
|
|
338
|
+
touches a file that is already there.
|
|
357
339
|
|
|
358
|
-
|
|
359
|
-
cp -v ./vendor/brnshkr/config/conf/.gitignore.example ./.gitignore
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
<!-- omit in toc -->
|
|
363
|
-
##### All
|
|
340
|
+
To have the packages installed for you, pick the modules interactively:
|
|
364
341
|
|
|
365
342
|
```sh
|
|
366
|
-
|
|
367
|
-
&& cp -v ./vendor/brnshkr/config/conf/php-cs-fixer.php.example ./conf/php-cs-fixer.php.example \
|
|
368
|
-
&& cp -v ./vendor/brnshkr/config/conf/php-cs-fixer.dist.php.example ./conf/php-cs-fixer.dist.php \
|
|
369
|
-
&& cp -v ./vendor/brnshkr/config/conf/rector.php.example ./conf/rector.php \
|
|
370
|
-
&& cp -v ./vendor/brnshkr/config/conf/rector.php.example ./conf/rector.php.example \
|
|
371
|
-
&& cp -v ./vendor/brnshkr/config/conf/rector.dist.php.example ./conf/rector.dist.php \
|
|
372
|
-
&& cp -v ./vendor/brnshkr/config/conf/phpstan.php.example ./conf/phpstan.php \
|
|
373
|
-
&& cp -v ./vendor/brnshkr/config/conf/phpstan.php.example ./conf/phpstan.php.example \
|
|
374
|
-
&& cp -v ./vendor/brnshkr/config/conf/phpstan.dist.php.example ./conf/phpstan.dist.php \
|
|
375
|
-
&& cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.php.example ./conf/twig-cs-fixer.php \
|
|
376
|
-
&& cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.php.example ./conf/twig-cs-fixer.php.example \
|
|
377
|
-
&& cp -v ./vendor/brnshkr/config/conf/twig-cs-fixer.dist.php.example ./conf/twig-cs-fixer.dist.php \
|
|
378
|
-
&& cp -v ./vendor/brnshkr/config/conf/Makefile.example ./Makefile \
|
|
379
|
-
&& cp -v ./vendor/brnshkr/config/conf/.gitignore.example ./.gitignore
|
|
343
|
+
composer brnshkr:config:setup
|
|
380
344
|
```
|
|
381
345
|
|
|
382
346
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
@@ -389,9 +353,8 @@ Take a look at the function signatures for exact details.
|
|
|
389
353
|
##### PHP CS Fixer
|
|
390
354
|
|
|
391
355
|
```php
|
|
392
|
-
// ./php-cs-fixer.dist.php
|
|
393
|
-
|
|
394
356
|
<?php
|
|
357
|
+
// ./conf/php-cs-fixer.dist.php
|
|
395
358
|
|
|
396
359
|
declare(strict_types=1);
|
|
397
360
|
|
|
@@ -404,9 +367,8 @@ return PhpCsFixer::getConfig(/* customize */);
|
|
|
404
367
|
##### Rector
|
|
405
368
|
|
|
406
369
|
```php
|
|
407
|
-
// ./rector.dist.php
|
|
408
|
-
|
|
409
370
|
<?php
|
|
371
|
+
// ./conf/rector.dist.php
|
|
410
372
|
|
|
411
373
|
declare(strict_types=1);
|
|
412
374
|
|
|
@@ -419,9 +381,8 @@ return Rector::getConfig(/* customize */);
|
|
|
419
381
|
##### PHPStan
|
|
420
382
|
|
|
421
383
|
```php
|
|
422
|
-
// ./phpstan.dist.php
|
|
423
|
-
|
|
424
384
|
<?php
|
|
385
|
+
// ./conf/phpstan.dist.php
|
|
425
386
|
|
|
426
387
|
declare(strict_types=1);
|
|
427
388
|
|
|
@@ -434,9 +395,8 @@ return PhpStan::getConfig(/* customize */);
|
|
|
434
395
|
##### Twig CS Fixer
|
|
435
396
|
|
|
436
397
|
```php
|
|
437
|
-
// ./twig-cs-fixer.dist.php
|
|
438
|
-
|
|
439
398
|
<?php
|
|
399
|
+
// ./conf/twig-cs-fixer.dist.php
|
|
440
400
|
|
|
441
401
|
declare(strict_types=1);
|
|
442
402
|
|
|
@@ -495,16 +455,22 @@ php ./vendor/bin/twig-cs-fixer fix --config ./conf/twig-cs-fixer.php -v
|
|
|
495
455
|
```
|
|
496
456
|
|
|
497
457
|
<!-- omit in toc -->
|
|
498
|
-
##### Option 2 — Run
|
|
458
|
+
##### Option 2 — Run Make Targets (@brnshkr Convention)
|
|
499
459
|
|
|
500
|
-
For these
|
|
460
|
+
For these targets to work you need to follow the convention of putting your configuration files into the `./conf` directory
|
|
461
|
+
(Exactly how it is done in this project as well; see [`./conf`](https://github.com/brnshkr/config/blob/master/conf)).
|
|
501
462
|
|
|
502
|
-
|
|
463
|
+
Your own Makefile includes this one. Copy the shipped starter rather than writing the include by hand:
|
|
464
|
+
it guards the include, so a fresh clone can `make bootstrap` before anything is installed.
|
|
503
465
|
|
|
504
|
-
```
|
|
505
|
-
|
|
466
|
+
```sh
|
|
467
|
+
cp -v ./vendor/brnshkr/config/conf/Makefile.dist ./Makefile
|
|
506
468
|
```
|
|
507
469
|
|
|
470
|
+
A target appears once the tool it runs is installed, so `make help` lists what your repository actually has,
|
|
471
|
+
`make ci` runs all of it, and `make startup` writes any config you are still missing.
|
|
472
|
+
The full reference is [`docs/Makefile.md`](https://github.com/brnshkr/config/blob/master/docs/Makefile.md).
|
|
473
|
+
|
|
508
474
|
<!-- omit in toc -->
|
|
509
475
|
###### PHP CS Fixer
|
|
510
476
|
|
|
@@ -544,8 +510,10 @@ make twig-cs-fixer
|
|
|
544
510
|
<!-- omit in toc -->
|
|
545
511
|
#### IDE Setup
|
|
546
512
|
|
|
547
|
-
When using the recommended way of putting config files into the `./conf` directory
|
|
548
|
-
|
|
513
|
+
When using the recommended way of putting config files into the `./conf` directory
|
|
514
|
+
it might be necessary to instruct your IDE to read these files correctly.
|
|
515
|
+
If you need a VS Code setup and have the specific [`extensions`](https://github.com/brnshkr/config/blob/master/.vscode/extensions.json)
|
|
516
|
+
installed you can take a look at the `Project specific` section in [`./.vscode/settings.json`](https://github.com/brnshkr/config/blob/master/.vscode/settings.json).
|
|
549
517
|
|
|
550
518
|
<!-- omit in toc -->
|
|
551
519
|
#### Plugin Commands
|
|
@@ -556,55 +524,24 @@ For full usage run `composer help <command>`, `composer <command> --help` or `co
|
|
|
556
524
|
| Command | Alias | Description |
|
|
557
525
|
| --- | --- | --- |
|
|
558
526
|
| `brnshkr:config` | `b:c` | Displays the plugin overview and a list of available commands. Useful to quickly discover what the plugin exposes. |
|
|
559
|
-
| `brnshkr:config:setup [<modules>...]` | `b:c:s` | Interactive setup helper: installs suggested packages for modules, copies example config files, and can create a `Makefile` and/or a `.gitignore` file. |
|
|
560
527
|
| `brnshkr:config:update-php-extensions` | `b:c:upe` | Scans installed packages and updates `composer.json` with required `ext-*` platform packages. |
|
|
561
528
|
| `brnshkr:config:extract-phar <package>` | `b:c:ep` | Extracts a `.phar` file from a given vendor package. |
|
|
562
529
|
|
|
563
530
|
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
564
531
|
|
|
565
|
-
###
|
|
532
|
+
### 🧩 Custom PHPStan Rules
|
|
566
533
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
```sh
|
|
573
|
-
composer install \
|
|
574
|
-
&& cp -v ./conf/php-cs-fixer.php.example ./conf/php-cs-fixer.php \
|
|
575
|
-
&& cp -v ./conf/rector.php.example ./conf/rector.php \
|
|
576
|
-
&& cp -v ./conf/phpstan.php.example ./conf/phpstan.php \
|
|
577
|
-
&& cp -v ./conf/twig-cs-fixer.php.example ./conf/twig-cs-fixer.php
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
<!-- omit in toc -->
|
|
581
|
-
#### Make
|
|
582
|
-
|
|
583
|
-
We recommend using [GNU Make][make-url] as the primary task runner.
|
|
584
|
-
See [the Makefile](./conf/Makefile) for a full list of available targets.
|
|
585
|
-
You can also run `make help` or simply `make` to view all targets with brief descriptions.
|
|
586
|
-
|
|
587
|
-
If you need local overrides, create a `./.local/Makefile` — the main Makefile automatically includes it if present.
|
|
534
|
+
Beyond the upstream rule set, the default configuration ships a number of custom PHPStan rules in two flavors.
|
|
535
|
+
**Standalone rules** are general-purpose checks enabled out of the box,
|
|
536
|
+
while **architecture presets** are opinionated bundles of class-placement and isolation rules tailored to a
|
|
537
|
+
specific framework or architecture style — opt-in and configured through `setArchitecture()`.
|
|
538
|
+
Both are documented with examples in the [Custom PHPStan Rules docs](https://github.com/brnshkr/config/blob/master/docs/php/phpstan/rules/index.md).
|
|
588
539
|
|
|
589
|
-
|
|
590
|
-
##### Common targets
|
|
591
|
-
|
|
592
|
-
Here are some frequently used examples (see `make help` for the complete list):
|
|
593
|
-
|
|
594
|
-
- `make help` — Show available targets and usage
|
|
595
|
-
- `make rector` — Run Rector to apply automated PHP refactorings
|
|
596
|
-
- `make php-cs-fixer` — Run PHP-CS-Fixer to format and fix coding-style issues
|
|
597
|
-
- `make phpstan` — Run PHPStan static analysis
|
|
598
|
-
- `make test` — Run PHPUnit test suite
|
|
599
|
-
- `make test-update` — Run PHPUnit test suite and update snapshots
|
|
600
|
-
- `make check` — Run Rector, PHP-CS-Fixer, Twig-CS-Fixer, PHPStan and PHPUnit
|
|
540
|
+
<p align="right"><a href="#top" title="Back to top"> ⬆ </a></p>
|
|
601
541
|
|
|
602
542
|
## 🔨 TODOs / Roadmap
|
|
603
543
|
|
|
604
|
-
-
|
|
605
|
-
- Expand [`⚙️ Worflows`](#️-workflows) section in readme
|
|
606
|
-
- Write sections about custom PHPStan and ESLint rules
|
|
607
|
-
- Add all around support for enforcing TypeScript aliases with ESLint
|
|
544
|
+
- Expand [`⚙️ Workflows`](#️-workflows) section in readme
|
|
608
545
|
- Add Vue support
|
|
609
546
|
- Add React support
|
|
610
547
|
- Add Tailwind support via <https://github.com/schoero/eslint-plugin-better-tailwindcss>
|
|
@@ -616,9 +553,11 @@ Any help is always greatly appreciated 🙂
|
|
|
616
553
|
|
|
617
554
|
## ❤️ Contributing
|
|
618
555
|
|
|
619
|
-
Contributions are what make the open source community such an amazing place to learn, inspire, and create.
|
|
556
|
+
Contributions are what make the open source community such an amazing place to learn, inspire, and create.
|
|
557
|
+
Any contributions you make are **greatly appreciated**.
|
|
620
558
|
|
|
621
|
-
If you have a suggestion that would make this better, please fork the repo and create a pull request.
|
|
559
|
+
If you have a suggestion that would make this better, please fork the repo and create a pull request.
|
|
560
|
+
You can also simply open an issue with the tag "enhancement".
|
|
622
561
|
Don't forget to give the project a star! Thanks again!
|
|
623
562
|
|
|
624
563
|
1. Fork the project
|
|
@@ -627,13 +566,17 @@ Don't forget to give the project a star! Thanks again!
|
|
|
627
566
|
4. Push to the branch => `git push origin feature/my-new-feature`
|
|
628
567
|
5. Open a pull request
|
|
629
568
|
|
|
569
|
+
New to the codebase?
|
|
570
|
+
The [Development docs](https://github.com/brnshkr/config/blob/master/docs/development.md)
|
|
571
|
+
cover environment setup and the day-to-day commands for both stacks.
|
|
572
|
+
|
|
630
573
|
### 💄 Commit Style
|
|
631
574
|
|
|
632
575
|
This project mostly follows the [Conventional Commits](https://www.conventionalcommits.org) specification.
|
|
633
576
|
There are only a few differences. The main one is that the scope is required:
|
|
634
577
|
So **instead of** this commit message signature: `<type>[optional scope]: <description>`
|
|
635
578
|
You **should use** this one: `<type><scope>: <description>`
|
|
636
|
-
Further details can be found in the [
|
|
579
|
+
Further details can be found in the [commitlint configuration](https://github.com/brnshkr/config/blob/master/conf/commitlint.mjs).
|
|
637
580
|
|
|
638
581
|
### ⚙️ Workflows
|
|
639
582
|
|
|
@@ -644,8 +587,15 @@ See [./.github/workflows](https://github.com/brnshkr/config/blob/master/.github/
|
|
|
644
587
|
## 🔖 Versioning
|
|
645
588
|
|
|
646
589
|
This project follows [Semantic Versioning 2.0.0][semver-2.0.0-url].
|
|
647
|
-
The NPM and Composer packages are versioned in sync,
|
|
648
|
-
|
|
590
|
+
The NPM and Composer packages are versioned in sync,
|
|
591
|
+
so a version change does not necessarily indicate a change in a specific package.
|
|
592
|
+
|
|
593
|
+
> ❗ **Note** ❗
|
|
594
|
+
> Since changes to rules and dependencies are not considered breaking,
|
|
595
|
+
> even a patch release may introduce new errors in code that hasn't changed and break your CI without notice.
|
|
596
|
+
> We therefore strongly recommend pinning to an exact version
|
|
597
|
+
> (`-E` for the JS package managers, `composer r --dev brnshkr/config:X.Y.Z` for Composer)
|
|
598
|
+
> so updates stay opt-in and can be applied on your own schedule.
|
|
649
599
|
|
|
650
600
|
<!-- omit in toc -->
|
|
651
601
|
### Changes Considered as Breaking Changes
|
|
@@ -672,8 +622,9 @@ Distributed under the MIT License. See [LICENSE](./LICENSE) for more information
|
|
|
672
622
|
|
|
673
623
|
- [TypeScript](https://www.typescriptlang.org)
|
|
674
624
|
- [ESLint](https://github.com/eslint/eslint)
|
|
625
|
+
- [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2)
|
|
675
626
|
- [Stylelint](https://github.com/stylelint/stylelint)
|
|
676
|
-
- [
|
|
627
|
+
- [commitlint](https://github.com/conventional-changelog/commitlint)
|
|
677
628
|
- [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
678
629
|
- [PHP](https://www.php.net)
|
|
679
630
|
- [PHPStan](https://github.com/phpstan/phpstan)
|
|
@@ -681,7 +632,7 @@ Distributed under the MIT License. See [LICENSE](./LICENSE) for more information
|
|
|
681
632
|
- [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
|
|
682
633
|
- [Twig-CS-Fixer](https://github.com/VincentLanglet/Twig-CS-Fixer)
|
|
683
634
|
- [GNU Make](https://www.gnu.org/software/make)
|
|
684
|
-
- [Best-README-Template](https://github.com/othneildrew/Best-README-Template)
|
|
635
|
+
- [Best-README-Template](https://github.com/othneildrew/Best-README-Template)
|
|
685
636
|
- [Choose an Open Source License](https://choosealicense.com)
|
|
686
637
|
- [Shields.io](https://shields.io)
|
|
687
638
|
- <a href="https://github.com/brnshkr">
|
|
@@ -698,8 +649,6 @@ Distributed under the MIT License. See [LICENSE](./LICENSE) for more information
|
|
|
698
649
|
|
|
699
650
|
[@brnshkr-organization-url]: https://github.com/brnshkr
|
|
700
651
|
|
|
701
|
-
[make-url]: https://www.gnu.org/software/make
|
|
702
|
-
|
|
703
652
|
[semver-2.0.0-url]: https://semver.org/#semantic-versioning-200
|
|
704
653
|
[semver-2.0.0-shield-url]: https://img.shields.io/badge/semver-2.0.0-blue?label=🔖%20semver&style=flat-square&labelColor=%237f399d&color=%23a5097e
|
|
705
654
|
|