Skip to content

Commit d62cabf

Browse files
authored
Merge branch 'main' into patch-1
2 parents 4f8dab4 + 1c1a379 commit d62cabf

33 files changed

+3513
-2421
lines changed

.eslintrc.json

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

.github/renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"dependencyDashboard": false,
1010
"onboarding": false,
1111
"prConcurrentLimit": 5
12-
}
12+
}

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/setup-node@v3
1717
with:
1818
node-version: current
19-
cache: 'pnpm'
19+
cache: pnpm
2020
- run: pnpm install --frozen-lockfile
2121
- run: pnpm test
2222
env:
@@ -32,10 +32,9 @@ jobs:
3232
uses: actions/setup-node@v3
3333
with:
3434
node-version: current
35-
cache: 'pnpm'
35+
cache: pnpm
3636
- run: pnpm install --frozen-lockfile
3737
- run: pnpm lint-fix
38-
- run: pnpm prettier
3938
- name: Auto commit fixed code
4039
id: auto-commit-action
4140
uses: stefanzweifel/git-auto-commit-action@v4

.github/workflows/issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'good first issue'
1+
name: good first issue
22
on: [issues]
33

44
jobs:

.prettierignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
node_modules
2-
dist
3-
.npmignore
4-
package-lock.json
5-
.DS_Store
6-
tsconfig.tsbuildinfo
7-
example
1+
**

.prettierrc.json

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

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ generates:
239239
constraint:
240240
minLength: min
241241
# Replace $1 with specified `startsWith` argument value of the constraint directive
242-
startsWith: ["matches", "/^$1/"]
242+
startsWith: [matches, /^$1/]
243243
format:
244244
email: email
245245
```
@@ -249,7 +249,7 @@ Then generates yup validation schema like below.
249249
```ts
250250
export function ExampleInputSchema(): yup.SchemaOf<ExampleInput> {
251251
return yup.object({
252-
email: yup.string().defined().required("Hello, World!").min(50).email(),
252+
email: yup.string().defined().required('Hello, World!').min(50).email(),
253253
message: yup.string().defined().matches(/^Hello/)
254254
})
255255
}
@@ -277,7 +277,7 @@ generates:
277277
constraint:
278278
minLength: min
279279
# Replace $1 with specified `startsWith` argument value of the constraint directive
280-
startsWith: ["regex", "/^$1/", "message"]
280+
startsWith: [regex, /^$1/, message]
281281
format:
282282
email: email
283283
```
@@ -288,7 +288,7 @@ Then generates zod validation schema like below.
288288
export function ExampleInputSchema(): z.ZodSchema<ExampleInput> {
289289
return z.object({
290290
email: z.string().min(50).email(),
291-
message: z.string().regex(/^Hello/, "message")
291+
message: z.string().regex(/^Hello/, 'message')
292292
})
293293
}
294294
```
@@ -310,4 +310,4 @@ generates:
310310
preset: 'client',
311311
plugins:
312312
...
313-
```
313+
```

codegen.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
overwrite: true
2-
schema: './example/test.graphql'
2+
schema: ./example/test.graphql
33
generates:
44
example/types.ts:
55
plugins:
@@ -21,11 +21,11 @@ generates:
2121
constraint:
2222
minLength: min # same as ['min', '$1']
2323
maxLength: max
24-
startsWith: ['matches', '/^$1/']
25-
endsWith: ['matches', '/$1$/']
26-
contains: ['matches', '/$1/']
27-
notContains: ['matches', '/^((?!$1).)*$/']
28-
pattern: ['matches', '/$1/']
24+
startsWith: [matches, /^$1/]
25+
endsWith: [matches, /$1$/]
26+
contains: [matches, /$1/]
27+
notContains: [matches, '/^((?!$1).)*$/']
28+
pattern: [matches, /$1/]
2929
format:
3030
# For example, `@constraint(format: "uri")`. this case $1 will be "uri".
3131
# Therefore the generator generates yup schema `.url()` followed by `uri: 'url'`
@@ -37,8 +37,8 @@ generates:
3737
# you need to add the logic using `yup.addMethod`.
3838
# see: https://github.com/jquense/yup#addmethodschematype-schema-name-string-method--schema-void
3939
ipv4: ipv4
40-
min: ['min', '$1 - 1']
41-
max: ['max', '$1 + 1']
40+
min: [min, $1 - 1]
41+
max: [max, '$1 + 1']
4242
exclusiveMin: min
4343
exclusiveMax: max
4444
scalars:
@@ -61,7 +61,7 @@ generates:
6161
constraint:
6262
minLength: min
6363
# Replace $1 with specified `startsWith` argument value of the constraint directive
64-
startsWith: ['regex', '/^$1/', 'message']
64+
startsWith: [regex, /^$1/, message]
6565
format:
6666
email: email
6767
scalars:
@@ -76,7 +76,7 @@ generates:
7676
constraint:
7777
minLength: min
7878
# Replace $1 with specified `startsWith` argument value of the constraint directive
79-
startsWith: ['pattern', '/^$1/']
79+
startsWith: [pattern, /^$1/]
8080
format:
8181
email: email
8282
scalars:

eslint.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu({
4+
typescript: true,
5+
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
6+
ignores: [
7+
'dist/**',
8+
'node_modules/**',
9+
'example/**',
10+
'vitest.config.ts',
11+
'tsconfig.json',
12+
'README.md',
13+
],
14+
}, {
15+
rules: { 'style/semi': 'off' },
16+
})

example/yup/schemas.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as yup from 'yup'
22
import { Admin, AttributeInput, ButtonComponentType, ComponentInput, DropDownComponentInput, EventArgumentInput, EventInput, EventOptionType, Guest, HttpInput, HttpMethod, LayoutInput, MyType, MyTypeFooArgs, PageInput, PageType, User, UserKind } from '../types'
33

4-
export const ButtonComponentTypeSchema = yup.string<ButtonComponentType>().oneOf([ButtonComponentType.Button, ButtonComponentType.Submit]).defined();
4+
export const ButtonComponentTypeSchema = yup.string<ButtonComponentType>().oneOf(Object.values(ButtonComponentType)).defined();
55

6-
export const EventOptionTypeSchema = yup.string<EventOptionType>().oneOf([EventOptionType.Reload, EventOptionType.Retry]).defined();
6+
export const EventOptionTypeSchema = yup.string<EventOptionType>().oneOf(Object.values(EventOptionType)).defined();
77

8-
export const HttpMethodSchema = yup.string<HttpMethod>().oneOf([HttpMethod.Get, HttpMethod.Post]).defined();
8+
export const HttpMethodSchema = yup.string<HttpMethod>().oneOf(Object.values(HttpMethod)).defined();
99

10-
export const PageTypeSchema = yup.string<PageType>().oneOf([PageType.BasicAuth, PageType.Lp, PageType.Restricted, PageType.Service]).defined();
10+
export const PageTypeSchema = yup.string<PageType>().oneOf(Object.values(PageType)).defined();
1111

1212
function union<T extends {}>(...schemas: ReadonlyArray<yup.Schema<T>>): yup.MixedSchema<T> {
1313
return yup.mixed<T>().test({

0 commit comments

Comments
 (0)