Skip to content

Commit 9bef0cf

Browse files
committed
build(deps-dev): bump @flex-development/tutils from 6.0.0-alpha.10 to 6.0.0-alpha.15
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent aa7ce00 commit 9bef0cf

File tree

148 files changed

+1594
-1584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+1594
-1584
lines changed

.eslintrc.base.cjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const config = {
246246
allowedNames: ['self']
247247
}
248248
],
249-
'@typescript-eslint/no-throw-literal': 2,
249+
'@typescript-eslint/no-throw-literal': 0,
250250
'@typescript-eslint/no-type-alias': 0,
251251
'@typescript-eslint/no-unnecessary-boolean-literal-compare': [
252252
2,
@@ -661,7 +661,7 @@ const config = {
661661
terms: ['@fixme', '@todo']
662662
}
663663
],
664-
'unicorn/explicit-length-check': 2,
664+
'unicorn/explicit-length-check': 0,
665665
'unicorn/filename-case': [
666666
2,
667667
{
@@ -858,7 +858,6 @@ const config = {
858858
'promise/valid-params': 0,
859859
'unicorn/consistent-destructuring': 0,
860860
'unicorn/error-message': 0,
861-
'unicorn/explicit-length-check': 0,
862861
'unicorn/no-array-for-each': 0,
863862
'unicorn/no-hex-escape': 0,
864863
'unicorn/no-useless-undefined': 0,
@@ -997,7 +996,6 @@ const config = {
997996
'@typescript-eslint/no-misused-promises': 0,
998997
'@typescript-eslint/no-mixed-enums': 0,
999998
'@typescript-eslint/no-redundant-type-constituents': 0,
1000-
'@typescript-eslint/no-throw-literal': 0,
1001999
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 0,
10021000
'@typescript-eslint/no-unnecessary-condition': 0,
10031001
'@typescript-eslint/no-unnecessary-qualifier': 0,

__tests__/reporters/notifier.ts

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @module tests/reporters/Notifier
44
*/
55

6-
import type { OneOrMany } from '@flex-development/tutils'
6+
import { cast, isArray, type OneOrMany } from '@flex-development/tutils'
77
import notifier from 'node-notifier'
88
import type NotificationCenter from 'node-notifier/notifiers/notificationcenter'
99
import { performance } from 'node:perf_hooks'
@@ -20,22 +20,28 @@ import type { File, Reporter, Task, Test, Vitest } from 'vitest'
2020
*/
2121
class Notifier implements Reporter {
2222
/**
23+
* Test reporter context.
24+
*
2325
* @public
24-
* @member {Vitest} ctx - Test reporter context
26+
* @member {Vitest} ctx
2527
*/
26-
public ctx: Vitest = {} as Vitest
28+
public ctx!: Vitest
2729

2830
/**
31+
* Test run end time (in milliseconds).
32+
*
2933
* @public
30-
* @member {number} end - Test run end time (in milliseconds)
34+
* @member {number} end
3135
*/
32-
public end: number = 0
36+
public end!: number
3337

3438
/**
39+
* Test run start time (in milliseconds).
40+
*
3541
* @public
36-
* @member {number} start - Test run start time (in milliseconds)
42+
* @member {number} start
3743
*/
38-
public start: number = 0
44+
public start!: number
3945

4046
/**
4147
* Sends a notification.
@@ -52,19 +58,39 @@ class Notifier implements Reporter {
5258
files: File[] = this.ctx.state.getFiles(),
5359
errors: unknown[] = this.ctx.state.getUnhandledErrors()
5460
): Promise<void> {
55-
/** @const {Test[]} tests - Tests run */
61+
/**
62+
* Tests that have been run.
63+
*
64+
* @const {Test[]} tests
65+
*/
5666
const tests: Test[] = this.tests(files)
5767

58-
/** @const {number} fails - Total number of failed tests */
68+
/**
69+
* Total number of failed tests.
70+
*
71+
* @const {number} fails
72+
*/
5973
const fails: number = tests.filter(t => t.result?.state === 'fail').length
6074

61-
/** @const {number} passes - Total number of passed tests */
75+
/**
76+
* Total number of passed tests.
77+
*
78+
* @const {number} passes
79+
*/
6280
const passes: number = tests.filter(t => t.result?.state === 'pass').length
6381

64-
/** @var {string} message - Notification message */
82+
/**
83+
* Notification message.
84+
*
85+
* @var {string} message
86+
*/
6587
let message: string = ''
6688

67-
/** @var {string} title - Notification title */
89+
/**
90+
* Notification title.
91+
*
92+
* @var {string} title
93+
*/
6894
let title: string = ''
6995

7096
// get notification title and message based on number of failed tests
@@ -76,7 +102,11 @@ class Notifier implements Reporter {
76102

77103
title = '\u274C Failed'
78104
} else {
79-
/** @const {number} time - Time to run all tests (in milliseconds) */
105+
/**
106+
* Time to run all tests (in milliseconds).
107+
*
108+
* @const {number} time
109+
*/
80110
const time: number = this.end - this.start
81111

82112
message = dedent`
@@ -128,7 +158,7 @@ class Notifier implements Reporter {
128158
*/
129159
public onInit(context: Vitest): void {
130160
this.ctx = context
131-
return void (this.start = performance.now())
161+
return void ((this.start = performance.now()) && (this.end = 0))
132162
}
133163

134164
/**
@@ -140,17 +170,13 @@ class Notifier implements Reporter {
140170
* @return {Test[]} `Test` object array
141171
*/
142172
protected tests(tasks: OneOrMany<Task> = []): Test[] {
143-
const { mode } = this.ctx
144-
145-
return (Array.isArray(tasks) ? tasks : [tasks]).flatMap(task => {
146-
const { type } = task
147-
148-
return mode === 'typecheck' && type === 'suite' && task.tasks.length === 0
149-
? ([task] as unknown as [Test])
150-
: type === 'test'
173+
return (isArray<Task>(tasks) ? tasks : [tasks]).flatMap(task => {
174+
return task.type === 'custom'
175+
? [cast(task)]
176+
: task.type === 'test'
151177
? [task]
152178
: 'tasks' in task
153-
? task.tasks.flatMap(t => (t.type === 'test' ? [t] : this.tests(t)))
179+
? task.tasks.flatMap(task => this.tests(task))
154180
: []
155181
})
156182
}

build.config.ts

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,63 @@ import tsconfig from './tsconfig.build.json' assert { type: 'json' }
1717
const config: Config = defineBuildConfig({
1818
charset: 'utf8',
1919
entries: [
20-
{
21-
dts: 'only',
22-
plugins: [
23-
{
24-
name: 'ts-ignore-peers',
25-
setup({ onEnd }: PluginBuild): void {
26-
return void onEnd((result: BuildResult<{ write: false }>): void => {
27-
const { outputFiles } = result
28-
29-
/**
30-
* Regular expression used to insert `// @ts-ignore` above
31-
* property declarations.
32-
*
33-
* @const {RegExp} regex
34-
*/
35-
const regex: RegExp = /\n( +)(.+?\??: )(import\('node-fetch'\).+)/
36-
37-
/**
38-
* Property declaration with `// @ts-ignore` prepended.
39-
*
40-
* @const {string} replacement
41-
*/
42-
const replacement: string =
43-
'\n$1// @ts-ignore peer dependency\n$1$2$3'
44-
45-
return void (result.outputFiles = outputFiles.map(output => ({
46-
...output,
47-
text: output.text.replace(regex, replacement)
48-
})))
49-
})
50-
}
51-
}
52-
]
53-
},
20+
{ dts: 'only' },
5421
{
5522
dts: false,
5623
pattern: ['**/index.ts', 'enums/*', 'internal/*', 'utils/*'],
5724
sourcemap: true,
58-
sourcesContent: false
25+
sourcesContent: true
26+
}
27+
],
28+
plugins: [
29+
{
30+
name: 'ts-ignore-peers',
31+
32+
/**
33+
* Inserts `// @ts-ignore peer dependency` above property declarations
34+
* using types from peer dependencies.
35+
*
36+
* [1]: https://esbuild.github.io/plugins
37+
*
38+
* @see https://github.com/microsoft/TypeScript/issues/38628#issuecomment-1439749496
39+
*
40+
* @param {PluginBuild} build - [esbuild plugin api][1]
41+
* @param {PluginBuild['onEnd']} build.onEnd - Build end callback
42+
* @return {void} Nothing when complete
43+
*/
44+
setup({ onEnd }: PluginBuild): void {
45+
return void onEnd((result: BuildResult<{ write: false }>): void => {
46+
const { outputFiles } = result
47+
48+
/**
49+
* Regular expression used to insert `// @ts-ignore` above
50+
* property declarations.
51+
*
52+
* @see https://regex101.com/r/6r7Cke
53+
*
54+
* @const {RegExp} regex
55+
*/
56+
const regex: RegExp =
57+
/\n( +)(.+?\??: )(\w+<)?(import\('node-fetch'\).+)/g
58+
59+
/**
60+
* Property declaration with `// @ts-ignore` prepended.
61+
*
62+
* @const {string} replacement
63+
*/
64+
const replacement: string =
65+
'\n$1// @ts-ignore peer dependency\n$1$2$3$4'
66+
67+
return void (result.outputFiles = outputFiles.map(output => {
68+
return output.path.endsWith('.d.mts')
69+
? {
70+
...output,
71+
text: output.text.replace(regex, replacement)
72+
}
73+
: output
74+
}))
75+
})
76+
}
5977
}
6078
],
6179
target: [

config/changelog.config.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import {
1414
type Commit
1515
} from '@flex-development/commitlint-config'
1616
import pathe from '@flex-development/pathe'
17-
import { CompareResult, isNIL } from '@flex-development/tutils'
17+
import {
18+
CompareResult,
19+
at,
20+
includes,
21+
isNIL,
22+
select
23+
} from '@flex-development/tutils'
1824
import addStream from 'add-stream'
1925
import conventionalChangelog from 'conventional-changelog'
2026
import type { Options } from 'conventional-changelog-core'
@@ -154,7 +160,6 @@ sade('changelog', true)
154160
const changelog: Readable = conventionalChangelog<Commit>(
155161
{
156162
append: false,
157-
debug: debug ? console.debug.bind(console) : undefined,
158163
outputUnreleased:
159164
typeof outputUnreleased === 'boolean'
160165
? outputUnreleased
@@ -175,6 +180,7 @@ sade('changelog', true)
175180
{ section: ':bug: Fixes', type: Type.FIX },
176181
{ section: ':fire: Performance Improvements', type: Type.PERF },
177182
{ section: ':mechanical_arm: Refactors', type: Type.REFACTOR },
183+
{ hidden: true, type: Type.RELEASE },
178184
{ section: ':wastebasket: Reverts', type: Type.REVERT },
179185
{ hidden: true, type: Type.STYLE },
180186
{ section: ':white_check_mark: Testing', type: Type.TEST },
@@ -198,10 +204,10 @@ sade('changelog', true)
198204
return void apply(null, {
199205
...commit,
200206
committerDate: dateformat(commit.committerDate, 'yyyy-mm-dd', true),
201-
mentions: commit.mentions.filter(m => m !== 'flexdevelopment'),
207+
mentions: select(commit.mentions, m => m !== 'flexdevelopment'),
202208
// @ts-expect-error ts(2322)
203209
raw: commit,
204-
references: commit.references.filter(ref => ref.action !== null),
210+
references: select(commit.references, ref => ref.action !== null),
205211
version: commit.gitTags ? vgx.exec(commit.gitTags)?.[1] : undefined
206212
})
207213
},
@@ -296,21 +302,21 @@ sade('changelog', true)
296302
*
297303
* @const {CommitEnhanced?} first_commit
298304
*/
299-
const first_commit: CommitEnhanced | undefined = commits.at(0)
305+
const first_commit: CommitEnhanced | undefined = at(commits, 0)
300306

301307
/**
302308
* Last commit in release.
303309
*
304310
* @const {CommitEnhanced?} last_commit
305311
*/
306-
const last_commit: CommitEnhanced | undefined = commits.at(-1)
312+
const last_commit: CommitEnhanced | undefined = at(commits, -1)
307313

308314
// set current and previous tags
309315
if (key && (!currentTag || !previousTag)) {
310316
currentTag = key.version ?? undefined
311317

312318
// try setting previous tag based on current tag
313-
if (gitSemverTags.includes(currentTag ?? '')) {
319+
if (includes(gitSemverTags, currentTag)) {
314320
const { version = '' } = key
315321
previousTag = gitSemverTags[gitSemverTags.indexOf(version) + 1]
316322
if (!previousTag) previousTag = last_commit?.hash ?? undefined
@@ -324,7 +330,7 @@ sade('changelog', true)
324330
: !currentTag && version
325331
? pkg.tagPrefix + version
326332
: currentTag ?? version
327-
previousTag = previousTag ?? gitSemverTags[0]
333+
previousTag = previousTag ?? at(gitSemverTags, 0)
328334
}
329335

330336
// set release date

docs/.vitepress/composables/use-comments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import type { Root } from '@flex-development/docast'
77
import docastParse, { type Options } from '@flex-development/docast-parse'
8-
import { CompareResult } from '@flex-development/tutils'
8+
import pathe, { type ParsedPath } from '@flex-development/pathe'
9+
import { CompareResult, sort } from '@flex-development/tutils'
910
import { globby } from 'globby'
1011
import fs from 'node:fs/promises'
11-
import pathe, { type ParsedPath } from '@flex-development/pathe'
1212
import { unified } from 'unified'
1313
import { VFile } from 'vfile'
1414
import attacher from '../theme/comments/plugin'
@@ -21,7 +21,7 @@ import type Documentation from '../theme/documentation'
2121
*
2222
* @return {Promise<Documentation[]>} Documentation objects
2323
*/
24-
async function useComments(): Promise<Documentation[]> {
24+
const useComments = async (): Promise<Documentation[]> => {
2525
/**
2626
* Documentation objects.
2727
*
@@ -107,7 +107,7 @@ async function useComments(): Promise<Documentation[]> {
107107
for (const doc of compilation) objects.push({ doc, file: p })
108108
}
109109

110-
return objects.sort((obj1: Documentation, obj2: Documentation): number => {
110+
return sort(objects, (obj1: Documentation, obj2: Documentation): number => {
111111
/**
112112
* Comparison result for {@linkcode obj1} and {@linkcode obj2}.
113113
*

docs/.vitepress/composables/use-page-url.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
* @module docs/vitepress/composables/usePageUrl
44
*/
55

6+
import pathe from '@flex-development/pathe'
7+
68
/**
79
* Creates a page url from a relative path.
810
*
911
* @param {string} hostname - Site url
1012
* @param {string} path - Relative page path
1113
* @return {string} Page url
1214
*/
13-
function usePageUrl(hostname: string, path: string): string {
14-
return `${hostname}/${path}`
15+
const usePageUrl = (hostname: string, path: string): string => {
16+
return pathe
17+
.join(hostname, path)
1518
.replace(/\.md$/, '.html')
1619
.replace(/index\.html$/, '')
1720
}

0 commit comments

Comments
 (0)