Skip to content

Commit

Permalink
chore(workspace): Update eslint and add missing rules (#3350)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored Aug 2, 2023
1 parent 15f12ae commit 344b544
Show file tree
Hide file tree
Showing 99 changed files with 1,088 additions and 1,057 deletions.
8 changes: 3 additions & 5 deletions exchanges/auth/src/authExchange.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Source } from 'wonka';
import {
Source,
pipe,
map,
filter,
Expand All @@ -10,10 +10,7 @@ import {
merge,
} from 'wonka';

import {
createRequest,
makeOperation,
makeErrorResult,
import type {
Operation,
OperationContext,
OperationResult,
Expand All @@ -23,6 +20,7 @@ import {
AnyVariables,
OperationInstance,
} from '@urql/core';
import { createRequest, makeOperation, makeErrorResult } from '@urql/core';

/** Utilities to use while refreshing authentication tokens. */
export interface AuthUtilities {
Expand Down
8 changes: 2 additions & 6 deletions exchanges/context/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
Exchange,
makeOperation,
Operation,
OperationContext,
} from '@urql/core';
import type { Exchange, Operation, OperationContext } from '@urql/core';
import { makeOperation } from '@urql/core';

import { fromPromise, fromValue, mergeMap, pipe } from 'wonka';

Expand Down
15 changes: 6 additions & 9 deletions exchanges/execute/src/execute.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { Source, pipe, filter, takeUntil, mergeMap, merge, make } from 'wonka';
import type { Source } from 'wonka';
import { pipe, filter, takeUntil, mergeMap, merge, make } from 'wonka';

import {
import type {
GraphQLSchema,
GraphQLFieldResolver,
GraphQLTypeResolver,
execute,
subscribe,
ExecutionArgs,
SubscriptionArgs,
Kind,
} from 'graphql';
import { execute, subscribe, Kind } from 'graphql';

import {
import type {
Exchange,
ExecutionResult,
makeResult,
makeErrorResult,
mergeResultPatch,
Operation,
OperationResult,
} from '@urql/core';
import { makeResult, makeErrorResult, mergeResultPatch } from '@urql/core';

/** Input parameters for the {@link executeExchange}.
* @see {@link ExecutionArgs} which this interface mirrors. */
Expand Down
4 changes: 2 additions & 2 deletions exchanges/graphcache/src/ast/node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
NamedTypeNode,
NameNode,
DirectiveNode,
Expand All @@ -8,7 +8,7 @@ import {
FragmentDefinitionNode,
} from '@0no-co/graphql.web';

import { FormattedNode } from '@urql/core';
import type { FormattedNode } from '@urql/core';

export type SelectionSet = readonly FormattedNode<SelectionNode>[];

Expand Down
6 changes: 3 additions & 3 deletions exchanges/graphcache/src/ast/schemaPredicates.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
import type {
InlineFragmentNode,
FragmentDefinitionNode,
} from '@0no-co/graphql.web';

import { warn, invariant } from '../helpers/help';
import { getTypeCondition } from './node';
import { SchemaIntrospector, SchemaObject } from './schema';
import type { SchemaIntrospector, SchemaObject } from './schema';

import {
import type {
KeyingConfig,
UpdatesConfig,
ResolverConfig,
Expand Down
9 changes: 4 additions & 5 deletions exchanges/graphcache/src/ast/traversal.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {
import type {
SelectionNode,
DocumentNode,
OperationDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
valueFromASTUntyped,
Kind,
} from '@0no-co/graphql.web';
import { valueFromASTUntyped, Kind } from '@0no-co/graphql.web';

import { FormattedNode } from '@urql/core';
import type { FormattedNode } from '@urql/core';
import { getName, getDirectives } from './node';
import { invariant } from '../helpers/help';
import { Fragments, Variables } from '../types';
import type { Fragments, Variables } from '../types';

function getMainOperation(
doc: FormattedNode<DocumentNode>
Expand Down
96 changes: 40 additions & 56 deletions exchanges/graphcache/src/ast/variables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ describe('normalizeVariables', () => {
it('normalizes variables', () => {
const input = { x: 42 };
const operation = getMainOperation(
formatDocument(
gql`
query ($x: Int!) {
field
}
`
)
formatDocument(gql`
query ($x: Int!) {
field
}
`)
);
const normalized = normalizeVariables(operation, input);
expect(normalized).toEqual({ x: 42 });
Expand All @@ -22,13 +20,11 @@ describe('normalizeVariables', () => {
it('normalizes variables with defaults', () => {
const input = { x: undefined };
const operation = getMainOperation(
formatDocument(
gql`
query ($x: Int! = 42) {
field
}
`
)
formatDocument(gql`
query ($x: Int! = 42) {
field
}
`)
);
const normalized = normalizeVariables(operation, input);
expect(normalized).toEqual({ x: 42 });
Expand All @@ -37,27 +33,23 @@ describe('normalizeVariables', () => {
it('normalizes variables even with missing fields', () => {
const input = { x: undefined };
const operation = getMainOperation(
formatDocument(
gql`
query ($x: Int!) {
field
}
`
)
formatDocument(gql`
query ($x: Int!) {
field
}
`)
);
const normalized = normalizeVariables(operation, input);
expect(normalized).toEqual({});
});

it('skips normalizing for queries without variables', () => {
const operation = getMainOperation(
formatDocument(
gql`
query {
field
}
`
)
formatDocument(gql`
query {
field
}
`)
);
(operation as any).variableDefinitions = undefined;
const normalized = normalizeVariables(operation, {});
Expand All @@ -66,13 +58,11 @@ describe('normalizeVariables', () => {

it('preserves missing variables', () => {
const operation = getMainOperation(
formatDocument(
gql`
query {
field
}
`
)
formatDocument(gql`
query {
field
}
`)
);
(operation as any).variableDefinitions = undefined;
const normalized = normalizeVariables(operation, { test: true });
Expand All @@ -83,13 +73,11 @@ describe('normalizeVariables', () => {
describe('filterVariables', () => {
it('returns undefined when no variables are defined', () => {
const operation = getMainOperation(
formatDocument(
gql`
query {
field
}
`
)
formatDocument(gql`
query {
field
}
`)
);
const vars = filterVariables(operation, { test: true });
expect(vars).toBe(undefined);
Expand All @@ -98,13 +86,11 @@ describe('filterVariables', () => {
it('filters out missing vars', () => {
const input = { x: true, y: false };
const operation = getMainOperation(
formatDocument(
gql`
query ($x: Int!) {
field
}
`
)
formatDocument(gql`
query ($x: Int!) {
field
}
`)
);
const vars = filterVariables(operation, input);
expect(vars).toEqual({ x: true });
Expand All @@ -113,13 +99,11 @@ describe('filterVariables', () => {
it('ignores defaults', () => {
const input = { x: undefined };
const operation = getMainOperation(
formatDocument(
gql`
query ($x: Int! = 42) {
field
}
`
)
formatDocument(gql`
query ($x: Int! = 42) {
field
}
`)
);
const vars = filterVariables(operation, input);
expect(vars).toEqual({ x: undefined });
Expand Down
6 changes: 3 additions & 3 deletions exchanges/graphcache/src/ast/variables.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
import type {
FieldNode,
DirectiveNode,
OperationDefinitionNode,
valueFromASTUntyped,
} from '@0no-co/graphql.web';
import { valueFromASTUntyped } from '@0no-co/graphql.web';

import { getName } from './node';

import { Variables } from '../types';
import type { Variables } from '../types';

/** Evaluates a fields arguments taking vars into account */
export const getFieldArguments = (
Expand Down
11 changes: 5 additions & 6 deletions exchanges/graphcache/src/cacheExchange.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
import type {
Exchange,
formatDocument,
makeOperation,
Operation,
OperationResult,
RequestPolicy,
CacheOutcome,
} from '@urql/core';
import { formatDocument, makeOperation } from '@urql/core';

import type { Source } from 'wonka';
import {
filter,
map,
Expand All @@ -17,15 +17,14 @@ import {
fromArray,
mergeMap,
empty,
Source,
} from 'wonka';

import { _query } from './operations/query';
import { _write } from './operations/write';
import { addMetadata, toRequestPolicy } from './helpers/operation';
import { filterVariables, getMainOperation } from './ast';
import { Store } from './store/store';
import { Data, Dependencies, CacheExchangeOpts } from './types';
import type { Data, Dependencies, CacheExchangeOpts } from './types';

import {
initDataState,
Expand Down Expand Up @@ -262,7 +261,7 @@ export const cacheExchange =
if (operation.kind === 'subscription' || result.hasNext)
reserveLayer(store.data, operation.key, true);

let queryDependencies: void | Dependencies;
let queryDependencies: undefined | Dependencies;
let data: Data | null = result.data;
if (data) {
// Write the result to cache and collect all dependencies that need to be
Expand Down
17 changes: 10 additions & 7 deletions exchanges/graphcache/src/default-storage/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { SerializedEntries, SerializedRequest, StorageAdapter } from '../types';
import type {
SerializedEntries,
SerializedRequest,
StorageAdapter,
} from '../types';

const getRequestPromise = <T>(request: IDBRequest<T>): Promise<T> => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -92,12 +96,11 @@ export const makeDefaultStorage = (opts?: StorageOptions): DefaultStorage => {

const deserializeBatch = (input: string) => {
const data = {};
let char = '',
key = '',
entry = '',
mode = 0,
index = 0;

let char = '';
let key = '';
let entry = '';
let mode = 0;
let index = 0;
while (index < input.length) {
entry = '';
while ((char = input[index++]) !== ':' && char) {
Expand Down
2 changes: 1 addition & 1 deletion exchanges/graphcache/src/extras/relayPagination.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringifyVariables } from '@urql/core';
import { Cache, Resolver, Variables, NullArray } from '../types';
import type { Cache, Resolver, Variables, NullArray } from '../types';

export type MergeMode = 'outwards' | 'inwards';

Expand Down
2 changes: 1 addition & 1 deletion exchanges/graphcache/src/extras/simplePagination.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringifyVariables } from '@urql/core';
import { Resolver, Variables, NullArray } from '../types';
import type { Resolver, Variables, NullArray } from '../types';

export type MergeMode = 'before' | 'after';

Expand Down
4 changes: 2 additions & 2 deletions exchanges/graphcache/src/helpers/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Every warning and error comes with a number that uniquely identifies them.
// You can read more about the messages themselves in `docs/graphcache/errors.md`

import {
Kind,
import type {
ExecutableDefinitionNode,
InlineFragmentNode,
} from '@0no-co/graphql.web';
import { Kind } from '@0no-co/graphql.web';

export type ErrorCode =
| 1
Expand Down
Loading

0 comments on commit 344b544

Please sign in to comment.