@alessiofrittoli/package-configs 0.1.0
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 +616 -0
- package/dist/eslint/index.cjs +1 -0
- package/dist/eslint/index.d.cts +13 -0
- package/dist/eslint/index.d.mts +13 -0
- package/dist/eslint/index.mjs +1 -0
- package/dist/eslint/profiles/index.cjs +1 -0
- package/dist/eslint/profiles/index.d.cts +8 -0
- package/dist/eslint/profiles/index.d.mts +8 -0
- package/dist/eslint/profiles/index.mjs +1 -0
- package/dist/markdown/configs/base.json +6 -0
- package/dist/oxlint/index.cjs +1 -0
- package/dist/oxlint/index.d.cts +21 -0
- package/dist/oxlint/index.d.mts +21 -0
- package/dist/oxlint/index.mjs +1 -0
- package/dist/oxlint/profiles/index.cjs +1 -0
- package/dist/oxlint/profiles/index.d.cts +4 -0
- package/dist/oxlint/profiles/index.d.mts +4 -0
- package/dist/oxlint/profiles/index.mjs +1 -0
- package/dist/prettier/index.cjs +1 -0
- package/dist/prettier/index.d.cts +12 -0
- package/dist/prettier/index.d.mts +12 -0
- package/dist/prettier/index.mjs +1 -0
- package/dist/prettier/profiles/index.cjs +1 -0
- package/dist/prettier/profiles/index.d.cts +4 -0
- package/dist/prettier/profiles/index.d.mts +4 -0
- package/dist/prettier/profiles/index.mjs +1 -0
- package/dist/standard-6L5tOVhX.cjs +1 -0
- package/dist/standard-9H_vBPqI.mjs +1 -0
- package/dist/standard-BaghAlFU.cjs +1 -0
- package/dist/standard-BgmRUkms.cjs +1 -0
- package/dist/standard-CRskCPOC.mjs +1 -0
- package/dist/standard-DKXaHXIw.mjs +1 -0
- package/dist/tsconfig/configs/base.json +28 -0
- package/dist/tsconfig/configs/react-bundler.json +14 -0
- package/dist/tsconfig/index.cjs +1 -0
- package/dist/tsconfig/index.d.cts +29 -0
- package/dist/tsconfig/index.d.mts +29 -0
- package/dist/tsconfig/index.mjs +1 -0
- package/dist/tsdown/index.cjs +1 -0
- package/dist/tsdown/index.d.cts +30 -0
- package/dist/tsdown/index.d.mts +30 -0
- package/dist/tsdown/index.mjs +1 -0
- package/dist/vite/index.cjs +1 -0
- package/dist/vite/index.d.cts +21 -0
- package/dist/vite/index.d.mts +21 -0
- package/dist/vite/index.mjs +1 -0
- package/package.json +168 -0
package/README.md
ADDED
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
<h1 align="center">Package configs ⚙️</h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
Handle package configuration with ease
|
|
4
|
+
</p>
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://npmjs.org/package/@alessiofrittoli/package-configs">
|
|
7
|
+
<img src="https://img.shields.io/npm/v/@alessiofrittoli/package-configs" alt="Latest version"/>
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://coveralls.io/github/alessiofrittoli/package-configs">
|
|
10
|
+
<img src="https://coveralls.io/repos/github/alessiofrittoli/package-configs/badge.svg" alt="Test coverage"/>
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://socket.dev/npm/package/@alessiofrittoli/package-configs/overview">
|
|
13
|
+
<img src="https://socket.dev/api/badge/npm/package/@alessiofrittoli/package-configs" alt="Socket Security score"/>
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://npmjs.org/package/@alessiofrittoli/package-configs">
|
|
16
|
+
<img src="https://img.shields.io/npm/dm/@alessiofrittoli/package-configs.svg" alt="npm downloads"/>
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://bundlephobia.com/package/@alessiofrittoli/package-configs">
|
|
19
|
+
<img src="https://badgen.net/bundlephobia/dependency-count/@alessiofrittoli/package-configs" alt="Dependencies"/>
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://libraries.io/npm/%40alessiofrittoli%2Fpackage-configs">
|
|
22
|
+
<img src="https://img.shields.io/librariesio/release/npm/@alessiofrittoli/package-configs" alt="Dependencies status"/>
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://bundlephobia.com/package/@alessiofrittoli/package-configs">
|
|
27
|
+
<img src="https://badgen.net/bundlephobia/min/@alessiofrittoli/package-configs" alt="minified"/>
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://bundlephobia.com/package/@alessiofrittoli/package-configs">
|
|
30
|
+
<img src="https://badgen.net/bundlephobia/minzip/@alessiofrittoli/package-configs" alt="minizipped"/>
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://bundlephobia.com/package/@alessiofrittoli/package-configs">
|
|
33
|
+
<img src="https://badgen.net/bundlephobia/tree-shaking/@alessiofrittoli/package-configs" alt="Tree shakable"/>
|
|
34
|
+
</a>
|
|
35
|
+
</p>
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://github.com/sponsors/alessiofrittoli">
|
|
38
|
+
<img src="https://img.shields.io/static/v1?label=Fund%20this%20package&message=%E2%9D%A4&logo=GitHub&color=%23DB61A2" alt="Fund this package"/>
|
|
39
|
+
</a>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
[sponsor-badge]: https://img.shields.io/static/v1?label=Fund%20this%20package&message=%E2%9D%A4&logo=GitHub&color=%23DB61A2
|
|
43
|
+
[sponsor-url]: https://github.com/sponsors/alessiofrittoli
|
|
44
|
+
|
|
45
|
+
## Table of Content
|
|
46
|
+
|
|
47
|
+
- [Development](#development)
|
|
48
|
+
- [Local development](#local-development)
|
|
49
|
+
- [Production build](#production-build)
|
|
50
|
+
- [Unit tests](#unit-tests)
|
|
51
|
+
- [Run tests with coverage](#run-tests-with-coverage)
|
|
52
|
+
- [Contributing](#contributing)
|
|
53
|
+
- [API Reference](#api-reference)
|
|
54
|
+
- [TypeScript configurations](#typescript-configurations)
|
|
55
|
+
- [TypeScript configurations files](#typescript-configurations-files)
|
|
56
|
+
- [TypeScript utility functions](#typescript-utility-functions)
|
|
57
|
+
- [ESlint configurations](#eslint-configurations)
|
|
58
|
+
- [Oxlint configurations](#oxlint-configurations)
|
|
59
|
+
- [Prettier configurations](#prettier-configurations)
|
|
60
|
+
- [Tsdown configurations](#tsdown-configurations)
|
|
61
|
+
- [Vite configurations](#vite-configurations)
|
|
62
|
+
- [Markdownlint configurations](#markdownlint-configurations)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
Run the following to start development
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
nvm use
|
|
72
|
+
|
|
73
|
+
pnpm i
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Local development
|
|
77
|
+
|
|
78
|
+
Run the following
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
pnpm dev
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This will generate unminified output code, sourcemaps and will enable source file watcher.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Production build
|
|
89
|
+
|
|
90
|
+
Run the following to create a local production build
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
pnpm build
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This will generate minified output code without sourcemaps.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Unit tests
|
|
101
|
+
|
|
102
|
+
Run all the defined test suites by running the following:
|
|
103
|
+
|
|
104
|
+
```shell
|
|
105
|
+
# Run tests and watch file changes.
|
|
106
|
+
pnpm test:watch
|
|
107
|
+
|
|
108
|
+
# Run tests in a CI environment.
|
|
109
|
+
pnpm test:ci
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
#### Run tests with coverage
|
|
115
|
+
|
|
116
|
+
An HTTP server is then started to serve coverage files from `./coverage` folder.
|
|
117
|
+
|
|
118
|
+
⚠️ You may see a blank page the first time you run this command. Simply refresh the browser to see the updates.
|
|
119
|
+
|
|
120
|
+
```shell
|
|
121
|
+
pnpm test:coverage:serve
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Contributing
|
|
127
|
+
|
|
128
|
+
Contributions are truly welcome!
|
|
129
|
+
|
|
130
|
+
Please refer to the [Contributing Doc](./CONTRIBUTING.md) for more information on how to start contributing to this project.
|
|
131
|
+
|
|
132
|
+
Help keep this project up to date with [GitHub Sponsor][sponsor-url].
|
|
133
|
+
|
|
134
|
+
[![GitHub Sponsor][sponsor-badge]][sponsor-url]
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### Security
|
|
139
|
+
|
|
140
|
+
If you believe you have found a security vulnerability, we encourage you to **_responsibly disclose this and NOT open a public issue_**. We will investigate all legitimate reports. Email `security@alessiofrittoli.it` to disclose any security vulnerabilities.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## API Reference
|
|
145
|
+
|
|
146
|
+
### TypeScript configurations
|
|
147
|
+
|
|
148
|
+
This project exports different configurations JSON files as well as some utility functions that you might need in your projects.
|
|
149
|
+
|
|
150
|
+
#### TypeScript configurations files
|
|
151
|
+
|
|
152
|
+
<details>
|
|
153
|
+
|
|
154
|
+
<summary style="cursor:pointer">Base configuration file</summary>
|
|
155
|
+
|
|
156
|
+
This file is intended for `base` processes and it mainly contains all the required configuration for your IDE too.
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"extends": "@alessiofrittoli/package-configs/tsconfig/base.json",
|
|
161
|
+
"compilerOptions": {
|
|
162
|
+
"paths": {
|
|
163
|
+
"@/*": ["./src/*"]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
<details>
|
|
174
|
+
|
|
175
|
+
<summary style="cursor:pointer">React bundler configuration file</summary>
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"extends": "@alessiofrittoli/package-configs/tsconfig/react-bundler.json"
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
</details>
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
#### TypeScript utility functions
|
|
188
|
+
|
|
189
|
+
##### `parseTsConfig()`
|
|
190
|
+
|
|
191
|
+
Parse TypeScript configuration file.
|
|
192
|
+
|
|
193
|
+
<details>
|
|
194
|
+
|
|
195
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
196
|
+
|
|
197
|
+
| Parameter | Type | Default | Description |
|
|
198
|
+
| ----------------- | --------------------- | ------------------- | -------------------------------------------------- |
|
|
199
|
+
| `params` | `ParseTsConfigParams` | `{}` | (Optional) An object defining required parameters. |
|
|
200
|
+
| `params.filepath` | `string` | `"./tsconfig.json"` | (Optional) The TypeScript configuration file path. |
|
|
201
|
+
|
|
202
|
+
</details>
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
<details>
|
|
207
|
+
|
|
208
|
+
<summary style="cursor:pointer">Throws</summary>
|
|
209
|
+
|
|
210
|
+
Throws an `Error` if the resolved `filepath` does not exists.
|
|
211
|
+
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
<details>
|
|
217
|
+
|
|
218
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
219
|
+
|
|
220
|
+
Type: `ParsedCommandLine`
|
|
221
|
+
|
|
222
|
+
The parsed TypeScript configuration file.
|
|
223
|
+
|
|
224
|
+
</details>
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
<details>
|
|
229
|
+
|
|
230
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { parseTsConfig } from '@alessiofrittoli/package-configs/tsconfig'
|
|
234
|
+
|
|
235
|
+
const parsedTsConfig = parseTsConfig({ filepath: './tsconfig.build.json' })
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
</details>
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
##### `getTSConfigCompilerTarget()`
|
|
243
|
+
|
|
244
|
+
Get TypeScript compiler target from resolved configuration file.
|
|
245
|
+
|
|
246
|
+
<details>
|
|
247
|
+
|
|
248
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
249
|
+
|
|
250
|
+
| Parameter | Type | Default | Description |
|
|
251
|
+
| ----------------- | --------------------- | ------------------- | -------------------------------------------------- |
|
|
252
|
+
| `params` | `ParseTsConfigParams` | `{}` | (Optional) An object defining required parameters. |
|
|
253
|
+
| `params.filepath` | `string` | `"./tsconfig.json"` | (Optional) The TypeScript configuration file path. |
|
|
254
|
+
|
|
255
|
+
</details>
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
<details>
|
|
260
|
+
|
|
261
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
262
|
+
|
|
263
|
+
Type: `string | undefined`
|
|
264
|
+
|
|
265
|
+
The resolved TypeScript compiler target if any, `undefined` otherwise.
|
|
266
|
+
|
|
267
|
+
</details>
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
<details>
|
|
272
|
+
|
|
273
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { getTSConfigCompilerTarget } from '@alessiofrittoli/package-configs/tsconfig'
|
|
277
|
+
|
|
278
|
+
const compilerTarget = getTSConfigCompilerTarget({
|
|
279
|
+
filepath: './tsconfig.build.json',
|
|
280
|
+
})
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
</details>
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
### ESlint configurations
|
|
288
|
+
|
|
289
|
+
#### `eslintConfig()`
|
|
290
|
+
|
|
291
|
+
Get `ESLint` base configuration.
|
|
292
|
+
|
|
293
|
+
<details>
|
|
294
|
+
|
|
295
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
296
|
+
|
|
297
|
+
| Parameter | Type | Description |
|
|
298
|
+
| --------- | ------------------- | --------------------------------- |
|
|
299
|
+
| `configs` | `LinterConfigArray` | (Optional) Custom configurations. |
|
|
300
|
+
|
|
301
|
+
</details>
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
<details>
|
|
306
|
+
|
|
307
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
308
|
+
|
|
309
|
+
Type: `LinterConfigArray`
|
|
310
|
+
|
|
311
|
+
The ESLint configuration array.
|
|
312
|
+
|
|
313
|
+
</details>
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
<details>
|
|
318
|
+
|
|
319
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
// my-project/eslint.config.ts
|
|
323
|
+
import { eslintConfig } from "@alessiofrittoli/package-configs/eslint";
|
|
324
|
+
|
|
325
|
+
export default eslintConfig( {...}, {...} );
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
</details>
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### Oxlint configurations
|
|
333
|
+
|
|
334
|
+
#### `oxlintConfig()`
|
|
335
|
+
|
|
336
|
+
Get `Oxlint` base configuration.
|
|
337
|
+
|
|
338
|
+
<details>
|
|
339
|
+
|
|
340
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
341
|
+
|
|
342
|
+
| Parameter | Type | Description |
|
|
343
|
+
| --------- | ------------------ | --------------------------------- |
|
|
344
|
+
| `configs` | `T & OxlintConfig` | (Optional) Custom configurations. |
|
|
345
|
+
|
|
346
|
+
</details>
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
<details>
|
|
351
|
+
|
|
352
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
353
|
+
|
|
354
|
+
Type: `OxlintConfig`
|
|
355
|
+
|
|
356
|
+
The Oxlint configuration.
|
|
357
|
+
|
|
358
|
+
</details>
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
<details>
|
|
363
|
+
|
|
364
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
// my-project/oxlint.config.ts
|
|
368
|
+
import { oxlintConfig } from "@alessiofrittoli/package-configs/oxlint";
|
|
369
|
+
|
|
370
|
+
export default oxlintConfig( {...} );
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
</details>
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
### Prettier configurations
|
|
378
|
+
|
|
379
|
+
#### `prettierConfig()`
|
|
380
|
+
|
|
381
|
+
Get `Prettier` base configuration.
|
|
382
|
+
|
|
383
|
+
<details>
|
|
384
|
+
|
|
385
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
386
|
+
|
|
387
|
+
| Parameter | Type | Description |
|
|
388
|
+
| --------- | ---------------- | --------------------------------- |
|
|
389
|
+
| `configs` | `PrettierConfig` | (Optional) Custom configurations. |
|
|
390
|
+
|
|
391
|
+
</details>
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
<details>
|
|
396
|
+
|
|
397
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
398
|
+
|
|
399
|
+
Type: `PrettierConfig`
|
|
400
|
+
|
|
401
|
+
The Prettier configuration.
|
|
402
|
+
|
|
403
|
+
</details>
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
<details>
|
|
408
|
+
|
|
409
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
// my-project/prettier.config.ts
|
|
413
|
+
import { prettierConfig } from "@alessiofrittoli/package-configs/prettier";
|
|
414
|
+
|
|
415
|
+
export default prettierConfig( {...} );
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
</details>
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
### Tsdown configurations
|
|
423
|
+
|
|
424
|
+
#### `tsdownConfig()`
|
|
425
|
+
|
|
426
|
+
Get `tsdown` base configuration.
|
|
427
|
+
|
|
428
|
+
<details>
|
|
429
|
+
|
|
430
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
431
|
+
|
|
432
|
+
| Parameter | Type | Description |
|
|
433
|
+
| --------- | -------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
434
|
+
| `options` | `UserConfig\|UserConfigFn` | (Optional) An object defining custom options or a callable function that returns a custom options object. |
|
|
435
|
+
|
|
436
|
+
</details>
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
<details>
|
|
441
|
+
|
|
442
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
443
|
+
|
|
444
|
+
Type: `UserConfigFn`
|
|
445
|
+
|
|
446
|
+
A callable function executed by `tsdown` processes.
|
|
447
|
+
|
|
448
|
+
</details>
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
<details>
|
|
453
|
+
|
|
454
|
+
<summary style="cursor:pointer">Default configurations</summary>
|
|
455
|
+
|
|
456
|
+
| Property | Value |
|
|
457
|
+
| ------------------ | ------------------------ |
|
|
458
|
+
| `entry` | `["src/**\/index.ts"]` |
|
|
459
|
+
| `format` | `["cjs", "esm"]` |
|
|
460
|
+
| `dts` | `true` |
|
|
461
|
+
| `shims` | `true` |
|
|
462
|
+
| `clean` | `true` |
|
|
463
|
+
| `treeshake` | `true` |
|
|
464
|
+
| `minify` | `!watch` |
|
|
465
|
+
| `sourcemap` | `!!watch` |
|
|
466
|
+
| `target` | resolved tsconfig target |
|
|
467
|
+
| `deps` | `{ ... }` |
|
|
468
|
+
| `deps.neverBundle` | `true` |
|
|
469
|
+
|
|
470
|
+
</details>
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
<details>
|
|
475
|
+
|
|
476
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
// my-project/tsdown.config.ts
|
|
480
|
+
|
|
481
|
+
import { tsdownConfig } from '@alessiofrittoli/package-configs/tsdown'
|
|
482
|
+
import { join, resolve } from 'path'
|
|
483
|
+
|
|
484
|
+
const tsConfigFile = 'tsconfig.build.json'
|
|
485
|
+
|
|
486
|
+
export default tsdownConfig(({ outDir = 'example-custom-directory' }) => ({
|
|
487
|
+
tsconfig: resolve(process.cwd(), tsConfigFile),
|
|
488
|
+
outDir,
|
|
489
|
+
copy: [
|
|
490
|
+
{
|
|
491
|
+
from: 'src/assets',
|
|
492
|
+
to: join(outDir, 'assets'),
|
|
493
|
+
},
|
|
494
|
+
],
|
|
495
|
+
}))
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
</details>
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### Vite configurations
|
|
503
|
+
|
|
504
|
+
#### `viteConfig()`
|
|
505
|
+
|
|
506
|
+
Get `vite` base configuration.
|
|
507
|
+
|
|
508
|
+
<details>
|
|
509
|
+
|
|
510
|
+
<summary style="cursor:pointer">Parameters</summary>
|
|
511
|
+
|
|
512
|
+
| Parameter | Type | Description |
|
|
513
|
+
| --------- | ------------ | ---------------------------------------------------------------- |
|
|
514
|
+
| `options` | `UserConfig` | (Optional) An object defining custom Vite configuration options. |
|
|
515
|
+
|
|
516
|
+
</details>
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
<details>
|
|
521
|
+
|
|
522
|
+
<summary style="cursor:pointer">Returns</summary>
|
|
523
|
+
|
|
524
|
+
Type: `UserConfigFnObject`
|
|
525
|
+
|
|
526
|
+
An object with base and custom Vite configuration options.
|
|
527
|
+
|
|
528
|
+
</details>
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
<details>
|
|
533
|
+
|
|
534
|
+
<summary style="cursor:pointer">Default configurations</summary>
|
|
535
|
+
|
|
536
|
+
| Property | Value |
|
|
537
|
+
| ----------------------- | ------------------------------------------------------------- |
|
|
538
|
+
| `resolve.tsconfigPaths` | `true` |
|
|
539
|
+
| `test.reporters` | `["tree"]\|[]` based on `VITEST_VSCODE` environment variable. |
|
|
540
|
+
| `test.coverage.exclude` | `["**/*.mock.ts", "**/__tests__/**/*.mock.ts"]` |
|
|
541
|
+
|
|
542
|
+
</details>
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
<details>
|
|
547
|
+
|
|
548
|
+
<summary style="cursor:pointer">Examples</summary>
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
// my-project/vite.config.ts
|
|
552
|
+
|
|
553
|
+
/// <reference types="vitest/config" />
|
|
554
|
+
import { viteConfig } from "@alessiofrittoli/package-configs/vite";
|
|
555
|
+
|
|
556
|
+
export default viteConfig( {...} )
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
</details>
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
### Markdownlint configurations
|
|
564
|
+
|
|
565
|
+
To help you having a better DX while writing markdown documentations this library provides you a set of base linting rules.
|
|
566
|
+
|
|
567
|
+
Simply create a `.markdownlint.json` file at the root of your project and configure it like so:
|
|
568
|
+
|
|
569
|
+
```json
|
|
570
|
+
{
|
|
571
|
+
"extends": "@alessiofrittoli/package-configs/markdown/base.json"
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
> [!WARNING]
|
|
576
|
+
>
|
|
577
|
+
> The imported `base.json` uses `https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.41.0/schema/markdownlint-config-schema.json` as schema so make sure to add the following setting in your user/project JSON settings file:
|
|
578
|
+
>
|
|
579
|
+
> ```json
|
|
580
|
+
> {
|
|
581
|
+
> "json.schemaDownload.trustedDomains": {
|
|
582
|
+
> "https://raw.githubusercontent.com/DavidAnson/markdownlint/": true
|
|
583
|
+
> }
|
|
584
|
+
> }
|
|
585
|
+
> ```
|
|
586
|
+
|
|
587
|
+
### Made with ☕
|
|
588
|
+
|
|
589
|
+
<table style='display:flex;gap:20px;'>
|
|
590
|
+
<tbody>
|
|
591
|
+
<tr>
|
|
592
|
+
<td>
|
|
593
|
+
<img alt="avatar" src='https://avatars.githubusercontent.com/u/35973186' style='width:60px;border-radius:50%;object-fit:contain;'>
|
|
594
|
+
</td>
|
|
595
|
+
<td>
|
|
596
|
+
<table style='display:flex;gap:2px;flex-direction:column;'>
|
|
597
|
+
<tbody>
|
|
598
|
+
<tr>
|
|
599
|
+
<td>
|
|
600
|
+
<a href='https://github.com/alessiofrittoli' target='_blank' rel='noopener'>Alessio Frittoli</a>
|
|
601
|
+
</td>
|
|
602
|
+
</tr>
|
|
603
|
+
<tr>
|
|
604
|
+
<td>
|
|
605
|
+
<small>
|
|
606
|
+
<a href='https://alessiofrittoli.it' target='_blank' rel='noopener'>https://alessiofrittoli.it</a> |
|
|
607
|
+
<a href='mailto:info@alessiofrittoli.it' target='_blank' rel='noopener'>info@alessiofrittoli.it</a>
|
|
608
|
+
</small>
|
|
609
|
+
</td>
|
|
610
|
+
</tr>
|
|
611
|
+
</tbody>
|
|
612
|
+
</table>
|
|
613
|
+
</td>
|
|
614
|
+
</tr>
|
|
615
|
+
</tbody>
|
|
616
|
+
</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../standard-BgmRUkms.cjs"),t=(...t)=>[...e.t,...t];exports.eslintConfig=t;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/eslint/index.d.ts
|
|
3
|
+
export type LinterConfig = Linter.Config;
|
|
4
|
+
export type LinterConfigArray = LinterConfig[];
|
|
5
|
+
/**
|
|
6
|
+
* Get `ESLint` base configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param configs (Optional) Custom configurations.
|
|
9
|
+
*
|
|
10
|
+
* @returns The ESLint configuration array.
|
|
11
|
+
*/
|
|
12
|
+
export declare const eslintConfig: (...configs: LinterConfigArray) => LinterConfigArray;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/eslint/index.d.ts
|
|
3
|
+
export type LinterConfig = Linter.Config;
|
|
4
|
+
export type LinterConfigArray = LinterConfig[];
|
|
5
|
+
/**
|
|
6
|
+
* Get `ESLint` base configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param configs (Optional) Custom configurations.
|
|
9
|
+
*
|
|
10
|
+
* @returns The ESLint configuration array.
|
|
11
|
+
*/
|
|
12
|
+
export declare const eslintConfig: (...configs: LinterConfigArray) => LinterConfigArray;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../standard-9H_vBPqI.mjs";const t=(...t)=>[...e,...t];export{t as eslintConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../standard-BgmRUkms.cjs");exports.standardProfile=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../../standard-9H_vBPqI.mjs";export{e as standardProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../standard-BaghAlFU.cjs");let t=require("oxlint");const{categories:n,rules:r,plugins:i}=e.t,a=e=>{let a=[...i||[],...e?.plugins||[]];return(0,t.defineConfig)({...e,categories:{...n,...e?.categories},plugins:a.length>0?a:void 0,rules:{...r,...e?.rules}})};exports.oxlintConfig=a;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OxlintConfig, OxlintConfig as OxlintConfig$1, defineConfig } from "oxlint";
|
|
2
|
+
//#region src/oxlint/index.d.ts
|
|
3
|
+
export type LintPlugins = OxlintConfig$1['plugins'];
|
|
4
|
+
/**
|
|
5
|
+
* Get `Oxlint` base configuration.
|
|
6
|
+
*
|
|
7
|
+
* @param configs (Optional) Custom configurations.
|
|
8
|
+
*
|
|
9
|
+
* @returns The Oxlint configuration array.
|
|
10
|
+
*
|
|
11
|
+
* [Oxlint Reference](https://oxc.rs/docs/guide/usage/linter/config.html#typescript-config)
|
|
12
|
+
*
|
|
13
|
+
* [Oxlint Rules Reference](https://oxc.rs/docs/guide/usage/linter/rules)
|
|
14
|
+
*
|
|
15
|
+
* [Oxlint Plugins Reference](https://oxc.rs/docs/guide/usage/linter/config.html#configure-plugins)
|
|
16
|
+
*
|
|
17
|
+
* [Oxlint Supported Plugins](https://oxc.rs/docs/guide/usage/linter/plugins.html#supported-plugins)
|
|
18
|
+
*/
|
|
19
|
+
export declare const oxlintConfig: <T extends OxlintConfig$1>(configs?: T & OxlintConfig$1) => ReturnType<typeof defineConfig>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export type { OxlintConfig };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OxlintConfig, OxlintConfig as OxlintConfig$1, defineConfig } from "oxlint";
|
|
2
|
+
//#region src/oxlint/index.d.ts
|
|
3
|
+
export type LintPlugins = OxlintConfig$1['plugins'];
|
|
4
|
+
/**
|
|
5
|
+
* Get `Oxlint` base configuration.
|
|
6
|
+
*
|
|
7
|
+
* @param configs (Optional) Custom configurations.
|
|
8
|
+
*
|
|
9
|
+
* @returns The Oxlint configuration array.
|
|
10
|
+
*
|
|
11
|
+
* [Oxlint Reference](https://oxc.rs/docs/guide/usage/linter/config.html#typescript-config)
|
|
12
|
+
*
|
|
13
|
+
* [Oxlint Rules Reference](https://oxc.rs/docs/guide/usage/linter/rules)
|
|
14
|
+
*
|
|
15
|
+
* [Oxlint Plugins Reference](https://oxc.rs/docs/guide/usage/linter/config.html#configure-plugins)
|
|
16
|
+
*
|
|
17
|
+
* [Oxlint Supported Plugins](https://oxc.rs/docs/guide/usage/linter/plugins.html#supported-plugins)
|
|
18
|
+
*/
|
|
19
|
+
export declare const oxlintConfig: <T extends OxlintConfig$1>(configs?: T & OxlintConfig$1) => ReturnType<typeof defineConfig>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export type { OxlintConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../standard-DKXaHXIw.mjs";import{defineConfig as t}from"oxlint";const{categories:n,rules:r,plugins:i}=e,a=e=>{let a=[...i||[],...e?.plugins||[]];return t({...e,categories:{...n,...e?.categories},plugins:a.length>0?a:void 0,rules:{...r,...e?.rules}})};export{a as oxlintConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../standard-BaghAlFU.cjs");exports.standardProfile=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../../standard-DKXaHXIw.mjs";export{e as standardProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../standard-6L5tOVhX.cjs"),t=t=>({...e.t,...t});exports.prettierConfig=t;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config, Config as PrettierConfig } from "prettier";
|
|
2
|
+
//#region src/prettier/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get `Prettier` base configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param configs (Optional) Custom configurations.
|
|
7
|
+
*
|
|
8
|
+
* @returns The Prettier configuration array.
|
|
9
|
+
*/
|
|
10
|
+
export declare const prettierConfig: (configs?: Config) => Config;
|
|
11
|
+
//#endregion
|
|
12
|
+
export type { PrettierConfig };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config, Config as PrettierConfig } from "prettier";
|
|
2
|
+
//#region src/prettier/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get `Prettier` base configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param configs (Optional) Custom configurations.
|
|
7
|
+
*
|
|
8
|
+
* @returns The Prettier configuration array.
|
|
9
|
+
*/
|
|
10
|
+
export declare const prettierConfig: (configs?: Config) => Config;
|
|
11
|
+
//#endregion
|
|
12
|
+
export type { PrettierConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../standard-CRskCPOC.mjs";const t=t=>({...e,...t});export{t as prettierConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../standard-6L5tOVhX.cjs");exports.standardProfile=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../../standard-CRskCPOC.mjs";export{e as standardProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={useTabs:!0,tabWidth:4,endOfLine:`lf`,printWidth:110,semi:!1,singleQuote:!0,jsxSingleQuote:!0,trailingComma:`all`,bracketSameLine:!1,arrowParens:`avoid`,bracketSpacing:!0,embeddedLanguageFormatting:`auto`,htmlWhitespaceSensitivity:`css`,proseWrap:`preserve`,quoteProps:`as-needed`,tailwindFunctions:[`clsx`],plugins:[`./node_modules/prettier-plugin-sort-imports/dist/index.js`],overrides:[{files:[`*.md`,`*.yml`,`*.yaml`],options:{useTabs:!1,tabWidth:2}}]};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"typescript-eslint";import t from"@eslint/js";import n from"globals";const r=[{languageOptions:{globals:{...n.browser,...n.node}}},t.configs.recommended,...e.configs.recommended,{ignores:[`**/dist/*`,`**/coverage/*`,`.vscode`]},{rules:{"@typescript-eslint/no-namespace":`off`,"@typescript-eslint/consistent-type-imports":`warn`}}];export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={categories:{correctness:`warn`},plugins:[`eslint`,`typescript`,`unicorn`,`oxc`],rules:{"eslint/no-unused-vars":`error`,"prefer-const":[`error`,{ignoreReadBeforeAssign:!0}],"typescript/explicit-function-return-type":`error`,"typescript/consistent-type-imports":`warn`}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("typescript-eslint");c=s(c,1);let l=require("@eslint/js");l=s(l,1);let u=require("globals");u=s(u,1);const d=[{languageOptions:{globals:{...u.default.browser,...u.default.node}}},l.default.configs.recommended,...c.default.configs.recommended,{ignores:[`**/dist/*`,`**/coverage/*`,`.vscode`]},{rules:{"@typescript-eslint/no-namespace":`off`,"@typescript-eslint/consistent-type-imports":`warn`}}];Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={useTabs:!0,tabWidth:4,endOfLine:`lf`,printWidth:110,semi:!1,singleQuote:!0,jsxSingleQuote:!0,trailingComma:`all`,bracketSameLine:!1,arrowParens:`avoid`,bracketSpacing:!0,embeddedLanguageFormatting:`auto`,htmlWhitespaceSensitivity:`css`,proseWrap:`preserve`,quoteProps:`as-needed`,tailwindFunctions:[`clsx`],plugins:[`./node_modules/prettier-plugin-sort-imports/dist/index.js`],overrides:[{files:[`*.md`,`*.yml`,`*.yaml`],options:{useTabs:!1,tabWidth:2}}]};export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={categories:{correctness:`warn`},plugins:[`eslint`,`typescript`,`unicorn`,`oxc`],rules:{"eslint/no-unused-vars":`error`,"prefer-const":[`error`,{ignoreReadBeforeAssign:!0}],"typescript/explicit-function-return-type":`error`,"typescript/consistent-type-imports":`warn`}};export{e as t};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"exclude": ["*/**/dist"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "es2022",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"allowJs": false,
|
|
12
|
+
"exactOptionalPropertyTypes": false,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"noImplicitAny": true,
|
|
15
|
+
"noImplicitOverride": true,
|
|
16
|
+
"noImplicitThis": true,
|
|
17
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
18
|
+
"preserveConstEnums": true,
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"strictFunctionTypes": true,
|
|
21
|
+
"strictNullChecks": true,
|
|
22
|
+
"strictPropertyInitialization": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true,
|
|
24
|
+
"libReplacement": false,
|
|
25
|
+
"allowSyntheticDefaultImports": true,
|
|
26
|
+
"allowImportingTsExtensions": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
+
"module": "es2022",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"target": "es6",
|
|
9
|
+
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"jsx": "react-jsx",
|
|
12
|
+
"types": ["react"]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("typescript"),t=require("path"),n=require("fs");const r=(r={})=>{let{filepath:i=(0,t.resolve)(process.cwd(),`tsconfig.json`)}=r;if(!(0,n.existsSync)(i))throw Error(`No configuration file found.`,{cause:{filepath:i}});let a=(0,t.parse)(i).dir,o=(0,e.readConfigFile)(i,e.sys.readFile);return(0,e.parseJsonConfigFileContent)(o.config,e.sys,a)},i=t=>{try{let n=r(t).options.target;return n?n===e.ScriptTarget.Latest?`esnext`:e.ScriptTarget[n]?.toLowerCase():void 0}catch(e){console.error(e)}};exports.getTSConfigCompilerTarget=i,exports.parseTsConfig=r;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ParsedCommandLine } from "typescript";
|
|
2
|
+
//#region src/tsconfig/index.d.ts
|
|
3
|
+
export interface ParseTsConfigParams {
|
|
4
|
+
/**
|
|
5
|
+
* The TypeScript configuration file path.
|
|
6
|
+
*
|
|
7
|
+
* @default './tsconfig.json'
|
|
8
|
+
*/
|
|
9
|
+
filepath?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse TypeScript configuration file.
|
|
13
|
+
*
|
|
14
|
+
* @param params An object defining required parameters. See {@link ParseTsConfigParams} for more info.
|
|
15
|
+
*
|
|
16
|
+
* @returns The parsed TypeScript configuration file.
|
|
17
|
+
*
|
|
18
|
+
* @throws {Error} if the resolved `filepath` does not exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parseTsConfig: (params?: ParseTsConfigParams) => ParsedCommandLine;
|
|
21
|
+
/**
|
|
22
|
+
* Get TypeScript compiler target from resolved configuration file.
|
|
23
|
+
*
|
|
24
|
+
* @param params An object defining required parameters. See {@link ParseTsConfigParams} for more info.
|
|
25
|
+
*
|
|
26
|
+
* @returns The resolved TypeScript compiler target if any, `undefined` otherwise.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getTSConfigCompilerTarget: (params?: ParseTsConfigParams) => string | undefined;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ParsedCommandLine } from "typescript";
|
|
2
|
+
//#region src/tsconfig/index.d.ts
|
|
3
|
+
export interface ParseTsConfigParams {
|
|
4
|
+
/**
|
|
5
|
+
* The TypeScript configuration file path.
|
|
6
|
+
*
|
|
7
|
+
* @default './tsconfig.json'
|
|
8
|
+
*/
|
|
9
|
+
filepath?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse TypeScript configuration file.
|
|
13
|
+
*
|
|
14
|
+
* @param params An object defining required parameters. See {@link ParseTsConfigParams} for more info.
|
|
15
|
+
*
|
|
16
|
+
* @returns The parsed TypeScript configuration file.
|
|
17
|
+
*
|
|
18
|
+
* @throws {Error} if the resolved `filepath` does not exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parseTsConfig: (params?: ParseTsConfigParams) => ParsedCommandLine;
|
|
21
|
+
/**
|
|
22
|
+
* Get TypeScript compiler target from resolved configuration file.
|
|
23
|
+
*
|
|
24
|
+
* @param params An object defining required parameters. See {@link ParseTsConfigParams} for more info.
|
|
25
|
+
*
|
|
26
|
+
* @returns The resolved TypeScript compiler target if any, `undefined` otherwise.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getTSConfigCompilerTarget: (params?: ParseTsConfigParams) => string | undefined;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ScriptTarget as e,parseJsonConfigFileContent as t,readConfigFile as n,sys as r}from"typescript";import{parse as i,resolve as a}from"path";import{existsSync as o}from"fs";const s=(e={})=>{let{filepath:s=a(process.cwd(),`tsconfig.json`)}=e;if(!o(s))throw Error(`No configuration file found.`,{cause:{filepath:s}});let c=i(s).dir,l=n(s,r.readFile);return t(l.config,r,c)},c=t=>{try{let n=s(t).options.target;return n?n===e.Latest?`esnext`:e[n]?.toLowerCase():void 0}catch(e){console.error(e)}};export{c as getTSConfigCompilerTarget,s as parseTsConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tsconfig/index.cjs");let t=require("tsdown");const n=(n={})=>(0,t.defineConfig)(async(t,r)=>{let{target:i,watch:a=t.watch,tsconfig:o=t.tsconfig,deps:s=t.deps,...c}=typeof n==`function`?await n(t,r):n,l=i||(typeof o==`string`?e.getTSConfigCompilerTarget({filepath:o}):i);return{entry:[`src/**/index.ts`],format:[`cjs`,`esm`],dts:!0,shims:!0,clean:!0,treeshake:!0,minify:!a,sourcemap:!!a,tsconfig:o,target:l,watch:a,deps:{neverBundle:!0,...s},...c}});exports.tsdownConfig=n;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InlineConfig, UserConfig, UserConfigFn as UserConfigFn$1, UserConfigFnContext } from "tsdown";
|
|
2
|
+
//#region src/tsdown/index.d.ts
|
|
3
|
+
export type UserConfigFn = (inlineConfig: InlineConfig, context: UserConfigFnContext) => UserConfig | Promise<UserConfig>;
|
|
4
|
+
/**
|
|
5
|
+
* Get `tsdown` base configuration.
|
|
6
|
+
*
|
|
7
|
+
* @param options (Optional) An object defining custom options or a callable function that returns a custom options object. See {@link UserConfig} or {@link UserConfigFn}.
|
|
8
|
+
*
|
|
9
|
+
* @returns A callable function executed by `tsdown` processes.
|
|
10
|
+
*
|
|
11
|
+
* ---
|
|
12
|
+
*
|
|
13
|
+
* Defaults:
|
|
14
|
+
*
|
|
15
|
+
* | Property | Value |
|
|
16
|
+
* | ---------------------------- | ------------------------ |
|
|
17
|
+
* | `entry` | `['src/**\/index.ts']` |
|
|
18
|
+
* | `format` | `['cjs', 'esm']` |
|
|
19
|
+
* | `dts` | `true` |
|
|
20
|
+
* | `shims` | `true` |
|
|
21
|
+
* | `clean` | `true` |
|
|
22
|
+
* | `treeshake` | `true` |
|
|
23
|
+
* | `minify` | `!watch` |
|
|
24
|
+
* | `sourcemap` | `!!watch` |
|
|
25
|
+
* | `target` | resolved tsconfig target |
|
|
26
|
+
* | `deps` | `{ ... }` |
|
|
27
|
+
* | `deps.neverBundle` | `true` |
|
|
28
|
+
*/
|
|
29
|
+
export declare const tsdownConfig: (options?: UserConfig | UserConfigFn) => UserConfigFn$1;
|
|
30
|
+
//#endregion
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InlineConfig, UserConfig, UserConfigFn as UserConfigFn$1, UserConfigFnContext } from "tsdown";
|
|
2
|
+
//#region src/tsdown/index.d.ts
|
|
3
|
+
export type UserConfigFn = (inlineConfig: InlineConfig, context: UserConfigFnContext) => UserConfig | Promise<UserConfig>;
|
|
4
|
+
/**
|
|
5
|
+
* Get `tsdown` base configuration.
|
|
6
|
+
*
|
|
7
|
+
* @param options (Optional) An object defining custom options or a callable function that returns a custom options object. See {@link UserConfig} or {@link UserConfigFn}.
|
|
8
|
+
*
|
|
9
|
+
* @returns A callable function executed by `tsdown` processes.
|
|
10
|
+
*
|
|
11
|
+
* ---
|
|
12
|
+
*
|
|
13
|
+
* Defaults:
|
|
14
|
+
*
|
|
15
|
+
* | Property | Value |
|
|
16
|
+
* | ---------------------------- | ------------------------ |
|
|
17
|
+
* | `entry` | `['src/**\/index.ts']` |
|
|
18
|
+
* | `format` | `['cjs', 'esm']` |
|
|
19
|
+
* | `dts` | `true` |
|
|
20
|
+
* | `shims` | `true` |
|
|
21
|
+
* | `clean` | `true` |
|
|
22
|
+
* | `treeshake` | `true` |
|
|
23
|
+
* | `minify` | `!watch` |
|
|
24
|
+
* | `sourcemap` | `!!watch` |
|
|
25
|
+
* | `target` | resolved tsconfig target |
|
|
26
|
+
* | `deps` | `{ ... }` |
|
|
27
|
+
* | `deps.neverBundle` | `true` |
|
|
28
|
+
*/
|
|
29
|
+
export declare const tsdownConfig: (options?: UserConfig | UserConfigFn) => UserConfigFn$1;
|
|
30
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getTSConfigCompilerTarget as e}from"../tsconfig/index.mjs";import{defineConfig as t}from"tsdown";const n=(n={})=>t(async(t,r)=>{let{target:i,watch:a=t.watch,tsconfig:o=t.tsconfig,deps:s=t.deps,...c}=typeof n==`function`?await n(t,r):n,l=i||(typeof o==`string`?e({filepath:o}):i);return{entry:[`src/**/index.ts`],format:[`cjs`,`esm`],dts:!0,shims:!0,clean:!0,treeshake:!0,minify:!a,sourcemap:!!a,tsconfig:o,target:l,watch:a,deps:{neverBundle:!0,...s},...c}});export{n as tsdownConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vite");const t=(t={})=>{let{resolve:n,test:{coverage:r,...i}={},...a}=t;return(0,e.defineConfig)(()=>({resolve:{tsconfigPaths:!0,...n},test:{reporters:process.env.VITEST_VSCODE?[`tree`]:[],coverage:{exclude:[`**/*.mock.ts`,`**/__tests__/**/*.mock.ts`],...r},...i},...a}))};exports.viteConfig=t;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UserConfig, defineConfig } from "vite";
|
|
2
|
+
//#region src/vite/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get `vite` base configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param options (Optional) An object defining custom Vite configuration options. See {@link UserConfig} for more info.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object with base and custom Vite configuration options.
|
|
9
|
+
*
|
|
10
|
+
* ---
|
|
11
|
+
*
|
|
12
|
+
* Defaults:
|
|
13
|
+
*
|
|
14
|
+
* | Property | Value |
|
|
15
|
+
* | ----------------------- | ------------------------------------------------------------- |
|
|
16
|
+
* | `resolve.tsconfigPaths` | `true` |
|
|
17
|
+
* | `test.reporters` | `['tree']\|[]` based on `VITEST_VSCODE` environment variable. |
|
|
18
|
+
* | `test.coverage.exclude` | `['**\/*.mock.ts', '**\/__tests__/**\/*.mock.ts']` |
|
|
19
|
+
*/
|
|
20
|
+
export declare const viteConfig: (configs?: UserConfig) => ReturnType<typeof defineConfig>;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UserConfig, defineConfig } from "vite";
|
|
2
|
+
//#region src/vite/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get `vite` base configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param options (Optional) An object defining custom Vite configuration options. See {@link UserConfig} for more info.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object with base and custom Vite configuration options.
|
|
9
|
+
*
|
|
10
|
+
* ---
|
|
11
|
+
*
|
|
12
|
+
* Defaults:
|
|
13
|
+
*
|
|
14
|
+
* | Property | Value |
|
|
15
|
+
* | ----------------------- | ------------------------------------------------------------- |
|
|
16
|
+
* | `resolve.tsconfigPaths` | `true` |
|
|
17
|
+
* | `test.reporters` | `['tree']\|[]` based on `VITEST_VSCODE` environment variable. |
|
|
18
|
+
* | `test.coverage.exclude` | `['**\/*.mock.ts', '**\/__tests__/**\/*.mock.ts']` |
|
|
19
|
+
*/
|
|
20
|
+
export declare const viteConfig: (configs?: UserConfig) => ReturnType<typeof defineConfig>;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineConfig as e}from"vite";const t=(t={})=>{let{resolve:n,test:{coverage:r,...i}={},...a}=t;return e(()=>({resolve:{tsconfigPaths:!0,...n},test:{reporters:process.env.VITEST_VSCODE?[`tree`]:[],coverage:{exclude:[`**/*.mock.ts`,`**/__tests__/**/*.mock.ts`],...r},...i},...a}))};export{t as viteConfig};
|
package/package.json
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alessiofrittoli/package-configs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Utility library that offers base configurations for your packages.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Alessio Frittoli",
|
|
8
|
+
"email": "info@alessiofrittoli.it",
|
|
9
|
+
"url": "https://alessiofrittoli.it"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": [
|
|
13
|
+
{
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/alessiofrittoli"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"tsdown",
|
|
20
|
+
"eslint",
|
|
21
|
+
"vite",
|
|
22
|
+
"vitest"
|
|
23
|
+
],
|
|
24
|
+
"homepage": "https://github.com/alessiofrittoli/package-configs#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/alessiofrittoli/package-configs/issues",
|
|
27
|
+
"email": "info@alessiofrittoli.it"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/alessiofrittoli/package-configs.git"
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=24.15.0",
|
|
36
|
+
"pnpm": ">=11.27.1"
|
|
37
|
+
},
|
|
38
|
+
"main": "./dist/index.cjs",
|
|
39
|
+
"module": "./dist/index.mjs",
|
|
40
|
+
"types": "./dist/index.d.mts",
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/index.d.mts",
|
|
48
|
+
"default": "./dist/index.mjs"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/index.d.cts",
|
|
52
|
+
"default": "./dist/index.cjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"./*": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/*/index.d.mts",
|
|
58
|
+
"default": "./dist/*/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/*/index.d.cts",
|
|
62
|
+
"default": "./dist/*/index.cjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"./tsconfig/*.json": {
|
|
66
|
+
"import": "./dist/tsconfig/configs/*.json",
|
|
67
|
+
"require": "./dist/tsconfig/configs/*.json"
|
|
68
|
+
},
|
|
69
|
+
"./markdown/*.json": {
|
|
70
|
+
"import": "./dist/markdown/configs/*.json",
|
|
71
|
+
"require": "./dist/markdown/configs/*.json"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"//1a": "*********************************************************************",
|
|
76
|
+
"//1b": "******************** DEV - BUILD - LINT - RELEASE *******************",
|
|
77
|
+
"//1c": "*********************************************************************",
|
|
78
|
+
"dev": "tsdown --watch",
|
|
79
|
+
"build:prod": "pnpm tsc && pnpm tsdown",
|
|
80
|
+
"build": "pnpm lint && pnpm build:prod",
|
|
81
|
+
"eslint": "eslint -c legacy-eslint.config.ts --report-unused-disable-directives --max-warnings 0 --cache --cache-location .cache/eslint",
|
|
82
|
+
"lint": "oxlint --report-unused-disable-directives --max-warnings 0",
|
|
83
|
+
"release": "node scripts/release.ts --verbose --npm",
|
|
84
|
+
"//2a": "*********************************************************************",
|
|
85
|
+
"//2b": "***************************** UNIT TESTS ****************************",
|
|
86
|
+
"//2c": "*********************************************************************",
|
|
87
|
+
"test": "vitest --reporter=tree",
|
|
88
|
+
"test:watch": "pnpm test watch",
|
|
89
|
+
"test:ci": "pnpm test run",
|
|
90
|
+
"//3a": "*********************************************************************",
|
|
91
|
+
"//3b": "************************ UNIT TESTS COVERAGE ************************",
|
|
92
|
+
"//3c": "*********************************************************************",
|
|
93
|
+
"test:coverage": "pnpm test:watch --coverage",
|
|
94
|
+
"test:coverage:ci": "pnpm test:ci --coverage",
|
|
95
|
+
"test:serve-coverage": "http-server ./coverage --gzip true -p 0 -o /index.html --silent",
|
|
96
|
+
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
|
|
97
|
+
},
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"@eslint/js": "^10.0.1",
|
|
100
|
+
"eslint": "^10.11.0",
|
|
101
|
+
"globals": "^17.12.0",
|
|
102
|
+
"oxlint": "^1.85.0",
|
|
103
|
+
"prettier": "^3.9.9",
|
|
104
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
105
|
+
"prettier-plugin-sh": "^0.20.2",
|
|
106
|
+
"prettier-plugin-sort-imports": "^1.8.11",
|
|
107
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
108
|
+
"tsdown": "^0.23.0",
|
|
109
|
+
"typescript": "^6.0.3",
|
|
110
|
+
"typescript-eslint": "^8.70.1",
|
|
111
|
+
"vite": "^8.3.0",
|
|
112
|
+
"vitest": "^5.0.1"
|
|
113
|
+
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"@eslint/js": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"eslint": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"globals": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"oxlint": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"prettier": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"tsdown": {
|
|
131
|
+
"optional": true
|
|
132
|
+
},
|
|
133
|
+
"typescript": {
|
|
134
|
+
"optional": false
|
|
135
|
+
},
|
|
136
|
+
"typescript-eslint": {
|
|
137
|
+
"optional": true
|
|
138
|
+
},
|
|
139
|
+
"vite": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"vitest": {
|
|
143
|
+
"optional": true
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"devDependencies": {
|
|
147
|
+
"@alessiofrittoli/node-scripts": "^3.4.0",
|
|
148
|
+
"@eslint/js": "^10.0.1",
|
|
149
|
+
"@types/node": "^24.13.2",
|
|
150
|
+
"@vitest/coverage-v8": "5.0.2",
|
|
151
|
+
"concurrently": "^10.0.5",
|
|
152
|
+
"eslint": "^10.11.0",
|
|
153
|
+
"globals": "^17.12.0",
|
|
154
|
+
"http-server": "^14.1.1",
|
|
155
|
+
"jiti": "^2.7.0",
|
|
156
|
+
"oxlint": "^1.85.0",
|
|
157
|
+
"prettier": "^3.9.9",
|
|
158
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
159
|
+
"prettier-plugin-sh": "^0.20.2",
|
|
160
|
+
"prettier-plugin-sort-imports": "^1.8.11",
|
|
161
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
162
|
+
"tsdown": "^0.23.0",
|
|
163
|
+
"typescript": "6.0.3",
|
|
164
|
+
"typescript-eslint": "^8.70.1",
|
|
165
|
+
"vite": "^8.3.1",
|
|
166
|
+
"vitest": "^5.0.2"
|
|
167
|
+
}
|
|
168
|
+
}
|