Skip to content

Commit

Permalink
refactor: replace default exports with named exports (graphql#2916)
Browse files Browse the repository at this point in the history
Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
  • Loading branch information
IvanGoncharov and saihaj committed Feb 20, 2021
1 parent 6ba180a commit b24a232
Show file tree
Hide file tree
Showing 128 changed files with 257 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Expand Up @@ -136,7 +136,7 @@ rules:
import/max-dependencies: off
import/no-unassigned-import: error
import/no-named-default: error
import/no-default-export: off
import/no-default-export: error
import/no-named-export: off
import/no-anonymous-default-export: error
import/group-exports: off
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/__tests__/dedent-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import dedent from '../dedent';
import { dedent } from '../dedent';

describe('dedent', () => {
it('removes indentation in typical usage', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/__tests__/genFuzzStrings-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import genFuzzStrings from '../genFuzzStrings';
import { genFuzzStrings } from '../genFuzzStrings';

function expectFuzzStrings(options: {|
allowedChars: Array<string>,
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/__tests__/inspectStr-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import inspectStr from '../inspectStr';
import { inspectStr } from '../inspectStr';

describe('inspectStr', () => {
it('handles null and undefined values', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/__tests__/resolveOnNextTick-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import resolveOnNextTick from '../resolveOnNextTick';
import { resolveOnNextTick } from '../resolveOnNextTick';

describe('resolveOnNextTick', () => {
it('resolves promise on the next tick', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/dedent.js
Expand Up @@ -10,7 +10,7 @@
* `;
* str === "{\n test\n}\n";
*/
export default function dedent(
export function dedent(
strings: $ReadOnlyArray<string>,
...values: $ReadOnlyArray<string>
): string {
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/genFuzzStrings.js
@@ -1,7 +1,7 @@
/**
* Generator that produces all possible combinations of allowed characters.
*/
export default function* genFuzzStrings(options: {|
export function* genFuzzStrings(options: {|
allowedChars: Array<string>,
maxLength: number,
|}): Generator<string, void, void> {
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/inspectStr.js
@@ -1,7 +1,7 @@
/**
* Special inspect function to produce readable string literal for error messages in tests
*/
export default function inspectStr(str: ?string): string {
export function inspectStr(str: ?string): string {
if (str == null) {
return 'null';
}
Expand Down
4 changes: 1 addition & 3 deletions src/__testUtils__/kitchenSinkQuery.js
@@ -1,5 +1,5 @@
// $FlowFixMe[incompatible-call]
const kitchenSinkQuery: string = String.raw`
export const kitchenSinkQuery: string = String.raw`
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
whoever123is: node(id: [123, 456]) {
id
Expand Down Expand Up @@ -65,5 +65,3 @@ query {
__typename
}
`;

export default kitchenSinkQuery;
4 changes: 1 addition & 3 deletions src/__testUtils__/kitchenSinkSDL.js
@@ -1,4 +1,4 @@
const kitchenSinkSDL: string = `
export const kitchenSinkSDL: string = `
"""This is a description of the schema as a whole."""
schema {
query: QueryType
Expand Down Expand Up @@ -156,5 +156,3 @@ extend schema @onSchema {
subscription: SubscriptionType
}
`;

export default kitchenSinkSDL;
2 changes: 1 addition & 1 deletion src/__testUtils__/resolveOnNextTick.js
@@ -1,3 +1,3 @@
export default function resolveOnNextTick(): Promise<void> {
export function resolveOnNextTick(): Promise<void> {
return Promise.resolve(undefined);
}
2 changes: 1 addition & 1 deletion src/__tests__/starWarsSchema.js
@@ -1,4 +1,4 @@
import invariant from '../jsutils/invariant';
import { invariant } from '../jsutils/invariant';

import { GraphQLSchema } from '../type/schema';
import { GraphQLString } from '../type/scalars';
Expand Down
2 changes: 1 addition & 1 deletion src/error/GraphQLError.js
@@ -1,7 +1,7 @@
// FIXME:
// flowlint uninitialized-instance-property:off

import isObjectLike from '../jsutils/isObjectLike';
import { isObjectLike } from '../jsutils/isObjectLike';

import type { ASTNode } from '../language/ast';
import type { Source } from '../language/source';
Expand Down
4 changes: 2 additions & 2 deletions src/error/__tests__/GraphQLError-test.js
@@ -1,9 +1,9 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import dedent from '../../__testUtils__/dedent';
import { dedent } from '../../__testUtils__/dedent';

import invariant from '../../jsutils/invariant';
import { invariant } from '../../jsutils/invariant';

import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';
Expand Down
2 changes: 1 addition & 1 deletion src/error/formatError.js
@@ -1,4 +1,4 @@
import devAssert from '../jsutils/devAssert';
import { devAssert } from '../jsutils/devAssert';

import type { SourceLocation } from '../language/location';

Expand Down
2 changes: 1 addition & 1 deletion src/error/locatedError.js
@@ -1,4 +1,4 @@
import inspect from '../jsutils/inspect';
import { inspect } from '../jsutils/inspect';

import type { ASTNode } from '../language/ast';

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/executor-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import inspect from '../../jsutils/inspect';
import invariant from '../../jsutils/invariant';
import { inspect } from '../../jsutils/inspect';
import { invariant } from '../../jsutils/invariant';

import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/mutations-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import resolveOnNextTick from '../../__testUtils__/resolveOnNextTick';
import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick';

import { parse } from '../../language/parser';

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/union-interface-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import invariant from '../../jsutils/invariant';
import { invariant } from '../../jsutils/invariant';

import { parse } from '../../language/parser';

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/variables-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import inspect from '../../jsutils/inspect';
import invariant from '../../jsutils/invariant';
import { inspect } from '../../jsutils/inspect';
import { invariant } from '../../jsutils/invariant';

import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';
Expand Down
18 changes: 9 additions & 9 deletions src/execution/execute.js
@@ -1,15 +1,15 @@
import type { Path } from '../jsutils/Path';
import type { ObjMap } from '../jsutils/ObjMap';
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import inspect from '../jsutils/inspect';
import memoize3 from '../jsutils/memoize3';
import invariant from '../jsutils/invariant';
import devAssert from '../jsutils/devAssert';
import isPromise from '../jsutils/isPromise';
import isObjectLike from '../jsutils/isObjectLike';
import isCollection from '../jsutils/isCollection';
import promiseReduce from '../jsutils/promiseReduce';
import promiseForObject from '../jsutils/promiseForObject';
import { inspect } from '../jsutils/inspect';
import { memoize3 } from '../jsutils/memoize3';
import { invariant } from '../jsutils/invariant';
import { devAssert } from '../jsutils/devAssert';
import { isPromise } from '../jsutils/isPromise';
import { isObjectLike } from '../jsutils/isObjectLike';
import { isCollection } from '../jsutils/isCollection';
import { promiseReduce } from '../jsutils/promiseReduce';
import { promiseForObject } from '../jsutils/promiseForObject';
import { addPath, pathToArray } from '../jsutils/Path';

import type { GraphQLFormattedError } from '../error/formatError';
Expand Down
6 changes: 3 additions & 3 deletions src/execution/values.js
@@ -1,7 +1,7 @@
import type { ObjMap } from '../jsutils/ObjMap';
import keyMap from '../jsutils/keyMap';
import inspect from '../jsutils/inspect';
import printPathArray from '../jsutils/printPathArray';
import { keyMap } from '../jsutils/keyMap';
import { inspect } from '../jsutils/inspect';
import { printPathArray } from '../jsutils/printPathArray';

import { GraphQLError } from '../error/GraphQLError';

Expand Down
2 changes: 1 addition & 1 deletion src/graphql.js
@@ -1,5 +1,5 @@
import type { PromiseOrValue } from './jsutils/PromiseOrValue';
import isPromise from './jsutils/isPromise';
import { isPromise } from './jsutils/isPromise';

import type { Source } from './language/source';
import { parse } from './language/parser';
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/didYouMean-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import didYouMean from '../didYouMean';
import { didYouMean } from '../didYouMean';

describe('didYouMean', () => {
it('Does accept an empty list', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/identityFunc-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import identityFunc from '../identityFunc';
import { identityFunc } from '../identityFunc';

describe('identityFunc', () => {
it('returns the first argument it receives', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/jsutils/__tests__/inspect-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import inspect from '../inspect';
import invariant from '../invariant';
import { inspect } from '../inspect';
import { invariant } from '../invariant';

describe('inspect', () => {
it('undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/invariant-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import invariant from '../invariant';
import { invariant } from '../invariant';

describe('invariant', () => {
it('throws on false conditions', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/jsutils/__tests__/isAsyncIterable-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import identityFunc from '../identityFunc';
import isAsyncIterable from '../isAsyncIterable';
import { identityFunc } from '../identityFunc';
import { isAsyncIterable } from '../isAsyncIterable';

describe('isAsyncIterable', () => {
it('should return `true` for AsyncIterable', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/jsutils/__tests__/isCollection-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import identityFunc from '../identityFunc';
import isCollection from '../isCollection';
import { identityFunc } from '../identityFunc';
import { isCollection } from '../isCollection';

describe('isCollection', () => {
it('should return `true` for collections', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/jsutils/__tests__/isObjectLike-test.js
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import identityFunc from '../identityFunc';
import isObjectLike from '../isObjectLike';
import { identityFunc } from '../identityFunc';
import { isObjectLike } from '../isObjectLike';

describe('isObjectLike', () => {
it('should return `true` for objects', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/naturalCompare-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import naturalCompare from '../naturalCompare';
import { naturalCompare } from '../naturalCompare';

describe('naturalCompare', () => {
it('Handles empty strings', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/suggestionList-test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import suggestionList from '../suggestionList';
import { suggestionList } from '../suggestionList';

function expectSuggestions(input: string, options: Array<string>) {
return expect(suggestionList(input, options));
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/__tests__/toObjMap-test.js
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import { describe, it } from 'mocha';

import type { ObjMapLike } from '../ObjMap';
import toObjMap from '../toObjMap';
import { toObjMap } from '../toObjMap';

// Workaround to make both ESLint and Flow happy
const __proto__: string = '__proto__';
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/devAssert.js
@@ -1,4 +1,4 @@
export default function devAssert(condition: mixed, message: string): void {
export function devAssert(condition: mixed, message: string): void {
const booleanCondition = Boolean(condition);
// istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
if (!booleanCondition) {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/didYouMean.js
Expand Up @@ -11,7 +11,7 @@ declare function didYouMean(
): string;

// eslint-disable-next-line no-redeclare
export default function didYouMean(firstArg, secondArg) {
export function didYouMean(firstArg, secondArg) {
const [subMessage, suggestionsArg] =
typeof firstArg === 'string'
? [firstArg, secondArg]
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/identityFunc.js
@@ -1,6 +1,6 @@
/**
* Returns the first argument it receives.
*/
export default function identityFunc<T>(x: T): T {
export function identityFunc<T>(x: T): T {
return x;
}
2 changes: 1 addition & 1 deletion src/jsutils/inspect.js
Expand Up @@ -6,7 +6,7 @@ const MAX_RECURSIVE_DEPTH = 2;
/**
* Used to print values in error messages.
*/
export default function inspect(value: mixed): string {
export function inspect(value: mixed): string {
return formatValue(value, []);
}

Expand Down
1 change: 1 addition & 0 deletions src/jsutils/instanceOf.js
Expand Up @@ -9,6 +9,7 @@ declare function instanceOf(

// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
// See: https://webpack.js.org/guides/production/
// eslint-disable-next-line import/no-default-export
export default process.env.NODE_ENV === 'production'
? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
// eslint-disable-next-line no-shadow
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/invariant.js
@@ -1,4 +1,4 @@
export default function invariant(condition: mixed, message?: string): void {
export function invariant(condition: mixed, message?: string): void {
const booleanCondition = Boolean(condition);
// istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
if (!booleanCondition) {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/isAsyncIterable.js
Expand Up @@ -6,6 +6,6 @@ declare function isAsyncIterable(value: mixed): boolean %checks(value instanceof
AsyncIterable);

// eslint-disable-next-line no-redeclare
export default function isAsyncIterable(maybeAsyncIterable) {
export function isAsyncIterable(maybeAsyncIterable) {
return typeof maybeAsyncIterable?.[Symbol.asyncIterator] === 'function';
}
2 changes: 1 addition & 1 deletion src/jsutils/isCollection.js
Expand Up @@ -23,7 +23,7 @@ declare function isCollection(value: mixed): boolean %checks(value instanceof
Iterable);

// eslint-disable-next-line no-redeclare
export default function isCollection(obj) {
export function isCollection(obj) {
if (obj == null || typeof obj !== 'object') {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/isObjectLike.js
Expand Up @@ -2,6 +2,6 @@
* Return true if `value` is object-like. A value is object-like if it's not
* `null` and has a `typeof` result of "object".
*/
export default function isObjectLike(value: mixed): boolean %checks {
export function isObjectLike(value: mixed): boolean %checks {
return typeof value == 'object' && value !== null;
}

0 comments on commit b24a232

Please sign in to comment.