Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix global eslint runner

+88 -65
+3
CONTRIBUTING.md
··· 49 49 # Jest Tests for the current package: 50 50 yarn run test 51 51 52 + # Linting (prettier & eslint): 53 + yarn run lint 54 + 52 55 # Builds for the current package: 53 56 yarn run build 54 57
+1
exchanges/graphcache/package.json
··· 48 48 "test": "jest", 49 49 "clean": "rimraf dist extras", 50 50 "check": "tsc --noEmit", 51 + "lint": "eslint --ext=js,jsx,ts,tsx .", 51 52 "build": "rollup -c ../../scripts/rollup/config.js", 52 53 "prepare": "../../scripts/prepare/index.js", 53 54 "prepublishOnly": "run-s clean test build"
+1 -1
exchanges/graphcache/src/cacheExchange.ts
··· 305 305 const cacheOps$ = pipe( 306 306 cache$, 307 307 filter(res => res.outcome === 'miss'), 308 - map(res => addCacheOutcome(res.operation, res.outcome)), 308 + map(res => addCacheOutcome(res.operation, res.outcome)) 309 309 ); 310 310 311 311 // Resolve OperationResults that the cache was able to assemble completely and trigger
+1
exchanges/suspense/package.json
··· 33 33 "test": "jest", 34 34 "clean": "rimraf dist", 35 35 "check": "tsc --noEmit", 36 + "lint": "eslint --ext=js,jsx,ts,tsx .", 36 37 "build": "rollup -c ../../scripts/rollup/config.js", 37 38 "prepare": "../../scripts/prepare/index.js", 38 39 "prepublishOnly": "run-s clean test build"
+5 -12
exchanges/suspense/src/suspenseExchange.test.ts
··· 21 21 }); 22 22 23 23 it('logs a warning if suspense mode is not activated', () => { 24 - const warn = jest.spyOn(console, 'warn').mockImplementation(() => { /* noop */ }); 24 + const warn = jest.spyOn(console, 'warn').mockImplementation(() => { 25 + /* noop */ 26 + }); 25 27 const client = createClient({ url: 'https://example.com', suspense: false }); 26 28 const forward = jest.fn(() => fromArray([])); 27 29 const ops = fromArray([]); ··· 63 65 const resolveResult = jest.fn( 64 66 operation => ({ operation } as OperationResult) 65 67 ); 66 - const forward = ops => 67 - pipe( 68 - ops, 69 - map(resolveResult) 70 - ); 68 + const forward = ops => pipe(ops, map(resolveResult)); 71 69 const { source: ops, next: dispatch } = makeSubject<Operation>(); 72 70 73 71 pipe( ··· 97 95 const resolveResult = jest.fn( 98 96 operation => ({ operation } as OperationResult) 99 97 ); 100 - const forward = ops => 101 - pipe( 102 - ops, 103 - delay(1), 104 - map(resolveResult) 105 - ); 98 + const forward = ops => pipe(ops, delay(1), map(resolveResult)); 106 99 const { source: ops, next: dispatch } = makeSubject<Operation>(); 107 100 108 101 pipe(
+1 -1
package.json
··· 7 7 "scripts": { 8 8 "test": "jest", 9 9 "check": "tsc", 10 - "lint": "eslint .", 10 + "lint": "eslint --ext=js,jsx,ts,tsx .", 11 11 "build": "./scripts/rollup/build.js" 12 12 }, 13 13 "jest": {
+1
packages/core/package.json
··· 31 31 "test": "jest", 32 32 "clean": "rimraf dist", 33 33 "check": "tsc --noEmit", 34 + "lint": "eslint --ext=js,jsx,ts,tsx .", 34 35 "build": "rollup -c ../../scripts/rollup/config.js", 35 36 "prepare": "../../scripts/prepare/index.js", 36 37 "prepublishOnly": "run-s clean test build"
+8 -2
packages/core/src/client.ts
··· 36 36 PromisifiedSource, 37 37 } from './types'; 38 38 39 - import { createRequest, toSuspenseSource, withPromise, maskTypename } from './utils'; 39 + import { 40 + createRequest, 41 + toSuspenseSource, 42 + withPromise, 43 + maskTypename, 44 + } from './utils'; 45 + 40 46 import { DocumentNode } from 'graphql'; 41 47 42 48 /** Options for configuring the URQL [client]{@link Client}. */ ··· 198 204 map(res => { 199 205 res.data = maskTypename(res.data); 200 206 return res; 201 - }), 207 + }) 202 208 ); 203 209 } 204 210
+5 -1
packages/core/src/exchanges/cache.ts
··· 86 86 ), 87 87 ]), 88 88 map(op => addMetadata(op, { cacheOutcome: 'miss' })), 89 - filter(op => op.operationName !== 'query' || op.context.requestPolicy !== 'cache-only'), 89 + filter( 90 + op => 91 + op.operationName !== 'query' || 92 + op.context.requestPolicy !== 'cache-only' 93 + ), 90 94 forward, 91 95 tap(response => { 92 96 if (
+5 -3
packages/core/src/exchanges/subscription.ts
··· 93 93 complete(); 94 94 } 95 95 }, 96 - }) 96 + }); 97 97 }); 98 98 99 99 return () => { ··· 105 105 106 106 const isSubscriptionOperation = (operation: Operation): boolean => { 107 107 const { operationName } = operation; 108 - return operationName === 'subscription' || 108 + return ( 109 + operationName === 'subscription' || 109 110 (!!enableAllOperations && 110 - (operationName === 'query' || operationName === 'mutation')); 111 + (operationName === 'query' || operationName === 'mutation')) 112 + ); 111 113 }; 112 114 113 115 return ops$ => {
+16 -17
packages/core/src/utils/maskTypename.test.ts
··· 1 1 import { maskTypename } from './maskTypename'; 2 2 3 3 it('strips typename from flat objects', () => { 4 - expect( 5 - maskTypename({ __typename: 'Todo', id: 1 }) 6 - ).toEqual({ id: 1 }); 4 + expect(maskTypename({ __typename: 'Todo', id: 1 })).toEqual({ id: 1 }); 7 5 }); 8 6 9 7 it('strips typename from flat objects containing dates', () => { 10 8 const date = new Date(); 11 - expect( 12 - maskTypename({ __typename: 'Todo', id: 1, date }) 13 - ).toEqual({ id: 1, date }); 9 + expect(maskTypename({ __typename: 'Todo', id: 1, date })).toEqual({ 10 + id: 1, 11 + date, 12 + }); 14 13 }); 15 14 16 15 it('strips typename from nested objects', () => { ··· 20 19 id: 1, 21 20 author: { 22 21 id: 2, 23 - __typename: 'Author' 24 - } 22 + __typename: 'Author', 23 + }, 25 24 }) 26 25 ).toEqual({ id: 1, author: { id: 2 } }); 27 26 }); ··· 35 34 id: 2, 36 35 __typename: 'Author', 37 36 books: [ 38 - { id: 3, __typename: 'Book', review: { id: 8, __typename: 'Review' } }, 37 + { 38 + id: 3, 39 + __typename: 'Book', 40 + review: { id: 8, __typename: 'Review' }, 41 + }, 39 42 { id: 4, __typename: 'Book' }, 40 43 { id: 5, __typename: 'Book' }, 41 - ] 42 - } 44 + ], 45 + }, 43 46 }) 44 47 ).toEqual({ 45 48 id: 1, 46 49 author: { 47 50 id: 2, 48 - books: [ 49 - { id: 3, review: { id: 8 } }, 50 - { id: 4 }, 51 - { id: 5 }, 52 - ] 53 - } 51 + books: [{ id: 3, review: { id: 8 } }, { id: 4 }, { id: 5 }], 52 + }, 54 53 }); 55 54 });
+1 -1
packages/core/src/utils/maskTypename.ts
··· 18 18 19 19 return acc; 20 20 }, {}); 21 - } 21 + };
+1 -1
packages/core/src/utils/stringifyVariables.test.ts
··· 30 30 }); 31 31 32 32 it('stringifies date correctly', () => { 33 - const date =new Date('2019-12-11T04:20:00'); 33 + const date = new Date('2019-12-11T04:20:00'); 34 34 expect(stringifyVariables(date)).toBe(date.toJSON()); 35 35 });
+1 -5
packages/core/src/utils/withPromise.ts
··· 3 3 4 4 export function withPromise<T>(source$: Source<T>): PromisifiedSource<T> { 5 5 (source$ as PromisifiedSource<T>).toPromise = () => 6 - pipe( 7 - source$, 8 - take(1), 9 - toPromise 10 - ); 6 + pipe(source$, take(1), toPromise); 11 7 return source$ as PromisifiedSource<T>; 12 8 }
+1
packages/preact-urql/package.json
··· 33 33 "test": "jest", 34 34 "clean": "rimraf dist", 35 35 "check": "tsc --noEmit", 36 + "lint": "eslint --ext=js,jsx,ts,tsx .", 36 37 "build": "rollup -c ../../scripts/rollup/config.js", 37 38 "prepare": "../../scripts/prepare/index.js", 38 39 "prepublishOnly": "run-s clean test build"
+2
packages/preact-urql/src/hooks/useImmediateEffect.ts
··· 1 + /* eslint-disable react-hooks/exhaustive-deps */ 2 + 1 3 import { useRef, useEffect, EffectCallback } from 'preact/hooks'; 2 4 import { noop } from './useQuery'; 3 5
+3 -1
packages/preact-urql/src/hooks/useImmediateState.ts
··· 1 + /* eslint-disable react-hooks/exhaustive-deps */ 2 + 1 3 import { 2 4 useRef, 3 5 useState, ··· 29 31 setState(action); 30 32 } 31 33 }, 32 - [] 34 + [state] 33 35 ); 34 36 35 37 useIsomorphicLayoutEffect(() => {
+1 -1
packages/preact-urql/src/hooks/useMutation.ts
··· 46 46 return pipe( 47 47 client.executeMutation( 48 48 createRequest(query, variables as any), 49 - context || {}, 49 + context || {} 50 50 ), 51 51 toPromise 52 52 ).then(result => {
+8 -1
packages/preact-urql/src/hooks/useQuery.ts
··· 80 80 ); 81 81 unsubscribe.current = result.unsubscribe; 82 82 }, 83 - [setState, client, request, args.requestPolicy, args.pollInterval, args.context] 83 + [ 84 + setState, 85 + client, 86 + request, 87 + args.requestPolicy, 88 + args.pollInterval, 89 + args.context, 90 + ] 84 91 ); 85 92 86 93 useImmediateEffect(() => {
+1
packages/react-urql/package.json
··· 34 34 "test": "jest", 35 35 "clean": "rimraf dist", 36 36 "check": "tsc --noEmit", 37 + "lint": "eslint --ext=js,jsx,ts,tsx .", 37 38 "build": "rollup -c ../../scripts/rollup/config.js", 38 39 "prepare": "../../scripts/prepare/index.js", 39 40 "prepublishOnly": "run-s clean test build"
+2
packages/react-urql/src/components/Mutation.test.tsx
··· 1 + /* eslint-disable react-hooks/rules-of-hooks */ 2 + 1 3 jest.mock('../context', () => { 2 4 // eslint-disable-next-line @typescript-eslint/no-var-requires 3 5 const { delay, fromValue, pipe } = require('wonka');
+3 -4
packages/react-urql/src/hooks/useMutation.test.tsx
··· 1 + /* eslint-disable react-hooks/rules-of-hooks */ 2 + 1 3 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011 2 4 jest.mock('../context', () => { 3 5 // eslint-disable-next-line @typescript-eslint/no-var-requires 4 6 const { delay, fromValue, pipe } = require('wonka'); 5 7 const mock = { 6 8 executeMutation: jest.fn(() => 7 - pipe( 8 - fromValue({ data: 1, error: 2, extensions: { i: 1 } }), 9 - delay(200) 10 - ) 9 + pipe(fromValue({ data: 1, error: 2, extensions: { i: 1 } }), delay(200)) 11 10 ), 12 11 }; 13 12
+1 -1
packages/react-urql/src/hooks/useMutation.ts
··· 42 42 return pipe( 43 43 client.executeMutation( 44 44 createRequest(query, variables as any), 45 - context || {}, 45 + context || {} 46 46 ), 47 47 toPromise 48 48 ).then(result => {
+3 -1
packages/react-urql/src/hooks/useQuery.spec.ts
··· 1 + /* eslint-disable react-hooks/rules-of-hooks */ 2 + 1 3 import { renderHook, act } from '@testing-library/react-hooks'; 2 4 import { interval, map, pipe } from 'wonka'; 3 5 import { RequestPolicy } from '@urql/core'; ··· 16 18 }; 17 19 18 20 return { 19 - useClient: () => mock 21 + useClient: () => mock, 20 22 }; 21 23 }); 22 24
+2
packages/react-urql/src/hooks/useQuery.test.tsx
··· 1 + /* eslint-disable react-hooks/rules-of-hooks */ 2 + 1 3 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011 2 4 jest.mock('../context', () => { 3 5 // eslint-disable-next-line @typescript-eslint/no-var-requires
+2
packages/react-urql/src/hooks/useSubscription.test.tsx
··· 1 + /* eslint-disable react-hooks/rules-of-hooks */ 2 + 1 3 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011 2 4 jest.mock('../context', () => { 3 5 const d = { data: 1234, error: 5678 };
+3 -9
packages/react-urql/src/test-utils/ssr.test.tsx
··· 12 12 OperationContext, 13 13 GraphQLRequest, 14 14 Operation, 15 - OperationResult 15 + OperationResult, 16 16 } from '@urql/core'; 17 17 18 18 import { Provider } from '../context'; ··· 96 96 let promise; 97 97 98 98 try { 99 - pipe( 100 - client.executeRequestOperation(queryOperation), 101 - publish 102 - ); 99 + pipe(client.executeRequestOperation(queryOperation), publish); 103 100 } catch (error) { 104 101 promise = error; 105 102 } ··· 155 152 ssr.restoreData({ [queryOperation.key]: queryResponse }); 156 153 157 154 expect(() => { 158 - pipe( 159 - client.executeRequestOperation(queryOperation), 160 - publish 161 - ); 155 + pipe(client.executeRequestOperation(queryOperation), publish); 162 156 }).not.toThrow(); 163 157 164 158 const data = ssr.extractData();
+1
packages/site/package.json
··· 6 6 "scripts": { 7 7 "start": "react-static start", 8 8 "build": "react-static build", 9 + "lint": "eslint --ext=js,jsx .", 9 10 "clean": "rimraf dist", 10 11 "prepublishOnly": "run-s clean build" 11 12 },
+1
packages/svelte-urql/package.json
··· 34 34 "test": "jest", 35 35 "clean": "rimraf dist", 36 36 "check": "tsc --noEmit", 37 + "lint": "eslint --ext=js,jsx,ts,tsx .", 37 38 "build": "rollup -c ../../scripts/rollup/config.js", 38 39 "prepare": "../../scripts/prepare/index.js", 39 40 "prepublishOnly": "run-s clean test build"
+3 -3
packages/svelte-urql/src/createClient.ts
··· 1 - import { createClient, ClientOptions, Client } from '@urql/core'; 1 + import { createClient, ClientOptions, Client } from '@urql/core'; 2 2 import { setClient } from './context/setClient'; 3 3 4 4 export const createSvelteClient = (args: ClientOptions): Client => { 5 - const client = createClient(args) 5 + const client = createClient(args); 6 6 setClient(client); 7 7 return client; 8 - } 8 + };
+1
scripts/eslint/preset.js
··· 36 36 '@typescript-eslint/no-object-literal-type-assertion': 'off', 37 37 '@typescript-eslint/explicit-function-return-type': 'off', 38 38 '@typescript-eslint/interface-name-prefix': 'off', 39 + '@typescript-eslint/no-non-null-assertion': 'off', 39 40 '@typescript-eslint/no-explicit-any': 'off', 40 41 '@typescript-eslint/array-type': 'off', 41 42 'react-hooks/rules-of-hooks': 'error',