From 0124f049036735e2f08f41f4de83d6ceda058554 Mon Sep 17 00:00:00 2001 From: Chris Beer <chris@cbeer.info> Date: Thu, 17 Mar 2022 12:01:21 -0700 Subject: [PATCH] eslint expanded its default linelength --- .../mirador/invalid-api-response.test.js | 8 ++---- .../components/OpenSeadragonViewer.test.js | 16 +++-------- .../components/SearchPanelControls.test.js | 4 +-- __tests__/src/components/Window.test.js | 8 ++---- __tests__/src/sagas/windows.test.js | 18 ++++++++---- __tests__/src/selectors/canvases.test.js | 20 ++++--------- __tests__/src/selectors/searches.test.js | 12 ++------ src/components/AnnotationsOverlay.js | 8 ++---- src/components/Window.js | 7 +++-- src/containers/CanvasAnnotations.js | 4 +-- src/containers/SearchHit.js | 8 ++---- src/containers/WindowAuthenticationBar.js | 4 +-- src/lib/ThumbnailFactory.js | 28 ++++++++----------- src/lib/TruncatedHit.js | 8 ++---- src/state/createStore.js | 4 +-- src/state/sagas/iiif.js | 4 +-- src/state/sagas/windows.js | 12 ++------ src/state/selectors/searches.js | 8 ++---- 18 files changed, 61 insertions(+), 120 deletions(-) diff --git a/__tests__/integration/mirador/invalid-api-response.test.js b/__tests__/integration/mirador/invalid-api-response.test.js index 3bc9a2d41..d0edd9de1 100644 --- a/__tests__/integration/mirador/invalid-api-response.test.js +++ b/__tests__/integration/mirador/invalid-api-response.test.js @@ -25,12 +25,8 @@ describe('Mirador Invalid API Response Handler Test', () => { it('renders an error message when a manifest cannot be loaded (and allows it to be dismissed)', async () => { await fetchManifest('http://127.0.0.1:4488/__tests__/fixtures/version-2/broken'); - await expect(page).toMatchElement( - 'p', { text: 'The resource cannot be added:', timeout: 2000 }, - ); - await expect(page).toMatchElement( - 'p', { text: 'http://127.0.0.1:4488/__tests__/fixtures/version-2/broken' }, - ); + await expect(page).toMatchElement('p', { text: 'The resource cannot be added:', timeout: 2000 }); + await expect(page).toMatchElement('p', { text: 'http://127.0.0.1:4488/__tests__/fixtures/version-2/broken' }); await expect(page).toClick('button', { text: 'Dismiss' }); diff --git a/__tests__/src/components/OpenSeadragonViewer.test.js b/__tests__/src/components/OpenSeadragonViewer.test.js index 29566d2e6..1c957824c 100644 --- a/__tests__/src/components/OpenSeadragonViewer.test.js +++ b/__tests__/src/components/OpenSeadragonViewer.test.js @@ -270,12 +270,8 @@ describe('OpenSeadragonViewer', () => { it('calls the OSD viewport panTo and zoomTo with the component state', () => { wrapper.instance().componentDidMount(); - expect(panTo).toHaveBeenCalledWith( - { x: 1, y: 0, zoom: 0.5 }, true, - ); - expect(zoomTo).toHaveBeenCalledWith( - 0.5, { x: 1, y: 0, zoom: 0.5 }, true, - ); + expect(panTo).toHaveBeenCalledWith({ x: 1, y: 0, zoom: 0.5 }, true); + expect(zoomTo).toHaveBeenCalledWith(0.5, { x: 1, y: 0, zoom: 0.5 }, true); }); it('adds animation-start/finish flag for rerendering performance', () => { @@ -330,12 +326,8 @@ describe('OpenSeadragonViewer', () => { }, }); - expect(panTo).toHaveBeenCalledWith( - expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false, - ); - expect(zoomTo).toHaveBeenCalledWith( - 0.5, expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false, - ); + expect(panTo).toHaveBeenCalledWith(expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false); + expect(zoomTo).toHaveBeenCalledWith(0.5, expect.objectContaining({ x: 1, y: 0, zoom: 0.5 }), false); expect(setRotation).toHaveBeenCalledWith(90); expect(setFlip).toHaveBeenCalledWith(true); expect(forceRedraw).not.toHaveBeenCalled(); diff --git a/__tests__/src/components/SearchPanelControls.test.js b/__tests__/src/components/SearchPanelControls.test.js index d09f64123..64c57780c 100644 --- a/__tests__/src/components/SearchPanelControls.test.js +++ b/__tests__/src/components/SearchPanelControls.test.js @@ -36,9 +36,7 @@ describe('SearchPanelControls', () => { const value = 'somestring'; wrapper.find(Autocomplete).prop('onChange')({}, { match: value }, {}); expect(wrapper.state().search).toEqual(value); - expect(fetchSearch).toHaveBeenCalledWith( - 'window', 'cw', 'http://example.com/search?q=somestring', 'somestring', - ); + expect(fetchSearch).toHaveBeenCalledWith('window', 'cw', 'http://example.com/search?q=somestring', 'somestring'); }); it('renders a text input through the renderInput prop', () => { const wrapper = createWrapper(); diff --git a/__tests__/src/components/Window.test.js b/__tests__/src/components/Window.test.js index c16b361fe..78bd9f388 100644 --- a/__tests__/src/components/Window.test.js +++ b/__tests__/src/components/Window.test.js @@ -47,18 +47,14 @@ describe('Window', () => { describe('when workspaceType is mosaic', () => { xit('calls the context mosaicWindowActions connectDragSource method to make WindowTopBar draggable', () => { const connectDragSource = jest.fn(component => component); - wrapper = createWrapper( - { windowDraggable: true, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }, - ); + wrapper = createWrapper({ windowDraggable: true, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }); expect(wrapper.find(WindowTopBar)).toHaveLength(1); expect(connectDragSource).toHaveBeenCalled(); }); it('does not call the context mosaicWindowActions connectDragSource when the windowDraggable is set to false', () => { const connectDragSource = jest.fn(component => component); - wrapper = createWrapper( - { windowDraggable: false, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }, - ); + wrapper = createWrapper({ windowDraggable: false, workspaceType: 'mosaic' }, { mosaicWindowActions: { connectDragSource } }); expect(wrapper.find(WindowTopBar)).toHaveLength(1); expect(connectDragSource).not.toHaveBeenCalled(); }); diff --git a/__tests__/src/sagas/windows.test.js b/__tests__/src/sagas/windows.test.js index 796c0adc0..126a38162 100644 --- a/__tests__/src/sagas/windows.test.js +++ b/__tests__/src/sagas/windows.test.js @@ -218,8 +218,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), {}], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), {}], ]) .run() .then(({ allEffects }) => allEffects.length === 0); @@ -234,8 +236,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), { cwid: { } }], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), { cwid: { } }], [select(getAnnotationsBySearch, { canvasIds: ['a', 'b'], companionWindowIds: ['cwid'], windowId: 'abc123' }), { }], ]) @@ -256,8 +260,10 @@ describe('window-level sagas', () => { return expectSaga(setCurrentAnnotationsOnCurrentCanvas, action) .provide([ - [select(getSearchForWindow, - { windowId: 'abc123' }), { cwid: { } }], + [select( + getSearchForWindow, + { windowId: 'abc123' }, + ), { cwid: { } }], [select(getAnnotationsBySearch, { canvasIds: ['a', 'b'], companionWindowIds: ['cwid'], windowId: 'abc123' }), { cwid: ['annoId'] }], ]) diff --git a/__tests__/src/selectors/canvases.test.js b/__tests__/src/selectors/canvases.test.js index e8fc9adb8..43d1a0f73 100644 --- a/__tests__/src/selectors/canvases.test.js +++ b/__tests__/src/selectors/canvases.test.js @@ -355,9 +355,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasNonTiledResources( - state, { windowId: 'a' }, - )[0].id).toBe('http://iiif.io/api/presentation/2.0/example/fixtures/resources/page1-full.png'); + expect(getVisibleCanvasNonTiledResources(state, { windowId: 'a' })[0].id).toBe('http://iiif.io/api/presentation/2.0/example/fixtures/resources/page1-full.png'); }); it('works for v3 Presentation API', () => { const state = { @@ -376,9 +374,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasNonTiledResources( - state, { windowId: 'a' }, - )[0].id).toBe('http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png'); + expect(getVisibleCanvasNonTiledResources(state, { windowId: 'a' })[0].id).toBe('http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png'); }); describe('getVisibleCanvasVideoResources', () => { @@ -399,9 +395,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasVideoResources( - state, { windowId: 'a' }, - )[0].id).toBe('https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4'); + expect(getVisibleCanvasVideoResources(state, { windowId: 'a' })[0].id).toBe('https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4'); }); }); @@ -423,9 +417,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasCaptions( - state, { windowId: 'a' }, - )[0].id).toBe('https://example.com/file.vtt'); + expect(getVisibleCanvasCaptions(state, { windowId: 'a' })[0].id).toBe('https://example.com/file.vtt'); }); }); @@ -447,9 +439,7 @@ describe('getVisibleCanvasNonTiledResources', () => { }, }, }; - expect(getVisibleCanvasAudioResources( - state, { windowId: 'a' }, - )[0].id).toBe('https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4'); + expect(getVisibleCanvasAudioResources(state, { windowId: 'a' })[0].id).toBe('https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4'); }); }); }); diff --git a/__tests__/src/selectors/searches.test.js b/__tests__/src/selectors/searches.test.js index 3a9e3791a..378417caf 100644 --- a/__tests__/src/selectors/searches.test.js +++ b/__tests__/src/selectors/searches.test.js @@ -309,9 +309,7 @@ describe('getResourceAnnotationForSearchHit', () => { }; expect( - getResourceAnnotationForSearchHit( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ).resource['@id'], + getResourceAnnotationForSearchHit(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }).resource['@id'], ).toEqual(annoId); }); }); @@ -344,9 +342,7 @@ describe('getResourceAnnotationLabel', () => { }; expect( - getResourceAnnotationLabel( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ), + getResourceAnnotationLabel(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }), ).toEqual(['The Annotation Label']); }); @@ -369,9 +365,7 @@ describe('getResourceAnnotationLabel', () => { }; expect( - getResourceAnnotationLabel( - state, { annotationUri: annoId, companionWindowId, windowId: 'a' }, - ), + getResourceAnnotationLabel(state, { annotationUri: annoId, companionWindowId, windowId: 'a' }), ).toEqual([]); }); }); diff --git a/src/components/AnnotationsOverlay.js b/src/components/AnnotationsOverlay.js index eb527f1d9..56215888e 100644 --- a/src/components/AnnotationsOverlay.js +++ b/src/components/AnnotationsOverlay.js @@ -85,12 +85,8 @@ export class AnnotationsOverlay extends Component { this.initializeViewer(); - const annotationsUpdated = !AnnotationsOverlay.annotationsMatch( - annotations, prevProps.annotations, - ); - const searchAnnotationsUpdated = !AnnotationsOverlay.annotationsMatch( - searchAnnotations, prevProps.searchAnnotations, - ); + const annotationsUpdated = !AnnotationsOverlay.annotationsMatch(annotations, prevProps.annotations); + const searchAnnotationsUpdated = !AnnotationsOverlay.annotationsMatch(searchAnnotations, prevProps.searchAnnotations); const hoveredAnnotationsUpdated = ( xor(hoveredAnnotationIds, prevProps.hoveredAnnotationIds).length > 0 diff --git a/src/components/Window.js b/src/components/Window.js index 56d3bd45e..30462d2e7 100644 --- a/src/components/Window.js +++ b/src/components/Window.js @@ -83,8 +83,11 @@ export class Window extends Component { elevation={1} id={windowId} className={ - cn(classes.window, ns('window'), - maximized ? classes.maximized : null) + cn( + classes.window, + ns('window'), + maximized ? classes.maximized : null, + ) } aria-label={t('window', { label })} > diff --git a/src/containers/CanvasAnnotations.js b/src/containers/CanvasAnnotations.js index 7c9caa748..5bebeae78 100644 --- a/src/containers/CanvasAnnotations.js +++ b/src/containers/CanvasAnnotations.js @@ -28,9 +28,7 @@ function getIdAndContentOfResources(resources) { /** For connect */ const mapStateToProps = (state, { canvasId, windowId }) => ({ annotations: getIdAndContentOfResources( - getAnnotationResourcesByMotivationForCanvas( - state, { canvasId, windowId }, - ), + getAnnotationResourcesByMotivationForCanvas(state, { canvasId, windowId }), ), htmlSanitizationRuleSet: getConfig(state).annotations.htmlSanitizationRuleSet, label: getCanvasLabel(state, { diff --git a/src/containers/SearchHit.js b/src/containers/SearchHit.js index 9c535f5d5..c1da96397 100644 --- a/src/containers/SearchHit.js +++ b/src/containers/SearchHit.js @@ -23,12 +23,8 @@ const mapStateToProps = (state, { annotationId, hit = { annotations: [] }, companionWindowId, windowId, }) => { const realAnnoId = annotationId || hit.annotations[0]; - const hitAnnotation = getResourceAnnotationForSearchHit( - state, { annotationUri: realAnnoId, companionWindowId, windowId }, - ); - const annotationLabel = getResourceAnnotationLabel( - state, { annotationUri: realAnnoId, companionWindowId, windowId }, - ); + const hitAnnotation = getResourceAnnotationForSearchHit(state, { annotationUri: realAnnoId, companionWindowId, windowId }); + const annotationLabel = getResourceAnnotationLabel(state, { annotationUri: realAnnoId, companionWindowId, windowId }); const selectedCanvasIds = getVisibleCanvasIds(state, { windowId }); const selectedContentSearchAnnotationsIds = getSelectedContentSearchAnnotationIds(state, { diff --git a/src/containers/WindowAuthenticationBar.js b/src/containers/WindowAuthenticationBar.js index 3b42a93aa..f3b7f8733 100644 --- a/src/containers/WindowAuthenticationBar.js +++ b/src/containers/WindowAuthenticationBar.js @@ -13,9 +13,7 @@ import { WindowAuthenticationBar } from '../components/WindowAuthenticationBar'; const styles = theme => ({ buttonInvert: { '&:hover': { - backgroundColor: alpha( - theme.palette.secondary.contrastText, 1 - theme.palette.action.hoverOpacity, - ), + backgroundColor: alpha(theme.palette.secondary.contrastText, 1 - theme.palette.action.hoverOpacity), }, backgroundColor: theme.palette.secondary.contrastText, marginLeft: theme.spacing(5), diff --git a/src/lib/ThumbnailFactory.js b/src/lib/ThumbnailFactory.js index 79c063f88..988a422b0 100644 --- a/src/lib/ThumbnailFactory.js +++ b/src/lib/ThumbnailFactory.js @@ -90,27 +90,23 @@ class ThumbnailFactory { const imageFitness = (test) => test.width * test.height - targetArea; /** Look for the size that's just bigger than we prefer... */ - closestSize = sizes.reduce( - (best, test) => { - const score = imageFitness(test); + closestSize = sizes.reduce((best, test) => { + const score = imageFitness(test); - if (score < 0) return best; + if (score < 0) return best; - return Math.abs(score) < Math.abs(imageFitness(best)) - ? test - : best; - }, closestSize, - ); + return Math.abs(score) < Math.abs(imageFitness(best)) + ? test + : best; + }, closestSize); /** .... but not "too" big; we'd rather scale up an image than download too much */ if (closestSize.width * closestSize.height > targetArea * 6) { - closestSize = sizes.reduce( - (best, test) => ( - Math.abs(imageFitness(test)) < Math.abs(imageFitness(best)) - ? test - : best - ), closestSize, - ); + closestSize = sizes.reduce((best, test) => ( + Math.abs(imageFitness(test)) < Math.abs(imageFitness(best)) + ? test + : best + ), closestSize); } if (closestSize.default) return undefined; diff --git a/src/lib/TruncatedHit.js b/src/lib/TruncatedHit.js index f6363cf3a..8317b0984 100644 --- a/src/lib/TruncatedHit.js +++ b/src/lib/TruncatedHit.js @@ -25,16 +25,12 @@ export default class TruncatedHit { /** */ get before() { if (!this.hit.before) return ''; - return this.hit.before.substring( - this.hit.before.length - this.charsOnSide, this.hit.before.length, - ); + return this.hit.before.substring(this.hit.before.length - this.charsOnSide, this.hit.before.length); } /** */ get after() { if (!this.hit.after) return ''; - return this.hit.after.substring( - 0, Math.min(this.hit.after.length, this.charsOnSide), - ); + return this.hit.after.substring(0, Math.min(this.hit.after.length, this.charsOnSide)); } } diff --git a/src/state/createStore.js b/src/state/createStore.js index 717b0b891..9467f322c 100644 --- a/src/state/createStore.js +++ b/src/state/createStore.js @@ -27,9 +27,7 @@ function configureStore(pluginReducers, pluginSagas = []) { const store = createStore( rootReducer, composeWithDevTools( - applyMiddleware( - thunkMiddleware, sagaMiddleware, - ), + applyMiddleware(thunkMiddleware, sagaMiddleware), ), ); diff --git a/src/state/sagas/iiif.js b/src/state/sagas/iiif.js index 41823156b..bf34810fd 100644 --- a/src/state/sagas/iiif.js +++ b/src/state/sagas/iiif.js @@ -63,9 +63,7 @@ function* fetchIiifResourceWithAuth(url, iiifResource, options, { degraded, fail } } - const { error, json, response } = yield call( - fetchIiifResource, url, urlOptions, { failure: arg => arg, success: arg => arg }, - ); + const { error, json, response } = yield call(fetchIiifResource, url, urlOptions, { failure: arg => arg, success: arg => arg }); // Hard error either requesting the resource or deserializing the JSON. if (error) { diff --git a/src/state/sagas/windows.js b/src/state/sagas/windows.js index bc63cdcbb..ca256b1bc 100644 --- a/src/state/sagas/windows.js +++ b/src/state/sagas/windows.js @@ -94,9 +94,7 @@ export function* setWindowStartingCanvas(action) { const windowId = action.id || action.window.id; if (canvasId) { - const thunk = yield call( - setCanvas, windowId, canvasId, null, { preserveViewport: !!action.payload }, - ); + const thunk = yield call(setCanvas, windowId, canvasId, null, { preserveViewport: !!action.payload }); yield put(thunk); } else { const manifestoInstance = yield select(getManifestoInstance, { manifestId }); @@ -156,9 +154,7 @@ export function* setCurrentAnnotationsOnCurrentCanvas({ const companionWindowIds = Object.keys(searches || {}); if (companionWindowIds.length === 0) return; - const annotationBySearch = yield select( - getAnnotationsBySearch, { canvasIds: visibleCanvases, companionWindowIds, windowId }, - ); + const annotationBySearch = yield select(getAnnotationsBySearch, { canvasIds: visibleCanvases, companionWindowIds, windowId }); yield all( Object.keys(annotationBySearch) @@ -213,9 +209,7 @@ export function* setCanvasOfFirstSearchResult({ companionWindowId, windowId }) { if (selectedIds.length !== 0) return; - const annotations = yield select( - getSortedSearchAnnotationsForCompanionWindow, { companionWindowId, windowId }, - ); + const annotations = yield select(getSortedSearchAnnotationsForCompanionWindow, { companionWindowId, windowId }); if (!annotations || annotations.length === 0) return; yield put(selectAnnotation(windowId, annotations[0].id)); diff --git a/src/state/selectors/searches.js b/src/state/selectors/searches.js index 3e541084e..00656169c 100644 --- a/src/state/selectors/searches.js +++ b/src/state/selectors/searches.js @@ -108,9 +108,7 @@ export const getSortedSearchHitsForCompanionWindow = createSelector( [ getSearchHitsForCompanionWindow, getCanvases, - (state, { companionWindowId, windowId }) => annotationUri => getResourceAnnotationForSearchHit( - state, { annotationUri, companionWindowId, windowId }, - ), + (state, { companionWindowId, windowId }) => annotationUri => getResourceAnnotationForSearchHit(state, { annotationUri, companionWindowId, windowId }), ], (searchHits, canvases, annotationForSearchHit) => { if (!canvases || canvases.length === 0) return []; @@ -229,9 +227,7 @@ const getAnnotationById = createSelector( export const getCanvasForAnnotation = createSelector( [ getAnnotationById, - (state, { windowId }) => canvasId => getCanvas( - state, { canvasId, windowId }, - ), + (state, { windowId }) => canvasId => getCanvas(state, { canvasId, windowId }), ], (annotation, getCanvasById) => { const canvasId = annotation && annotation.targetId; -- GitLab