Skip to content

Commit 4fff601

Browse files
committed
feat(errors): ERR_INVALID_URL_SCHEME
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent ee4609f commit 4fff601

19 files changed

+206
-236
lines changed

.codecov.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,19 @@ coverage:
6565
threshold: 0%
6666

6767
flags:
68-
node19:
68+
node22:
6969
carryforward: false
7070
paths:
7171
- src/
72-
node18:
72+
node20:
7373
carryforward: false
7474
paths:
7575
- src/
76-
node16:
76+
node19:
77+
carryforward: false
78+
paths:
79+
- src/
80+
node18:
7781
carryforward: false
7882
paths:
7983
- src/
@@ -85,6 +89,7 @@ ignore:
8589
- '**/__mocks__/**'
8690
- '**/__tests__/**'
8791
- '**/index.ts'
92+
- '!src/index.ts'
8893
- src/interfaces/
8994
- src/internal/stack-trace.browser.ts
9095
- src/types/

.github/infrastructure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ branches:
4141
- context: test (18)
4242
- context: test (19)
4343
- context: test (20)
44+
- context: test (22)
4445
- context: typescript (5.4.5)
4546
- context: typescript (5.5.4)
4647
- context: typescript (latest)

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ jobs:
296296
fail-fast: false
297297
matrix:
298298
node-version:
299+
- 22
299300
- 20
300301
- 19
301302
- 18

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ This package exports the following identifiers:
157157
- `ERR_INVALID_PACKAGE_CONFIG`
158158
- `ERR_INVALID_PACKAGE_TARGET`
159159
- `ERR_INVALID_RETURN_VALUE`
160+
- `ERR_INVALID_URL_SCHEME`
160161
- `ERR_INVALID_URL`
161162
- `ERR_METHOD_NOT_IMPLEMENTED`
162163
- `ERR_MISSING_OPTION`

__tests__/utils/node-versions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const NODE_VERSIONS: SemanticVersion[] = [
1515
'19.9.0',
1616
'20.17.0',
1717
'21.7.3',
18-
'22.7.0'
18+
'22.7.0',
19+
'22.8.0'
1920
]
2021

2122
export default NODE_VERSIONS

loader.mjs

Lines changed: 0 additions & 187 deletions
This file was deleted.

