Skip to content

Commit cb7d547

Browse files
Use explicit comparisons instead of using Boolean constructor (#2173)
1 parent 43b7645 commit cb7d547

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

src/error/GraphQLError.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare
157157
// By being enumerable, JSON.stringify will include `locations` in the
158158
// resulting output. This ensures that the simplest possible GraphQL
159159
// service adheres to the spec.
160-
enumerable: Boolean(_locations),
160+
enumerable: _locations != null,
161161
},
162162
path: {
163163
// Coercing falsey values to undefined ensures they will not be included
@@ -166,7 +166,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare
166166
// By being enumerable, JSON.stringify will include `path` in the
167167
// resulting output. This ensures that the simplest possible GraphQL
168168
// service adheres to the spec.
169-
enumerable: Boolean(path),
169+
enumerable: path != null,
170170
},
171171
nodes: {
172172
value: _nodes || undefined,
@@ -187,7 +187,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare
187187
// By being enumerable, JSON.stringify will include `path` in the
188188
// resulting output. This ensures that the simplest possible GraphQL
189189
// service adheres to the spec.
190-
enumerable: Boolean(_extensions),
190+
enumerable: _extensions != null,
191191
},
192192
});
193193

src/jsutils/isPromise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ declare function isPromise(value: mixed): boolean %checks(value instanceof
99

1010
// eslint-disable-next-line no-redeclare
1111
export default function isPromise(value) {
12-
return Boolean(value && typeof value.then === 'function');
12+
return value != null && typeof value.then === 'function';
1313
}

src/language/visitor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export function visit(
346346
}
347347

348348
function isNode(maybeNode): boolean %checks {
349-
return Boolean(maybeNode && typeof maybeNode.kind === 'string');
349+
return maybeNode != null && typeof maybeNode.kind === 'string';
350350
}
351351

352352
/**

src/type/schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export class GraphQLSchema {
247247
this._possibleTypeMap[abstractType.name] = map;
248248
}
249249

250-
return Boolean(this._possibleTypeMap[abstractType.name][possibleType.name]);
250+
return this._possibleTypeMap[abstractType.name][possibleType.name] != null;
251251
}
252252

253253
getDirectives(): $ReadOnlyArray<GraphQLDirective> {

src/validation/rules/KnownTypeNames.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function KnownTypeNames(
4848
const typeName = node.name.value;
4949
if (!existingTypesMap[typeName] && !definedTypes[typeName]) {
5050
const definitionNode = ancestors[2] || parent;
51-
const isSDL = isSDLNode(definitionNode);
51+
const isSDL = definitionNode != null && isSDLNode(definitionNode);
5252
if (isSDL && isSpecifiedScalarName(typeName)) {
5353
return;
5454
}
@@ -73,10 +73,9 @@ function isSpecifiedScalarName(typeName) {
7373
return specifiedScalarsNames.indexOf(typeName) !== -1;
7474
}
7575

76-
function isSDLNode(value: ASTNode | $ReadOnlyArray<ASTNode> | void): boolean {
77-
return Boolean(
78-
value &&
79-
!Array.isArray(value) &&
80-
(isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value)),
76+
function isSDLNode(value: ASTNode | $ReadOnlyArray<ASTNode>): boolean {
77+
return (
78+
!Array.isArray(value) &&
79+
(isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value))
8180
);
8281
}

0 commit comments

Comments
 (0)