Skip to content

Commit

Permalink
Enable "sketchy-null-mixed" Flow check (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 21, 2019
1 parent c80e36d commit f01da1b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Expand Up @@ -13,7 +13,7 @@
sketchy-null-bool=off
sketchy-null-string=off
sketchy-null-number=error
sketchy-null-mixed=off
sketchy-null-mixed=error
sketchy-number=error
untyped-type-import=error
nonstrict-import=off
Expand Down
8 changes: 7 additions & 1 deletion src/error/GraphQLError.js
Expand Up @@ -138,7 +138,13 @@ export function GraphQLError( // eslint-disable-line no-redeclare
}, []);
}

const _extensions = extensions || (originalError && originalError.extensions);
let _extensions = extensions;
if (_extensions == null && originalError != null) {
const originalExtensions = originalError.extensions;
if (originalExtensions != null && typeof originalExtensions === 'object') {
_extensions = originalExtensions;
}
}

Object.defineProperties(this, {
message: {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/inspect.js
Expand Up @@ -41,7 +41,7 @@ function formatObjectValue(value, previouslySeenValues) {
if (value) {
const customInspectFn = getCustomFn(value);

if (customInspectFn) {
if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
const customValue = customInspectFn.call(value);

Expand Down
3 changes: 2 additions & 1 deletion src/jsutils/invariant.js
Expand Up @@ -8,8 +8,9 @@
*/

export default function invariant(condition: mixed, message: string) {
const booleanCondition = Boolean(condition);
/* istanbul ignore else */
if (!condition) {
if (!booleanCondition) {
throw new Error(message);
}
}
2 changes: 1 addition & 1 deletion src/language/__tests__/toJSONDeep.js
Expand Up @@ -12,7 +12,7 @@
* on any nested value which defines it.
*/
export default function toJSONDeep<T>(value: T): T {
if (!value || typeof value !== 'object') {
if (value == null || typeof value !== 'object') {
return value;
}

Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/visitor-test.js
Expand Up @@ -472,7 +472,7 @@ describe('Visitor', () => {
'enter',
node.kind,
key,
parent && parent.kind ? parent.kind : undefined,
parent && parent.kind != null ? parent.kind : undefined,
]);

checkVisitorFnArgs(ast, arguments);
Expand All @@ -484,7 +484,7 @@ describe('Visitor', () => {
'leave',
node.kind,
key,
parent && parent.kind ? parent.kind : undefined,
parent && parent.kind != null ? parent.kind : undefined,
]);

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

0 comments on commit f01da1b

Please sign in to comment.