package.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,33 @@
3434
"files": [
3535
"CHANGELOG.md",
3636
"LICENSE.md",
37-
"dist",
38-
"src"
37+
"README.md",
38+
"dist"
3939
],
4040
"exports": {
41-
".": "./dist/index.mjs",
41+
".": {
42+
"vitest": null,
43+
"default": "./dist/index.mjs"
44+
},
4245
"./package.json": "./package.json"
4346
},
4447
"imports": {
4548
"#format-message": {
49+
"ts-node": "./src/internal/format-message.development.ts",
4650
"development": "./dist/internal/format-message.development.mjs",
4751
"production": "./dist/internal/format-message.mjs",
4852
"default": "./dist/internal/format-message.mjs"
4953
},
50-
"#hide-stack-frames": "./dist/internal/hide-stack-frames.mjs",
51-
"#k-is-node-error": "./dist/internal/k-is-node-error.mjs",
54+
"#hide-stack-frames": {
55+
"ts-node": "./src/internal/hide-stack-frames.ts",
56+
"default": "./dist/internal/hide-stack-frames.mjs"
57+
},
58+
"#k-is-node-error": {
59+
"ts-node": "./src/internal/k-is-node-error.ts",
60+
"default": "./dist/internal/k-is-node-error.mjs"
61+
},
5262
"#stack-trace": {
63+
"ts-node": "./src/internal/stack-trace.ts",
5364
"browser": "./dist/internal/stack-trace.browser.mjs",
5465
"node": "./dist/internal/stack-trace.mjs",
5566
"default": "./dist/internal/stack-trace.mjs"
@@ -106,11 +117,8 @@
106117
"@commitlint/types": "19.0.3",
107118
"@eslint/js": "9.9.1",
108119
"@flex-development/commitlint-config": "1.0.1",
109-
"@flex-development/decorator-regex": "2.0.0",
110-
"@flex-development/esm-types": "2.0.0",
111120
"@flex-development/grease": "3.0.0-alpha.9",
112121
"@flex-development/mkbuild": "1.0.0-alpha.23",
113-
"@flex-development/mlly": "1.0.0-alpha.18",
114122
"@flex-development/pathe": "2.0.0",
115123
"@flex-development/pkg-types": "4.0.0",
116124
"@stylistic/eslint-plugin": "2.7.2",

src/__snapshots__/errors.integration.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ exports[`integration:errors > ERR_INVALID_RETURN_VALUE > #toString > should retu
3030

3131
exports[`integration:errors > ERR_INVALID_URL > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_URL]: Invalid URL`;
3232

33+
exports[`integration:errors > ERR_INVALID_URL_SCHEME > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file`;
34+
3335
exports[`integration:errors > ERR_METHOD_NOT_IMPLEMENTED > #toString > should return string representation of error 1`] = `Error [ERR_METHOD_NOT_IMPLEMENTED]: The _transform() method is not implemented`;
3436

3537
exports[`integration:errors > ERR_MISSING_OPTION > #toString > should return string representation of error 1`] = `TypeError [ERR_MISSING_OPTION]: init.highWaterMark is required`;

src/__snapshots__/index.e2e.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ exports[`e2e:errnode > should expose public api 1`] = `
2020
"ERR_INVALID_PACKAGE_TARGET",
2121
"ERR_INVALID_RETURN_VALUE",
2222
"ERR_INVALID_URL",
23+
"ERR_INVALID_URL_SCHEME",
2324
"ERR_METHOD_NOT_IMPLEMENTED",
2425
"ERR_MISSING_OPTION",
2526
"ERR_MODULE_NOT_FOUND",

src/__tests__/errors.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ describe('integration:errors', () => {
7777
],
7878
[codes.ERR_INVALID_RETURN_VALUE, TypeError, 'null', 'body', 13],
7979
[codes.ERR_INVALID_URL, TypeError, pathe.sep, 'http://[127.0.0.1]:8000'],
80+
[codes.ERR_INVALID_URL_SCHEME, TypeError, 'file'],
8081
[codes.ERR_METHOD_NOT_IMPLEMENTED, Error, '_transform()'],
8182
[codes.ERR_MISSING_OPTION, TypeError, 'init.highWaterMark'],
8283
[
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:errors/ERR_INVALID_URL_SCHEME > should build message from parameters (0) 1`] = `"The URL must be of scheme file"`;
4+
5+
exports[`unit:errors/ERR_INVALID_URL_SCHEME > should build message from parameters (1) 1`] = `"The URL must be one of scheme file or node"`;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file Type Tests - ERR_INVALID_URL_SCHEME
3+
* @module errnode/errors/tests/unit-d/ERR_INVALID_URL_SCHEME
4+
*/
5+
6+
import { codes } from '#src/enums'
7+
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
8+
import type * as TestSubject from '../err-invalid-url-scheme'
9+
10+
describe('unit-d:errors/ERR_INVALID_URL_SCHEME', () => {
11+
describe('ERR_INVALID_URL_SCHEME', () => {
12+
it('should be ErrInvalidUrlSchemeConstructor', () => {
13+
expectTypeOf<typeof TestSubject.default>()
14+
.toEqualTypeOf<TestSubject.ErrInvalidUrlSchemeConstructor>()
15+
})
16+
})
17+
18+
describe('ErrInvalidUrlScheme', () => {
19+
it('should extend NodeError<codes.ERR_INVALID_URL_SCHEME>', () => {
20+
expectTypeOf<TestSubject.ErrInvalidUrlScheme>()
21+
.toMatchTypeOf<NodeError<codes.ERR_INVALID_URL_SCHEME>>()
22+
})
23+
})
24+
25+
describe('ErrInvalidUrlSchemeConstructor', () => {
26+
it('should match NodeErrorConstructor', () => {
27+
// Arrange
28+
type T = TestSubject.ErrInvalidUrlScheme
29+
type Args = TestSubject.ErrInvalidUrlSchemeArgs
30+
31+
// Expect
32+
expectTypeOf<TestSubject.ErrInvalidUrlSchemeConstructor>()
33+
.toMatchTypeOf<NodeErrorConstructor<T, Args>>()
34+
})
35+
})
36+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @file Unit Tests - ERR_INVALID_URL_SCHEME
3+
* @module errnode/errors/tests/unit/ERR_INVALID_URL_SCHEME
4+
*/
5+
6+
import TestSubject, {
7+
type ErrInvalidUrlScheme
8+
} from '../err-invalid-url-scheme'
9+
10+
describe('unit:errors/ERR_INVALID_URL_SCHEME', () => {
11+
it.each<ConstructorParameters<typeof TestSubject>>([
12+
['file'],
13+
[['file', 'node']]
14+
])('should build message from parameters (%#)', (...args) => {
15+
// Act
16+
const subject: ErrInvalidUrlScheme = new TestSubject(...args)
17+
18+
// Expect
19+
expect(subject).to.have.property('message').be.a('string').that.is.not.empty
20+
expect(subject.message).toMatchSnapshot()
21+
})
22+
})

0 commit comments

Comments
 (0)