Skip to content

Commit 294592f

Browse files
committed
refactor: change API, dep++, lint with xo.
BREAKING CHANGE: change API
1 parent 3fa2945 commit 294592f

9 files changed

+6487
-1983
lines changed

.eslintignore

-1
This file was deleted.

.eslintrc.cjs

-33
This file was deleted.

.vscode/settings.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"editor.formatOnSave": true,
3+
"xo.enable": true,
4+
"xo.format.enable": true,
5+
"[javascript]": {
6+
"editor.defaultFormatter": "samverschueren.linter-xo"
7+
},
38
"[typescript]": {
4-
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
"editor.defaultFormatter": "samverschueren.linter-xo"
510
}
611
}

.xo-config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"space": true
3+
}

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ npm install construct-typed-parameters
2424
import { TypedParameters } from 'construct-typed-parameters';
2525

2626
const parameters = new TypedParameters(parameterType => ({
27-
TOKEN: parameterType.String({ required: true }),
28-
FIREBASE_CONFIG: parameterType.Json<{ apiKey: string }>({ required: true }),
27+
TOKEN: parameterType.string({ required: true }),
28+
FIREBASE_CONFIG: parameterType.json<{ apiKey: string }>({ required: true }),
2929
}));
3030

3131
const stringifiedParameters = parameters.stringify({
@@ -104,41 +104,41 @@ see `test/index.spec.ts`.
104104
import { TypedParameters } from 'construct-typed-parameters';
105105

106106
const parameters = new TypedParameters(pt => ({
107-
stringValue: pt.String({
107+
stringValue: pt.string({
108108
// required: boolean
109109
required: true,
110110
// defaultValue?: T1
111111
defaultValue: 'xxxx',
112112
// validate?: (value: T1) => string | string[] | null;
113113
validate: v => (v.includes('x') ? null : 'the value must contain x'),
114114
}),
115-
unionStringValue: pt.UnionString<'v1' | 'v2'>({
115+
unionStringValue: pt.unionString<'v1' | 'v2'>({
116116
required: true,
117117
defaultValue: 'v1',
118118
validate: v =>
119119
['v1', 'v2'].includes(v) ? null : 'the value must be v1 or v2',
120120
}),
121-
numberValue: pt.Number({
121+
numberValue: pt.number({
122122
required: true,
123123
defaultValue: 1,
124124
validate: v => (v === 0 ? 'value must not be 0' : null),
125125
}),
126-
unionNumberValue: pt.UnionNumber<0 | 1>({
126+
unionNumberValue: pt.unionNumber<0 | 1>({
127127
required: true,
128128
defaultValue: 0,
129129
validate: v => ([0, 1].includes(v) ? null : 'the value must be 0 or 1'),
130130
}),
131-
booleanValue: pt.Boolean({
131+
booleanValue: pt.boolean({
132132
required: true,
133133
defaultValue: true,
134134
validate: v => (v ? null : 'the value must be true'),
135135
}),
136-
jsonValue: pt.Json<{ apiKey: string }>({
136+
jsonValue: pt.json<{ apiKey: string }>({
137137
required: true,
138138
defaultValue: { apiKey: 'xxxx' },
139139
validate: v => (v.apiKey.length ? null : 'apiKey must be specified'),
140140
}),
141-
arrayValue: pt.Json<string[]>({
141+
arrayValue: pt.json<string[]>({
142142
required: true,
143143
defaultValue: ['main', 'sub'],
144144
validate: v => (v.length ? null : 'array must not empty'),

0 commit comments

Comments
 (0)