diff --git a/.prettierrc b/.prettierrc index c06cd1fd079..c90e0affa19 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,6 @@ "printWidth": 80, "semi": true, "singleQuote": true, + "arrowParens": "avoid", "trailingComma": "all" } diff --git a/package.json b/package.json index 2daf2d2bb5e..d7d42a6a69e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@anansi/babel-preset": "^1.2.0", - "@anansi/eslint-plugin": "^0.8.6", + "@anansi/eslint-plugin": "^0.9.0", "@babel/cli": "^7.8.4", "@babel/core": "^7.9.0", "@commitlint/cli": "^8.3.5", @@ -63,7 +63,7 @@ "jest": "^25.1.0", "lerna": "^3.20.2", "nock": "^12.0.0", - "prettier": "^1.19.1", + "prettier": "^2.0.1", "react": "16.13.1", "react-dom": "16.13.1", "react-test-renderer": "^16.13.1", diff --git a/packages/legacy/src/__tests__/useStatefulResource.tsx b/packages/legacy/src/__tests__/useStatefulResource.tsx index 2bed383d1f2..96d143a69dc 100644 --- a/packages/legacy/src/__tests__/useStatefulResource.tsx +++ b/packages/legacy/src/__tests__/useStatefulResource.tsx @@ -1,6 +1,5 @@ import { CoolerArticleResource } from '__tests__/common'; import { makeRenderRestHook, makeCacheProvider } from '@rest-hooks/test'; - import nock from 'nock'; import { payload, users, nested } from './fixtures'; diff --git a/packages/legacy/src/index.ts b/packages/legacy/src/index.ts index fd88ce05236..76e4b80f958 100644 --- a/packages/legacy/src/index.ts +++ b/packages/legacy/src/index.ts @@ -6,7 +6,6 @@ import { useDenormalized, __INTERNAL__, } from 'rest-hooks'; - import { useContext } from 'react'; /** Ensure a resource is available; loading and error returned explicitly. */ diff --git a/packages/rest-hooks/src/react-integration/__tests__/hooks.tsx b/packages/rest-hooks/src/react-integration/__tests__/hooks.tsx index 92c26065bdb..f056601ba56 100644 --- a/packages/rest-hooks/src/react-integration/__tests__/hooks.tsx +++ b/packages/rest-hooks/src/react-integration/__tests__/hooks.tsx @@ -4,7 +4,6 @@ import { ArticleResourceWithOtherListUrl, StaticArticleResource, } from '__tests__/common'; - import React, { Suspense, useEffect } from 'react'; import { render } from '@testing-library/react'; import { renderHook } from '@testing-library/react-hooks'; @@ -367,10 +366,7 @@ describe('useRetrieve', () => { global.Date.now = jest.fn(() => time); nock.cleanAll(); const fetchMock = jest.fn(() => payload); - mynock - .get(`/article-cooler/${payload.id}`) - .reply(200, fetchMock) - .persist(); + mynock.get(`/article-cooler/${payload.id}`).reply(200, fetchMock).persist(); const results: any[] = [ { request: CoolerArticleResource.detailShape(), diff --git a/packages/rest-hooks/src/react-integration/__tests__/integration.tsx b/packages/rest-hooks/src/react-integration/__tests__/integration.tsx index 2c57bc07716..321a5ced38d 100644 --- a/packages/rest-hooks/src/react-integration/__tests__/integration.tsx +++ b/packages/rest-hooks/src/react-integration/__tests__/integration.tsx @@ -5,7 +5,6 @@ import { UserResource, ArticleResourceWithOtherListUrl, } from '__tests__/common'; - import React from 'react'; import nock from 'nock'; import { act } from '@testing-library/react-hooks'; diff --git a/packages/rest-hooks/src/react-integration/__tests__/useResource.tsx b/packages/rest-hooks/src/react-integration/__tests__/useResource.tsx index 5e760c31c28..8d1466dd7a5 100644 --- a/packages/rest-hooks/src/react-integration/__tests__/useResource.tsx +++ b/packages/rest-hooks/src/react-integration/__tests__/useResource.tsx @@ -133,10 +133,7 @@ describe('useResource()', () => { .get(`/article-cooler/${payload.id}`) .delay(1000) .reply(200, payload); - nock('http://test.com') - .get(`/user/`) - .delay(2000) - .reply(200, users); + nock('http://test.com').get(`/user/`).delay(2000).reply(200, users); function MultiResourceTester() { try { diff --git a/packages/rest-hooks/src/react-integration/hooks/useCache.ts b/packages/rest-hooks/src/react-integration/hooks/useCache.ts index e9cd20d410b..35b6097d5d0 100644 --- a/packages/rest-hooks/src/react-integration/hooks/useCache.ts +++ b/packages/rest-hooks/src/react-integration/hooks/useCache.ts @@ -1,7 +1,6 @@ import { StateContext } from 'rest-hooks/react-integration/context'; import { ReadShape, ParamsFromShape } from 'rest-hooks/resource'; import { useDenormalized } from 'rest-hooks/state/selectors'; - import { useContext } from 'react'; /** Access a resource if it is available. */ diff --git a/packages/rest-hooks/src/react-integration/provider/CacheProvider.tsx b/packages/rest-hooks/src/react-integration/provider/CacheProvider.tsx index 9bb8e6a071d..5d1c6f22abb 100644 --- a/packages/rest-hooks/src/react-integration/provider/CacheProvider.tsx +++ b/packages/rest-hooks/src/react-integration/provider/CacheProvider.tsx @@ -10,7 +10,6 @@ import SubscriptionManager from 'rest-hooks/state/SubscriptionManager'; import PollingSubscription from 'rest-hooks/state/PollingSubscription'; import { State, Manager } from 'rest-hooks/types'; import useEnhancedReducer from '@rest-hooks/use-enhanced-reducer'; - import React, { ReactNode, useEffect, useMemo } from 'react'; interface ProviderProps { diff --git a/packages/rest-hooks/src/react-integration/provider/__tests__/provider.tsx b/packages/rest-hooks/src/react-integration/provider/__tests__/provider.tsx index 544251466ca..2807e6ee9c4 100644 --- a/packages/rest-hooks/src/react-integration/provider/__tests__/provider.tsx +++ b/packages/rest-hooks/src/react-integration/provider/__tests__/provider.tsx @@ -1,6 +1,5 @@ import { CoolerArticleResource } from '__tests__/common'; import { RECEIVE_TYPE } from 'rest-hooks/actionTypes'; - import React, { useContext } from 'react'; import { act, render } from '@testing-library/react'; diff --git a/packages/rest-hooks/src/state/__tests__/merge.tsx b/packages/rest-hooks/src/state/__tests__/merge.tsx index 470f2552b9c..cc4f239c03f 100644 --- a/packages/rest-hooks/src/state/__tests__/merge.tsx +++ b/packages/rest-hooks/src/state/__tests__/merge.tsx @@ -85,8 +85,8 @@ describe('mergeDeepCopy()', () => { }); }); - describe('basics', function() { - it('should merge `source` into `object`', function() { + describe('basics', function () { + it('should merge `source` into `object`', function () { const names = { characters: [{ name: 'barney' }, { name: 'fred' }], }; @@ -105,7 +105,7 @@ describe('mergeDeepCopy()', () => { expect(mergeDeepCopy(names, ages)).toStrictEqual(expected); }); - it('should treat sparse array sources as dense', function() { + it('should treat sparse array sources as dense', function () { const array = [1]; array[3] = 3; @@ -121,18 +121,18 @@ describe('mergeDeepCopy()', () => { expect(actual).toStrictEqual(expected); }); - it('should assign `null` values', function() { + it('should assign `null` values', function () { const actual = mergeDeepCopy({ a: 1 }, { a: null }); expect(actual.a).toBe(null); }); - it('should assign non array/buffer/typed-array/plain-object source values directly', function() { + it('should assign non array/buffer/typed-array/plain-object source values directly', function () { class Foo {} const values = [true, new Date(), Foo, 5, '', new RegExp('')], expected = values.map(() => true); - const actual = values.map(function(value) { + const actual = values.map(function (value) { const object = mergeDeepCopy({}, { a: value, b: { c: value } }); return object.a === value && object.b.c === value; }); @@ -140,7 +140,7 @@ describe('mergeDeepCopy()', () => { expect(actual).toStrictEqual(expected); }); - it('should not augment source objects', function() { + it('should not augment source objects', function () { const source1 = { a: [{ a: 1 }] }, source2 = { a: [{ b: 2 }] }, actual = mergeDeepCopy(source1, source2); @@ -158,12 +158,12 @@ describe('mergeDeepCopy()', () => { expect(actualb.a).toStrictEqual([[3, 4, 3]]); }); - it('should not overwrite existing values with `undefined` values of object sources', function() { + it('should not overwrite existing values with `undefined` values of object sources', function () { const actual = mergeDeepCopy({ a: 1 }, { a: undefined, b: undefined }); expect(actual).toStrictEqual({ a: 1, b: undefined }); }); - it('should not overwrite existing values with `undefined` values of array sources', function() { + it('should not overwrite existing values with `undefined` values of array sources', function () { let array: any[] = [1]; array[2] = 3; diff --git a/packages/rest-hooks/src/state/selectors/__tests__/useDenormalized.ts b/packages/rest-hooks/src/state/selectors/__tests__/useDenormalized.ts index a445b3fd9df..475e0ae8e9b 100644 --- a/packages/rest-hooks/src/state/selectors/__tests__/useDenormalized.ts +++ b/packages/rest-hooks/src/state/selectors/__tests__/useDenormalized.ts @@ -7,7 +7,6 @@ import { } from '__tests__/common'; import { normalize, NormalizedIndex } from 'rest-hooks/resource'; import { initialState } from 'rest-hooks/state/reducer'; - import { renderHook, act } from '@testing-library/react-hooks'; import { useState } from 'react'; diff --git a/packages/rest-hooks/src/state/selectors/useDenormalized.ts b/packages/rest-hooks/src/state/selectors/useDenormalized.ts index dc8af566f5c..192d16efdfa 100644 --- a/packages/rest-hooks/src/state/selectors/useDenormalized.ts +++ b/packages/rest-hooks/src/state/selectors/useDenormalized.ts @@ -6,7 +6,6 @@ import { DenormalizeNullable, ParamsFromShape, } from 'rest-hooks/resource'; - import { useMemo } from 'react'; import buildInferredResults from './buildInferredResults'; diff --git a/packages/test/src/MockProvider.tsx b/packages/test/src/MockProvider.tsx index 7830df84a52..799f110530d 100644 --- a/packages/test/src/MockProvider.tsx +++ b/packages/test/src/MockProvider.tsx @@ -1,5 +1,4 @@ import { __INTERNAL__, ActionTypes } from 'rest-hooks'; - import React from 'react'; import mockState, { Fixture } from './mockState'; diff --git a/packages/test/src/makeRenderRestHook.tsx b/packages/test/src/makeRenderRestHook.tsx index 236febefdb9..7c69c5f6735 100644 --- a/packages/test/src/makeRenderRestHook.tsx +++ b/packages/test/src/makeRenderRestHook.tsx @@ -1,5 +1,4 @@ import { State, SubscriptionManager, Manager } from 'rest-hooks'; - import React from 'react'; import { renderHook, RenderHookOptions } from '@testing-library/react-hooks'; diff --git a/packages/test/src/managers.ts b/packages/test/src/managers.ts index 2d5fbf654ce..04bc730e0c2 100644 --- a/packages/test/src/managers.ts +++ b/packages/test/src/managers.ts @@ -5,7 +5,6 @@ import { Dispatch, PollingSubscription, } from 'rest-hooks'; - import { act } from '@testing-library/react-hooks'; export class MockNetworkManager extends NetworkManager { diff --git a/packages/test/src/providers.tsx b/packages/test/src/providers.tsx index df114ec24af..0c0b582c7a8 100644 --- a/packages/test/src/providers.tsx +++ b/packages/test/src/providers.tsx @@ -6,7 +6,6 @@ import { Manager, PromiseifyMiddleware, } from 'rest-hooks'; - import React from 'react'; // Extension of the DeepPartial type defined by Redux which handles unknown diff --git a/yarn.lock b/yarn.lock index 3dd13c8fc6b..dc13c952e0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -33,13 +33,13 @@ path "^0.12.7" stable "^0.1.8" -"@anansi/eslint-plugin@^0.8.6": - version "0.8.6" - resolved "https://registry.yarnpkg.com/@anansi/eslint-plugin/-/eslint-plugin-0.8.6.tgz#83c39b4b8601d55d4e9d8badc0c327260daf2f2f" - integrity sha512-ec+qUgzY8VvmzkaJQws/daRGDbpdsFIdLwUCdu22vf4b3l5kidWxwwcGrIwCdfnhgtiOwAZS2xcucV2hpV0lmw== +"@anansi/eslint-plugin@^0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@anansi/eslint-plugin/-/eslint-plugin-0.9.0.tgz#5eaf0a976afb1164baafecea6940168ca53fef3b" + integrity sha512-T9tGIgzPb1DXFv8imb9cJ0nSi+Z8HCTZ5ubMtTW2xmfGd232GqZ6TnCsZpSTnWvGjXhR8ZCnsMUOUa6li72ViA== dependencies: - "@typescript-eslint/eslint-plugin" "^2.23.0" - "@typescript-eslint/parser" "^2.23.0" + "@typescript-eslint/eslint-plugin" "^2.24.0" + "@typescript-eslint/parser" "^2.24.0" babel-eslint "^10.1.0" babel-plugin-root-import "^6.4.1" eslint-config-prettier "^6.10.0" @@ -52,7 +52,7 @@ eslint-plugin-prettier "^3.1.2" eslint-plugin-react "^7.19.0" eslint-plugin-react-hooks "^2.5.0" - prettier "^1.19.1" + prettier "^2.0.1" typescript "^3.7.5" "@babel/cli@^7.8.4": @@ -2649,7 +2649,7 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^2.23.0": +"@typescript-eslint/eslint-plugin@^2.24.0": version "2.24.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.24.0.tgz#a86cf618c965a462cddf3601f594544b134d6d68" integrity sha512-wJRBeaMeT7RLQ27UQkDFOu25MqFOBus8PtOa9KaT5ZuxC1kAsd7JEHqWt4YXuY9eancX0GK9C68i5OROnlIzBA== @@ -2669,7 +2669,7 @@ "@typescript-eslint/typescript-estree" "2.24.0" eslint-scope "^5.0.0" -"@typescript-eslint/parser@^2.23.0": +"@typescript-eslint/parser@^2.24.0": version "2.24.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.24.0.tgz#2cf0eae6e6dd44d162486ad949c126b887f11eb8" integrity sha512-H2Y7uacwSSg8IbVxdYExSI3T7uM1DzmOn2COGtCahCC3g8YtM1xYAPi2MAHyfPs61VKxP/J/UiSctcRgw4G8aw== @@ -8534,10 +8534,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.1.tgz#3f00ac71263be34684b2b2c8d7e7f63737592dac" + integrity sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA== pretty-format@^24.3.0: version "24.9.0"