Skip to content

Commit 9024516

Browse files
shmaxdimaMachina
andauthored
Linting fixes (#8796)
* linting for generated files * add changeset Co-authored-by: Dimitri POSTOLOV <[email protected]>
1 parent a39d7a0 commit 9024516

File tree

11 files changed

+55
-46
lines changed

11 files changed

+55
-46
lines changed

.changeset/soft-pumpkins-smile.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-codegen/gql-tag-operations': patch
3+
'@graphql-codegen/client-preset': patch
4+
'@graphql-codegen/gql-tag-operations-preset': patch
5+
---
6+
7+
remove extra asterisk and add missing semicolon in generated output

dev-test/gql-tag-operations-masking-star-wars/gql/gql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const documents = {
3030
*
3131
* The query argument is unknown!
3232
* Please regenerate the types.
33-
**/
33+
*/
3434
export function gql(source: string): unknown;
3535

3636
/**

dev-test/gql-tag-operations-masking/gql/gql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const documents = {
3333
*
3434
* The query argument is unknown!
3535
* Please regenerate the types.
36-
**/
36+
*/
3737
export function gql(source: string): unknown;
3838

3939
/**

dev-test/gql-tag-operations/gql/gql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const documents = {
2929
*
3030
* The query argument is unknown!
3131
* Please regenerate the types.
32-
**/
32+
*/
3333
export function gql(source: string): unknown;
3434

3535
/**

dev-test/gql-tag-operations/graphql/gql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const documents = {
2929
*
3030
* The query argument is unknown!
3131
* Please regenerate the types.
32-
**/
32+
*/
3333
export function graphql(source: string): unknown;
3434

3535
/**

packages/plugins/typescript/gql-tag-operations/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const plugin: PluginFunction<{
5858
' * ```\n *\n',
5959
` * The query argument is unknown!\n`,
6060
` * Please regenerate the types.\n`,
61-
`**/\n`,
61+
` */\n`,
6262
`export function ${gqlTagName}(source: string): unknown;\n`,
6363
`\n`,
6464
].join('')

packages/presets/client/src/fragment-masking-plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ const createUnmaskFunctionTypeDefinitions = (unmaskFunctionName = defaultUnmaskF
5959
];
6060

6161
const createUnmaskFunction = (unmaskFunctionName = defaultUnmaskFunctionName) => `
62-
${createUnmaskFunctionTypeDefinitions(unmaskFunctionName).join(';\n')}
63-
${createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: true, list: 'with-list' })} {
64-
return fragmentType as any
62+
${createUnmaskFunctionTypeDefinitions(unmaskFunctionName)
63+
.concat(createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: true, list: 'with-list' }))
64+
.join(';\n')} {
65+
return fragmentType as any;
6566
}
6667
`;
6768

packages/presets/client/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
184184
plugins: [
185185
{
186186
[`add`]: {
187-
content: reexports.map(moduleName => `export * from "./${moduleName}${reexportsExtension}"`).join('\n'),
187+
content: reexports.map(moduleName => `export * from "./${moduleName}${reexportsExtension}";`).join('\n'),
188188
},
189189
},
190190
],

packages/presets/client/tests/client-preset.spec.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('client-preset', () => {
2929
expect(result).toHaveLength(4);
3030
// index.ts (re-exports)
3131
const indexFile = result.find(file => file.filename === 'out1/index.ts');
32-
expect(indexFile.content).toEqual(`export * from "./gql"
33-
export * from "./fragment-masking"`);
32+
expect(indexFile.content).toEqual(`export * from "./gql";
33+
export * from "./fragment-masking";`);
3434

3535
// gql.ts
3636
const gqlFile = result.find(file => file.filename === 'out1/gql.ts');
@@ -66,7 +66,7 @@ export * from "./fragment-masking"`);
6666
*
6767
* The query argument is unknown!
6868
* Please regenerate the types.
69-
**/
69+
*/
7070
export function graphql(source: string): unknown;
7171
7272
/**
@@ -117,8 +117,8 @@ export * from "./fragment-masking"`);
117117
expect(result).toHaveLength(4);
118118
// index.ts (re-exports)
119119
const indexFile = result.find(file => file.filename === 'out1/index.ts');
120-
expect(indexFile.content).toEqual(`export * from "./gql"
121-
export * from "./fragment-masking"`);
120+
expect(indexFile.content).toEqual(`export * from "./gql";
121+
export * from "./fragment-masking";`);
122122

123123
// gql.ts
124124
const gqlFile = result.find(file => file.filename === 'out1/gql.ts');
@@ -154,7 +154,7 @@ export * from "./fragment-masking"`);
154154
*
155155
* The query argument is unknown!
156156
* Please regenerate the types.
157-
**/
157+
*/
158158
export function graphql(source: string): unknown;
159159
160160
/**
@@ -234,7 +234,7 @@ export * from "./fragment-masking"`);
234234
*
235235
* The query argument is unknown!
236236
* Please regenerate the types.
237-
**/
237+
*/
238238
export function graphql(source: string): unknown;
239239
240240
/**
@@ -315,7 +315,7 @@ export * from "./fragment-masking"`);
315315
*
316316
* The query argument is unknown!
317317
* Please regenerate the types.
318-
**/
318+
*/
319319
export function graphql(source: string): unknown;
320320
321321
/**
@@ -444,7 +444,7 @@ export * from "./fragment-masking"`);
444444
*
445445
* The query argument is unknown!
446446
* Please regenerate the types.
447-
**/
447+
*/
448448
export function graphql(source: string): unknown;
449449
450450
/**
@@ -564,7 +564,7 @@ export * from "./fragment-masking"`);
564564
*
565565
* The query argument is unknown!
566566
* Please regenerate the types.
567-
**/
567+
*/
568568
export function graphql(source: string): unknown;
569569
570570
/**
@@ -644,7 +644,7 @@ export * from "./fragment-masking"`);
644644
expect(fileNames).toContain('out1/graphql.ts');
645645

646646
const indexFile = result.find(file => file.filename === 'out1/index.ts');
647-
expect(indexFile.content).toMatchInlineSnapshot(`"export * from "./gql""`);
647+
expect(indexFile.content).toMatchInlineSnapshot(`"export * from "./gql";"`);
648648
const gqlFile = result.find(file => file.filename === 'out1/gql.ts');
649649
expect(gqlFile.content).toMatchInlineSnapshot(`
650650
"/* eslint-disable */
@@ -678,7 +678,7 @@ export * from "./fragment-masking"`);
678678
*
679679
* The query argument is unknown!
680680
* Please regenerate the types.
681-
**/
681+
*/
682682
export function graphql(source: string): unknown;
683683
684684
/**
@@ -789,12 +789,12 @@ export * from "./fragment-masking"`);
789789
export function iLikeTurtles<TType>(
790790
_documentNode: DocumentNode<TType, any>,
791791
fragmentType: ReadonlyArray<FragmentType<DocumentNode<TType, any>>> | null | undefined
792-
): ReadonlyArray<TType> | null | undefined
792+
): ReadonlyArray<TType> | null | undefined;
793793
export function iLikeTurtles<TType>(
794794
_documentNode: DocumentNode<TType, any>,
795795
fragmentType: FragmentType<DocumentNode<TType, any>> | ReadonlyArray<FragmentType<DocumentNode<TType, any>>> | null | undefined
796796
): TType | ReadonlyArray<TType> | null | undefined {
797-
return fragmentType as any
797+
return fragmentType as any;
798798
}
799799
800800
@@ -828,14 +828,14 @@ export * from "./fragment-masking"`);
828828
export function iLikeTurtles<TType>(
829829
_documentNode: DocumentNode<TType, any>,
830830
fragmentType: ReadonlyArray<FragmentType<DocumentNode<TType, any>>> | null | undefined
831-
): ReadonlyArray<TType> | null | undefined
831+
): ReadonlyArray<TType> | null | undefined;
832832
`);
833833
expect(gqlFile.content).toBeSimilarStringTo(`
834834
export function iLikeTurtles<TType>(
835835
_documentNode: DocumentNode<TType, any>,
836836
fragmentType: FragmentType<DocumentNode<TType, any>> | ReadonlyArray<FragmentType<DocumentNode<TType, any>>> | null | undefined
837837
): TType | ReadonlyArray<TType> | null | undefined {
838-
return fragmentType as any
838+
return fragmentType as any;
839839
}
840840
`);
841841
});
@@ -945,8 +945,8 @@ export * from "./fragment-masking"`);
945945
expect(result).toHaveLength(4);
946946
// index.ts (re-exports)
947947
const indexFile = result.find(file => file.filename === 'out1/index.ts');
948-
expect(indexFile.content).toEqual(`export * from "./gql.js"
949-
export * from "./fragment-masking.js"`);
948+
expect(indexFile.content).toEqual(`export * from "./gql.js";
949+
export * from "./fragment-masking.js";`);
950950

951951
// gql.ts
952952
const gqlFile = result.find(file => file.filename === 'out1/gql.ts');
@@ -982,7 +982,7 @@ export * from "./fragment-masking.js"`);
982982
*
983983
* The query argument is unknown!
984984
* Please regenerate the types.
985-
**/
985+
*/
986986
export function graphql(source: string): unknown;
987987
988988
/**
@@ -1034,8 +1034,8 @@ export * from "./fragment-masking.js"`);
10341034
expect(result).toHaveLength(4);
10351035
// index.ts (re-exports)
10361036
const indexFile = result.find(file => file.filename === 'out1/index.ts');
1037-
expect(indexFile.content).toEqual(`export * from "./gql.js"
1038-
export * from "./fragment-masking.js"`);
1037+
expect(indexFile.content).toEqual(`export * from "./gql.js";
1038+
export * from "./fragment-masking.js";`);
10391039

10401040
// gql.ts
10411041
const gqlFile = result.find(file => file.filename === 'out1/gql.ts');
@@ -1056,7 +1056,7 @@ export * from "./fragment-masking.js"`);
10561056
*
10571057
* The query argument is unknown!
10581058
* Please regenerate the types.
1059-
**/
1059+
*/
10601060
export function graphql(source: string): unknown;
10611061
10621062
export function graphql(source: string) {

packages/presets/gql-tag-operations/src/fragment-masking-plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ const createUnmaskFunctionTypeDefinitions = (unmaskFunctionName = defaultUnmaskF
5151
];
5252

5353
const createUnmaskFunction = (unmaskFunctionName = defaultUnmaskFunctionName) => `
54-
${createUnmaskFunctionTypeDefinitions(unmaskFunctionName).join(';\n')}
55-
${createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: true, list: 'with-list' })} {
56-
return fragmentType as any
54+
${createUnmaskFunctionTypeDefinitions(unmaskFunctionName)
55+
.concat(createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: true, list: 'with-list' }))
56+
.join(';\n')} {
57+
return fragmentType as any;
5758
}
5859
`;
5960

0 commit comments

Comments
 (0)