Skip to content

Commit ad5ba26

Browse files
committed
lint-fix
1 parent 949dd94 commit ad5ba26

26 files changed

+643
-732
lines changed

.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 & 2 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,7 +32,7 @@ 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
3838
- name: Auto commit fixed code

.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:

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ export default antfu({
99
'example/**',
1010
'vitest.config.ts',
1111
'tsconfig.json',
12+
'README.md',
1213
],
14+
}, {
15+
rules: { 'style/semi': 'off' },
1316
})

package.json

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,40 @@
66
"type": "git",
77
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema.git"
88
},
9-
"main": "dist/main/index.js",
10-
"typings": "dist/types/index.d.ts",
11-
"module": "dist/module/index.js",
9+
"author": "codehex",
10+
"license": "MIT",
11+
"bugs": {
12+
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/issues"
13+
},
14+
"keywords": [
15+
"gql",
16+
"generator",
17+
"yup",
18+
"zod",
19+
"code",
20+
"types",
21+
"graphql",
22+
"codegen",
23+
"apollo",
24+
"node",
25+
"types",
26+
"typings"
27+
],
1228
"exports": {
1329
".": {
1430
"types": "./dist/types/index.d.ts",
1531
"import": "./dist/module/index.js",
1632
"require": "./dist/main/index.js"
1733
}
1834
},
35+
"main": "dist/main/index.js",
36+
"typings": "dist/types/index.d.ts",
37+
"module": "dist/module/index.js",
1938
"files": [
20-
"dist/**/*.{js,ts}",
2139
"!**/*.tsbuildinfo",
2240
"LICENSE",
23-
"README.md"
41+
"README.md",
42+
"dist/**/*.{js,ts}"
2443
],
2544
"scripts": {
2645
"type-check": "tsc --noEmit",
@@ -32,27 +51,22 @@
3251
"build:main": "tsc -p tsconfig.main.json",
3352
"build:module": "tsc -p tsconfig.module.json",
3453
"build:types": "tsc -p tsconfig.types.json",
35-
"lint": "eslint --ext .ts .",
36-
"lint-fix": "eslint --fix --ext .ts .",
54+
"lint": "eslint .",
55+
"lint-fix": "eslint . --fix",
3756
"generate": "run-p build:* && graphql-codegen",
3857
"prepublish": "run-p build:*"
3958
},
40-
"keywords": [
41-
"gql",
42-
"generator",
43-
"yup",
44-
"zod",
45-
"code",
46-
"types",
47-
"graphql",
48-
"codegen",
49-
"apollo",
50-
"node",
51-
"types",
52-
"typings"
53-
],
54-
"author": "codehex",
55-
"license": "MIT",
59+
"peerDependencies": {
60+
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
61+
},
62+
"dependencies": {
63+
"@graphql-codegen/plugin-helpers": "^5.0.0",
64+
"@graphql-codegen/schema-ast": "4.0.2",
65+
"@graphql-codegen/visitor-plugin-common": "^5.0.0",
66+
"@graphql-tools/utils": "^10.0.0",
67+
"graphlib": "^2.1.8",
68+
"graphql": "^16.6.0"
69+
},
5670
"devDependencies": {
5771
"@antfu/eslint-config": "^2.12.2",
5872
"@graphql-codegen/cli": "5.0.2",
@@ -70,19 +84,5 @@
7084
"vitest": "^1.0.0",
7185
"yup": "1.4.0",
7286
"zod": "3.22.4"
73-
},
74-
"dependencies": {
75-
"@graphql-codegen/plugin-helpers": "^5.0.0",
76-
"@graphql-codegen/schema-ast": "4.0.2",
77-
"@graphql-codegen/visitor-plugin-common": "^5.0.0",
78-
"@graphql-tools/utils": "^10.0.0",
79-
"graphlib": "^2.1.8",
80-
"graphql": "^16.6.0"
81-
},
82-
"peerDependencies": {
83-
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
84-
},
85-
"bugs": {
86-
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/issues"
8787
}
8888
}

