Skip to content

Commit ec342c6

Browse files
authored
Fix ESLint issues (#10199)
* Fix ESLint issues * Avoid using eslint flag config in VSCode
1 parent 839b6f0 commit ec342c6

File tree

16 files changed

+26
-12
lines changed

16 files changed

+26
-12
lines changed

.eslintrc.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ module.exports = {
5656
project: ['./tsconfig.json'],
5757
},
5858
},
59+
{
60+
files: ['scripts/*.{ts,js}', 'prettier.config.cjs', 'jest.config.js', 'jest.project.js'],
61+
rules: {
62+
'@typescript-eslint/no-require-imports': 'off',
63+
},
64+
},
5965
],
6066
ignorePatterns: [
6167
'dev-test',

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"yaml.schemas": {
33
"./website/static/config.schema.json": "*codegen.*"
44
},
5+
"eslint.useFlatConfig": false,
56
"editor.tabSize": 2,
67
"editor.insertSpaces": true,
78
"editor.rulers": [80],

packages/graphql-codegen-cli/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function runCli(cmd: string): Promise<number> {
3131
export async function ensureGraphQlPackage() {
3232
try {
3333
await import('graphql');
34-
} catch (e) {
34+
} catch {
3535
throw new Error(
3636
`Unable to load "graphql" package. Please make sure to install "graphql" as a dependency! \n
3737
To install "graphql", run:

packages/graphql-codegen-cli/src/graphql-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function isGraphQLConfig(config: GraphQLConfig): config is GraphQLConfig {
5757

5858
try {
5959
return config.getDefault().hasExtension('codegen');
60-
} catch (e) {}
60+
} catch {}
6161

6262
try {
6363
for (const projectName in config.projects) {
@@ -69,7 +69,7 @@ function isGraphQLConfig(config: GraphQLConfig): config is GraphQLConfig {
6969
}
7070
}
7171
}
72-
} catch (e) {}
72+
} catch {}
7373

7474
return false;
7575
}

packages/graphql-codegen-cli/src/utils/watcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const createWatcher = (
119119
// In ESM require is not defined
120120
try {
121121
delete require.cache[path];
122-
} catch (err) {}
122+
} catch {}
123123

124124
if (eventName === 'update' && config.configFilePath && path === config.configFilePath) {
125125
log(`${logSymbols.info} Config file has changed, reloading...`);

packages/graphql-codegen-cli/tests/__mocks__/some-fetch.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
const {
23
promises: { readFile },
34
} = require('fs');

packages/graphql-codegen-cli/tests/custom-loaders/custom-documents-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
const { parse } = require('graphql');
23
const { readFileSync } = require('fs');
34
const { join } = require('path');

packages/graphql-codegen-cli/tests/custom-loaders/custom-schema-loader-with-context.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
const { buildSchema } = require('graphql');
23
const { readFileSync } = require('fs');
34
const { join } = require('path');

packages/graphql-codegen-cli/tests/custom-loaders/custom-schema-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
const { buildSchema } = require('graphql');
23
const { readFileSync } = require('fs');
34
const { join } = require('path');

packages/graphql-codegen-cli/tests/init.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
import { resolve } from 'path';
23
import bddStdin from 'bdd-stdin';
34
import { bold } from '../src/init/helpers.js';

packages/plugins/other/schema-ast/tests/schema-ast.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('Schema AST', () => {
3939

4040
try {
4141
await validate(null, null, null, fileName, plugins);
42-
} catch (e) {
42+
} catch {
4343
expect(true).toBeFalsy();
4444
}
4545
});
@@ -54,7 +54,7 @@ describe('Schema AST', () => {
5454

5555
try {
5656
await validate(null, null, null, fileName, plugins);
57-
} catch (e) {
57+
} catch {
5858
expect(true).toBeFalsy();
5959
}
6060
});
@@ -69,7 +69,7 @@ describe('Schema AST', () => {
6969

7070
try {
7171
await validate(null, null, null, fileName, plugins);
72-
} catch (e) {
72+
} catch {
7373
expect(true).toBeFalsy();
7474
}
7575
});
@@ -84,7 +84,7 @@ describe('Schema AST', () => {
8484

8585
try {
8686
await validate(null, null, null, fileName, plugins);
87-
} catch (e) {
87+
} catch {
8888
expect(true).toBeFalsy();
8989
}
9090
});

packages/plugins/other/visitor-plugin-common/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-empty-object-type */
12
import { ASTNode, FragmentDefinitionNode, DirectiveNode } from 'graphql';
23
import { ParsedMapper } from './mappers.js';
34

packages/plugins/other/visitor-plugin-common/src/variables-to-object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class OperationVariablesToObject {
2626
protected _enumPrefix = true,
2727
protected _enumSuffix = true,
2828
protected _enumValues: ParsedEnumValuesMap = {},
29-
protected _applyCoercion: Boolean = false,
29+
protected _applyCoercion: boolean = false,
3030
protected _directiveArgumentAndInputFieldMappings: ParsedDirectiveArgumentAndInputFieldMappings = {}
3131
) {
3232
autoBind(this);
@@ -122,7 +122,7 @@ export class OperationVariablesToObject {
122122
return `${formattedFieldString}: ${formattedTypeString}`;
123123
}
124124

125-
public wrapAstTypeWithModifiers(_baseType: string, _typeNode: TypeNode, _applyCoercion?: Boolean): string {
125+
public wrapAstTypeWithModifiers(_baseType: string, _typeNode: TypeNode, _applyCoercion?: boolean): string {
126126
throw new Error(`You must override "wrapAstTypeWithModifiers" of OperationVariablesToObject!`);
127127
}
128128

packages/plugins/typescript/operations/tests/ts-documents.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { plugin as tsPlugin } from '../../typescript/src/index.js';
55
import { plugin } from '../src/index.js';
66

77
describe('TypeScript Operations Plugin', () => {
8+
// eslint-disable-next-line @typescript-eslint/no-require-imports
89
const gitHuntSchema = buildClientSchema(require('../../../../../dev-test/githunt/schema.json'));
910

1011
const schema = buildSchema(/* GraphQL */ `

packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class TypeScriptOperationVariablesToObject extends OperationVariablesToOb
1919
_enumPrefix = true,
2020
_enumSuffix = true,
2121
_enumValues: ParsedEnumValuesMap = {},
22-
_applyCoercion: Boolean = false,
22+
_applyCoercion: boolean = false,
2323
_directiveArgumentAndInputFieldMappings: ParsedDirectiveArgumentAndInputFieldMappings = {},
2424
private _maybeType = 'Maybe'
2525
) {

packages/utils/graphql-codegen-testing/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function findProjectDir(dirname: string): string | never {
6565
}
6666

6767
dirname = resolve(dirname, '..');
68-
} catch (e) {
68+
} catch {
6969
// ignore
7070
}
7171
}

0 commit comments

Comments
 (0)