Skip to content

Commit

Permalink
style: format and fix linting issues (#8850)
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Jan 25, 2023
1 parent 6b1d852 commit 788a258
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PROJECTS = false;
const CI = Boolean(process.env.CI);
const CI = !!process.env.CI;

module.exports =
!PROJECTS || CI
Expand Down
2 changes: 1 addition & 1 deletion jest.project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
task: (ctx, task) => {
const generateTasks: ListrTask<Ctx>[] = Object.keys(generates).map(filename => {
const outputConfig = generates[filename];
const hasPreset = Boolean(outputConfig.preset);
const hasPreset = !!outputConfig.preset;

const title = `Generate to ${filename}`;

Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-codegen-cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function buildOptions() {
if (typeof watch === 'string' || Array.isArray(watch)) {
return watch;
}
return Boolean(watch);
return !!watch;
},
},
r: {
Expand Down Expand Up @@ -488,7 +488,7 @@ function addHashToDocumentFiles(documentFilesPromise: Promise<Types.DocumentFile
}

export function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean {
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : Boolean(config.emitLegacyCommonJSImports);
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : !!config.emitLegacyCommonJSImports;
// const outputConfig = config.generates[outputPath];

// if (!outputConfig) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/src/generate-and-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export async function generate(
}

function shouldOverwrite(config: Types.Config, outputPath: string): boolean {
const globalValue = config.overwrite === undefined ? true : Boolean(config.overwrite);
const globalValue = config.overwrite === undefined ? true : !!config.overwrite;
const outputConfig = config.generates[outputPath];

if (!outputConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class BaseDocumentsVisitor<
namespacedImportName: getConfigValue(rawConfig.namespacedImportName, null),
experimentalFragmentVariables: getConfigValue(rawConfig.experimentalFragmentVariables, false),
addTypename: !rawConfig.skipTypename,
globalNamespace: Boolean(rawConfig.globalNamespace),
globalNamespace: !!rawConfig.globalNamespace,
operationResultSuffix: getConfigValue(rawConfig.operationResultSuffix, ''),
scalars: buildScalarsFromConfig(_schema, rawConfig, defaultScalars),
...((additionalConfig || {}) as any),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export class BaseResolversVisitor<
const isRootType = this._rootTypeNames.has(typeName);
const isMapped = this.config.mappers[typeName];
const isScalar = this.config.scalars[typeName];
const hasDefaultMapper = Boolean(this.config.defaultMapper?.type);
const hasDefaultMapper = !!this.config.defaultMapper?.type;

if (isRootType) {
prev[typeName] = applyWrapper(this.config.rootValueType.type);
Expand Down Expand Up @@ -952,14 +952,10 @@ export class BaseResolversVisitor<
}

protected isMapperImported(groupedMappers: GroupedMappers, identifier: string, source: string): boolean {
const exists = !groupedMappers[source]
? false
: Boolean(groupedMappers[source].find(m => 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;
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ export class BaseTypesVisitor<
return null;
})
.reverse()
.find(a => Boolean(a));
.find(a => !!a);

return type || null;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/plugins/other/visitor-plugin-common/src/base-visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ export class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig
externalFragments: rawConfig.externalFragments || [],
fragmentImports: rawConfig.fragmentImports || [],
addTypename: !rawConfig.skipTypename,
nonOptionalTypename: Boolean(rawConfig.nonOptionalTypename),
useTypeImports: Boolean(rawConfig.useTypeImports),
dedupeFragments: Boolean(rawConfig.dedupeFragments),
allowEnumStringTypes: Boolean(rawConfig.allowEnumStringTypes),
nonOptionalTypename: !!rawConfig.nonOptionalTypename,
useTypeImports: !!rawConfig.useTypeImports,
dedupeFragments: !!rawConfig.dedupeFragments,
allowEnumStringTypes: !!rawConfig.allowEnumStringTypes,
inlineFragmentTypes: rawConfig.inlineFragmentTypes ?? 'inline',
emitLegacyCommonJSImports:
rawConfig.emitLegacyCommonJSImports === undefined ? true : Boolean(rawConfig.emitLegacyCommonJSImports),
rawConfig.emitLegacyCommonJSImports === undefined ? true : !!rawConfig.emitLegacyCommonJSImports,
...((additionalConfig || {}) as any),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class ClientSideBaseVisitor<
omitOperationSuffix: getConfigValue(rawConfig.omitOperationSuffix, false),
gqlImport: rawConfig.gqlImport || null,
documentNodeImport: rawConfig.documentNodeImport || null,
noExport: Boolean(rawConfig.noExport),
noExport: !!rawConfig.noExport,
importOperationTypesFrom: getConfigValue(rawConfig.importOperationTypesFrom, null),
operationResultSuffix: getConfigValue(rawConfig.operationResultSuffix, ''),
documentVariablePrefix: getConfigValue(rawConfig.documentVariablePrefix, ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ExternalParsedMapper {
}

export function isExternalMapperType(m: ParsedMapper): m is ExternalParsedMapper {
return Boolean((m as ExternalParsedMapper).import);
return !!(m as ExternalParsedMapper).import;
}

enum MapperKind {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/other/visitor-plugin-common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class DeclarationBlock {
}

withComment(comment: string | StringValueNode | null, disabled = false): DeclarationBlock {
const nonEmptyComment = Boolean(isStringValueNode(comment) ? comment.value : comment);
const nonEmptyComment = !!(isStringValueNode(comment) ? comment.value : comment);

if (nonEmptyComment && !disabled) {
this._comment = transformComment(comment, 0);
Expand Down Expand Up @@ -218,7 +218,7 @@ export class DeclarationBlock {
const blockWrapper = this._ignoreBlockWrapper ? '' : this._config.blockWrapper;
const before = '{' + blockWrapper;
const after = blockWrapper + '}';
const block = [before, this._block, after].filter(val => 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)})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class OperationVariablesToObject {
return null;
})
.reverse()
.find(a => Boolean(a));
.find(a => !!a);

return type || null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/typescript/operations/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? '?' : '');
};

Expand Down
1 change: 0 additions & 1 deletion packages/presets/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
);
}

// eslint-disable-next-line no-implicit-coercion
const isPersistedOperations = !!options.presetConfig?.persistedDocuments ?? false;

const reexports: Array<string> = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/presets/graphql-modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const preset: Types.OutputPreset<ModulesConfig> = {
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': {},
},
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/live-demo/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit 788a258

Please sign in to comment.