src/config.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
1+
import type { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
22

33
export type ValidationSchema = 'yup' | 'zod' | 'myzod';
44
export type ValidationSchemaExportType = 'function' | 'const';
55

66
export interface DirectiveConfig {
77
[directive: string]: {
8-
[argument: string]: string | string[] | DirectiveObjectArguments;
9-
};
8+
[argument: string]: string | string[] | DirectiveObjectArguments
9+
}
1010
}
1111

1212
export interface DirectiveObjectArguments {
13-
[matched: string]: string | string[];
13+
[matched: string]: string | string[]
1414
}
1515

1616
interface ScalarSchemas {
17-
[name: string]: string;
17+
[name: string]: string
1818
}
1919

2020
export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
@@ -33,7 +33,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
3333
* schema: yup
3434
* ```
3535
*/
36-
schema?: ValidationSchema;
36+
schema?: ValidationSchema
3737
/**
3838
* @description import types from generated typescript type path
3939
* if not given, omit import statement.
@@ -52,7 +52,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
5252
* importFrom: ./path/to/types
5353
* ```
5454
*/
55-
importFrom?: string;
55+
importFrom?: string
5656
/**
5757
* @description Will use `import type {}` rather than `import {}` when importing generated typescript types.
5858
* This gives compatibility with TypeScript's "importsNotUsedAsValues": "error" option
@@ -74,7 +74,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
7474
* useTypeImports: true
7575
* ```
7676
*/
77-
useTypeImports?: boolean;
77+
useTypeImports?: boolean
7878
/**
7979
* @description Prefixes all import types from generated typescript type.
8080
* @default ""
@@ -93,7 +93,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
9393
* importFrom: ./path/to/types
9494
* ```
9595
*/
96-
typesPrefix?: string;
96+
typesPrefix?: string
9797
/**
9898
* @description Suffixes all import types from generated typescript type.
9999
* @default ""
@@ -112,7 +112,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
112112
* importFrom: ./path/to/types
113113
* ```
114114
*/
115-
typesSuffix?: string;
115+
typesSuffix?: string
116116
/**
117117
* @description Generates validation schema for enum as TypeScript `type`
118118
* @default false
@@ -137,7 +137,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
137137
* enumsAsTypes: true
138138
* ```
139139
*/
140-
enumsAsTypes?: boolean;
140+
enumsAsTypes?: boolean
141141
/**
142142
* @description Generates validation string schema as do not allow empty characters by default.
143143
* @default false
@@ -152,7 +152,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
152152
* notAllowEmptyString: true
153153
* ```
154154
*/
155-
notAllowEmptyString?: boolean;
155+
notAllowEmptyString?: boolean
156156
/**
157157
* @description Extends or overrides validation schema for the built-in scalars and custom GraphQL scalars.
158158
*
@@ -174,7 +174,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
174174
* Email: z.string().email()
175175
* ```
176176
*/
177-
scalarSchemas?: ScalarSchemas;
177+
scalarSchemas?: ScalarSchemas
178178
/**
179179
* @description Generates validation schema with GraphQL type objects.
180180
* but excludes "Query", "Mutation", "Subscription" objects.
@@ -193,7 +193,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
193193
* withObjectType: true
194194
* ```
195195
*/
196-
withObjectType?: boolean;
196+
withObjectType?: boolean
197197
/**
198198
* @description Specify validation schema export type.
199199
* @default function
@@ -209,7 +209,7 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
209209
* validationSchemaExportType: const
210210
* ```
211211
*/
212-
validationSchemaExportType?: ValidationSchemaExportType;
212+
validationSchemaExportType?: ValidationSchemaExportType
213213
/**
214214
* @description Generates validation schema with more API based on directive schema.
215215
* @exampleMarkdown
@@ -250,5 +250,5 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
250250
* exclusiveMax: max
251251
* ```
252252
*/
253-
directives?: DirectiveConfig;
253+
directives?: DirectiveConfig
254254
}

0 commit comments

Comments
 (0)