Skip to content

Commit f01da1b

Browse files
Enable "sketchy-null-mixed" Flow check (#1880)
1 parent c80e36d commit f01da1b

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
sketchy-null-bool=off
1414
sketchy-null-string=off
1515
sketchy-null-number=error
16-
sketchy-null-mixed=off
16+
sketchy-null-mixed=error
1717
sketchy-number=error
1818
untyped-type-import=error
1919
nonstrict-import=off

src/error/GraphQLError.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ export function GraphQLError( // eslint-disable-line no-redeclare
138138
}, []);
139139
}
140140

141-
const _extensions = extensions || (originalError && originalError.extensions);
141+
let _extensions = extensions;
142+
if (_extensions == null && originalError != null) {
143+
const originalExtensions = originalError.extensions;
144+
if (originalExtensions != null && typeof originalExtensions === 'object') {
145+
_extensions = originalExtensions;
146+
}
147+
}
142148

143149
Object.defineProperties(this, {
144150
message: {

src/jsutils/inspect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function formatObjectValue(value, previouslySeenValues) {
4141
if (value) {
4242
const customInspectFn = getCustomFn(value);
4343

44-
if (customInspectFn) {
44+
if (customInspectFn !== undefined) {
4545
// $FlowFixMe(>=0.90.0)
4646
const customValue = customInspectFn.call(value);
4747

src/jsutils/invariant.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
export default function invariant(condition: mixed, message: string) {
11+
const booleanCondition = Boolean(condition);
1112
/* istanbul ignore else */
12-
if (!condition) {
13+
if (!booleanCondition) {
1314
throw new Error(message);
1415
}
1516
}

src/language/__tests__/toJSONDeep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* on any nested value which defines it.
1313
*/
1414
export default function toJSONDeep<T>(value: T): T {
15-
if (!value || typeof value !== 'object') {
15+
if (value == null || typeof value !== 'object') {
1616
return value;
1717
}
1818

src/language/__tests__/visitor-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ describe('Visitor', () => {
472472
'enter',
473473
node.kind,
474474
key,
475-
parent && parent.kind ? parent.kind : undefined,
475+
parent && parent.kind != null ? parent.kind : undefined,
476476
]);
477477

478478
checkVisitorFnArgs(ast, arguments);
@@ -484,7 +484,7 @@ describe('Visitor', () => {
484484
'leave',
485485
node.kind,
486486
key,
487-
parent && parent.kind ? parent.kind : undefined,
487+
parent && parent.kind != null ? parent.kind : undefined,
488488
]);
489489

490490
expect(argsStack.pop()).to.deep.equal([...arguments]);

0 commit comments

Comments
 (0)