Skip to content

Commit 1e05848

Browse files
committed
build(deps): bump @flex-development/tutils from 6.0.0-alpha.10 to 6.0.0-alpha.14
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 1c11e2e commit 1e05848

File tree

14 files changed

+152
-100
lines changed

14 files changed

+152
-100
lines changed

.eslintrc.base.cjs

Lines changed: 1 addition & 2 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,
@@ -997,7 +997,6 @@ const config = {
997997
'@typescript-eslint/no-misused-promises': 0,
998998
'@typescript-eslint/no-mixed-enums': 0,
999999
'@typescript-eslint/no-redundant-type-constituents': 0,
1000-
'@typescript-eslint/no-throw-literal': 0,
10011000
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 0,
10021001
'@typescript-eslint/no-unnecessary-condition': 0,
10031002
'@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
}

__tests__/setup/serializers/regex-array.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,35 @@
44
*/
55

66
import type { RegExpArray } from '#tests/types'
7-
import { isNumber, isString, type Fn } from '@flex-development/tutils'
8-
import { get, omit } from 'radash'
7+
import {
8+
get,
9+
isArray,
10+
isNumber,
11+
isString,
12+
omit,
13+
type Fn
14+
} from '@flex-development/tutils'
915

1016
expect.addSnapshotSerializer({
1117
/**
12-
* Prints the given `value`.
18+
* Prints `value`.
1319
*
1420
* @param {unknown} value - Value to print
1521
* @param {Fn<[unknown], string>} printer - Print function
1622
* @return {string} `value` as printable string
1723
*/
1824
print(value: unknown, printer: Fn<[unknown], string>): string {
19-
return printer(omit(value as RegExpArray, ['index', 'input']))
25+
return printer(omit(value, ['index', 'input']))
2026
},
2127
/**
22-
* Checks if the given `value` is a {@linkcode RegExpArray}.
28+
* Checks if `value` is a {@linkcode RegExpArray}.
2329
*
2430
* @param {unknown} value - Value to check
2531
* @return {value is RegExpArray} `true` if `value` is {@linkcode RegExpArray}
2632
*/
2733
test(value: unknown): value is RegExpArray {
2834
return (
29-
Array.isArray(value) &&
35+
isArray(value) &&
3036
isNumber(get(value, 'index')) &&
3137
isString(get(value, 'input'))
3238
)

__tests__/types/regex.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* @module tests/types/Regex
44
*/
55

6+
import type { Pick } from '@flex-development/tutils'
7+
68
/**
79
* Object containing testable {@linkcode RegExp} properties.
810
*/

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

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
"typecheck:watch": "vitest typecheck"
7272
},
7373
"dependencies": {
74-
"@flex-development/errnode": "1.5.0",
74+
"@flex-development/errnode": "2.0.0",
7575
"@flex-development/pathe": "1.0.3",
76-
"@flex-development/tutils": "6.0.0-alpha.10"
76+
"@flex-development/tutils": "6.0.0-alpha.14"
7777
},
7878
"devDependencies": {
7979
"@commitlint/cli": "17.6.5",
@@ -138,7 +138,6 @@
138138
"pkg-size": "2.4.0",
139139
"prettier": "2.8.8",
140140
"prettier-plugin-sh": "0.12.8",
141-
"radash": "10.8.1",
142141
"sade": "1.8.1",
143142
"semver": "7.5.2",
144143
"serve": "14.2.0",
@@ -155,7 +154,7 @@
155154
},
156155
"resolutions": {
157156
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",
158-
"@flex-development/tutils": "6.0.0-alpha.10"
157+
"@flex-development/tutils": "6.0.0-alpha.14"
159158
},
160159
"engines": {
161160
"node": ">=16.20.0",

src/interfaces/__tests__/options.spec-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* @module ext-regex/interfaces/tests/unit-d/Options
44
*/
55

6-
import type { KeysRequired, Nilable } from '@flex-development/tutils'
6+
import type { Nilable, RequiredKeys } from '@flex-development/tutils'
77
import type TestSubject from '../options'
88

99
describe('unit-d:interfaces/Options', () => {
1010
it('should allow empty object', () => {
11-
expectTypeOf<KeysRequired<TestSubject>>().toBeNever()
11+
expectTypeOf<RequiredKeys<TestSubject>>().toBeNever()
1212
})
1313

1414
it('should match [flags?: Nilable<string>]', () => {

src/internal/__tests__/validate-string.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { ErrorCode, type NodeError } from '@flex-development/errnode'
7+
import { cast } from '@flex-development/tutils'
78
import testSubject from '../validate-string'
89

910
describe('unit:internal/validateString', () => {
@@ -13,24 +14,24 @@ describe('unit:internal/validateString', () => {
1314
name = 'ext'
1415
})
1516

16-
it('should return true if value is typeof string', () => {
17+
it('should return true if value is a string', () => {
1718
expect(testSubject('.mjs', name)).to.be.true
1819
})
1920

20-
it('should throw if value is not typeof string', () => {
21+
it('should throw if value is not a string', () => {
2122
// Arrange
22-
const code: ErrorCode = ErrorCode.ERR_INVALID_ARG_TYPE
23-
let error: NodeError<TypeError>
23+
let error!: NodeError<TypeError>
2424

2525
// Act
2626
try {
2727
testSubject(null, name)
2828
} catch (e: unknown) {
29-
error = e as typeof error
29+
error = cast(e)
3030
}
3131

3232
// Expect
33-
expect(error!).to.be.instanceof(TypeError)
34-
expect(error!).to.have.property('code').equal(code)
33+
expect(error)
34+
.to.be.instanceof(TypeError)
35+
.with.property('code', ErrorCode.ERR_INVALID_ARG_TYPE)
3536
})
3637
})

src/internal/validate-string.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import * as errnode from '@flex-development/errnode'
7+
import { isString } from '@flex-development/tutils'
78

89
/**
9-
* Checks if given `value` is a string.
10+
* Checks if `value` is a string.
1011
*
1112
* Throws [`ERR_INVALID_ARG_TYPE`][1] if the `value` is not a string.
1213
*
@@ -21,7 +22,7 @@ import * as errnode from '@flex-development/errnode'
2122
* @throws {errnode.NodeError<TypeError>} If `value` is not a string
2223
*/
2324
const validateString = (value: unknown, name: string): value is string => {
24-
if (typeof value === 'string') return true
25+
if (isString(value)) return true
2526
throw new errnode.ERR_INVALID_ARG_TYPE(name, 'string', value)
2627
}
2728

0 commit comments

Comments
 (0)