diff --git a/jest.config.js b/jest.config.js index 26f9a4877ed..d3c2273a357 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,5 @@ const PROJECTS = false; -const CI = Boolean(process.env.CI); +const CI = !!process.env.CI; module.exports = !PROJECTS || CI diff --git a/jest.project.js b/jest.project.js index 63ff4101e07..0213ed437bc 100644 --- a/jest.project.js +++ b/jest.project.js @@ -5,7 +5,7 @@ const { pathsToModuleNameMapper } = require('ts-jest'); const ROOT_DIR = __dirname; const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json'); const tsconfig = require(TSCONFIG); -const CI = Boolean(process.env.CI); +const CI = !!process.env.CI; module.exports = ({ dirname, projectMode = true }) => { const pkg = require(resolve(dirname, 'package.json')); diff --git a/packages/graphql-codegen-cli/src/codegen.ts b/packages/graphql-codegen-cli/src/codegen.ts index e150f05befe..34e848a9f61 100644 --- a/packages/graphql-codegen-cli/src/codegen.ts +++ b/packages/graphql-codegen-cli/src/codegen.ts @@ -196,7 +196,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom task: (ctx, task) => { const generateTasks: ListrTask[] = Object.keys(generates).map(filename => { const outputConfig = generates[filename]; - const hasPreset = Boolean(outputConfig.preset); + const hasPreset = !!outputConfig.preset; const title = `Generate to ${filename}`; diff --git a/packages/graphql-codegen-cli/src/config.ts b/packages/graphql-codegen-cli/src/config.ts index eaabf218ca4..cca4b2ab651 100644 --- a/packages/graphql-codegen-cli/src/config.ts +++ b/packages/graphql-codegen-cli/src/config.ts @@ -208,7 +208,7 @@ export function buildOptions() { if (typeof watch === 'string' || Array.isArray(watch)) { return watch; } - return Boolean(watch); + return !!watch; }, }, r: { @@ -488,7 +488,7 @@ function addHashToDocumentFiles(documentFilesPromise: Promise m.identifier === identifier)); - const existsFromEnums = Boolean( - Object.keys(this.config.enumValues) - .map(key => this.config.enumValues[key]) - .find(o => o.sourceFile === source && o.typeIdentifier === identifier) - ); + const exists = !groupedMappers[source] ? false : !!groupedMappers[source].find(m => m.identifier === identifier); + const existsFromEnums = !!Object.keys(this.config.enumValues) + .map(key => this.config.enumValues[key]) + .find(o => o.sourceFile === source && o.typeIdentifier === identifier); return exists || existsFromEnums; } @@ -1177,7 +1173,7 @@ export class BaseResolversVisitor< if (argsType !== null) { const argsToForceRequire = original.arguments.filter( - arg => Boolean(arg.defaultValue) || arg.type.kind === 'NonNullType' + arg => !!arg.defaultValue || arg.type.kind === 'NonNullType' ); if (argsToForceRequire.length > 0) { diff --git a/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts index eb42a66fbea..3b5839b34a6 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts @@ -963,7 +963,7 @@ export class BaseTypesVisitor< return null; }) .reverse() - .find(a => Boolean(a)); + .find(a => !!a); return type || null; } diff --git a/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts index d1d6f778cbd..f70e6a7f49c 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts @@ -381,13 +381,13 @@ export class BaseVisitor Boolean(val)).join('\n'); + const block = [before, this._block, after].filter(val => !!val).join('\n'); if (this._methodName) { result += `${this._methodName}(${this._config.blockTransformer(block)})`; diff --git a/packages/plugins/other/visitor-plugin-common/src/variables-to-object.ts b/packages/plugins/other/visitor-plugin-common/src/variables-to-object.ts index 301d3220d37..f5723cb3252 100644 --- a/packages/plugins/other/visitor-plugin-common/src/variables-to-object.ts +++ b/packages/plugins/other/visitor-plugin-common/src/variables-to-object.ts @@ -79,7 +79,7 @@ export class OperationVariablesToObject { return null; }) .reverse() - .find(a => Boolean(a)); + .find(a => !!a); return type || null; } diff --git a/packages/plugins/typescript/operations/src/visitor.ts b/packages/plugins/typescript/operations/src/visitor.ts index 34b37bcbe10..c07b2d5736c 100644 --- a/packages/plugins/typescript/operations/src/visitor.ts +++ b/packages/plugins/typescript/operations/src/visitor.ts @@ -68,7 +68,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< type: GraphQLOutputType | GraphQLNamedType | null, isConditional = false ): string => { - const optional = isConditional || (!this.config.avoidOptionals.field && Boolean(type) && !isNonNullType(type)); + const optional = isConditional || (!this.config.avoidOptionals.field && !!type && !isNonNullType(type)); return (this.config.immutableTypes ? `readonly ${name}` : name) + (optional ? '?' : ''); }; diff --git a/packages/presets/client/src/index.ts b/packages/presets/client/src/index.ts index f0b05b7260c..cc066919ca6 100644 --- a/packages/presets/client/src/index.ts +++ b/packages/presets/client/src/index.ts @@ -100,7 +100,6 @@ export const preset: Types.OutputPreset = { ); } - // eslint-disable-next-line no-implicit-coercion const isPersistedOperations = !!options.presetConfig?.persistedDocuments ?? false; const reexports: Array = []; diff --git a/packages/presets/graphql-modules/src/index.ts b/packages/presets/graphql-modules/src/index.ts index 21cd7671c95..0361d669380 100644 --- a/packages/presets/graphql-modules/src/index.ts +++ b/packages/presets/graphql-modules/src/index.ts @@ -91,7 +91,7 @@ export const preset: Types.OutputPreset = { schema: options.schema, documents: [], plugins: [ - ...options.plugins.filter(p => typeof p === 'object' && Boolean(p.add)), + ...options.plugins.filter(p => typeof p === 'object' && !!p.add), { 'graphql-modules-plugin': {}, }, diff --git a/website/src/components/live-demo/generate.ts b/website/src/components/live-demo/generate.ts index 9b64859a3a4..d206c229857 100644 --- a/website/src/components/live-demo/generate.ts +++ b/website/src/components/live-demo/generate.ts @@ -18,7 +18,7 @@ export async function generate(config: string, schema: string, documents?: strin const runConfigurations = []; for (const [filename, outputOptions] of Object.entries(generates)) { - const hasPreset = Boolean(outputOptions.preset); + const hasPreset = !!outputOptions.preset; const plugins = normalizeConfig(outputOptions.plugins || outputOptions); const outputConfig = outputOptions.config; const pluginMap = {}; diff --git a/website/src/pages/docs/getting-started/index.mdx b/website/src/pages/docs/getting-started/index.mdx index eb528b665c4..9a2706be0ea 100644 --- a/website/src/pages/docs/getting-started/index.mdx +++ b/website/src/pages/docs/getting-started/index.mdx @@ -477,7 +477,7 @@ import { createYoga, createSchema } from 'graphql-yoga' import { Resolvers } from './resolvers-types' const typeDefs = readFileSync('./schema.graphql', 'utf8') - + const resolvers: Resolvers = { Query: { // typed resolvers!