Skip to content

Commit b1a39de

Browse files
Partly fix "sketchy-null-bool" Flow rule (#1881)
1 parent f01da1b commit b1a39de

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/execution/values.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ export function getArgumentValues(
146146
let isNull;
147147
if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {
148148
const variableName = argumentNode.value.name.value;
149-
hasValue = variableValues && hasOwnProperty(variableValues, variableName);
150-
isNull = variableValues && variableValues[variableName] === null;
149+
hasValue =
150+
variableValues != null && hasOwnProperty(variableValues, variableName);
151+
isNull = variableValues != null && variableValues[variableName] === null;
151152
} else {
152153
hasValue = argumentNode != null;
153-
isNull = argumentNode && argumentNode.value.kind === Kind.NULL;
154+
isNull = argumentNode != null && argumentNode.value.kind === Kind.NULL;
154155
}
155156

156157
if (!hasValue && argDef.defaultValue !== undefined) {

src/language/blockString.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function isBlank(str) {
8080
export function printBlockString(
8181
value: string,
8282
indentation?: string = '',
83-
preferMultipleLines?: ?boolean = false,
83+
preferMultipleLines?: boolean = false,
8484
): string {
8585
const isSingleLine = value.indexOf('\n') === -1;
8686
const hasLeadingSpace = value[0] === ' ' || value[0] === '\t';

src/validation/rules/VariablesInAllowedPosition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function allowedVariableUsage(
9797
): boolean {
9898
if (isNonNullType(locationType) && !isNonNullType(varType)) {
9999
const hasNonNullVariableDefaultValue =
100-
varDefaultValue && varDefaultValue.kind !== Kind.NULL;
100+
varDefaultValue != null && varDefaultValue.kind !== Kind.NULL;
101101
const hasLocationDefaultValue = locationDefaultValue !== undefined;
102102
if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
103103
return false;

0 commit comments

Comments
 (0)