Skip to content

Commit 64ddd90

Browse files
committed
Fix many linting issues
1 parent 4d31a4c commit 64ddd90

16 files changed

+55
-66
lines changed

__tests__/components/MiradorTextOverlay.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('MiradorTextOverlay', () => {
125125
} = renderOverlay({ pageTexts });
126126
viewer.handlers['update-viewport']();
127127
const overlays = Array.of(...viewer.canvas.querySelectorAll('div > svg:first-of-type')).map(
128-
(e) => e.parentElement
128+
(e) => e.parentElement,
129129
);
130130
expect(overlays[0]).toHaveStyle({
131131
transform: 'translate(52.95000000000001px, 72.9px) scale(1.33)',

__tests__/components/OverlaySettings.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const mockTheme = {
2222

2323
// Mocked MUI slider for easier testing, taken from
2424
// https://stackoverflow.com/a/61628815 (CC BY-SA 4.0)
25-
jest.mock('@material-ui/core/Slider', () => (props) => {
25+
jest.mock('@material-ui/core/Slider', () => function(props) {
2626
const { id, name, min, max, onChange } = props;
2727
return (
2828
<input
@@ -67,7 +67,7 @@ function renderSettings(props = {}, renderFn = render) {
6767
{...props}
6868
windowTextOverlayOptions={options}
6969
/>
70-
</ThemeProvider>
70+
</ThemeProvider>,
7171
);
7272
return { rerender, options, updateOptionsMock };
7373
}
@@ -209,7 +209,7 @@ describe('TextOverlaySettingsBubble', () => {
209209
it('should be positioned lower if mirador-image-tools is enabled', () => {
210210
renderSettings({ imageToolsEnabled: true });
211211
expect(
212-
screen.getByLabelText('expandTextOverlayOptions').parentElement.parentElement
212+
screen.getByLabelText('expandTextOverlayOptions').parentElement.parentElement,
213213
).toHaveStyle('top: 66px');
214214
});
215215

__tests__/components/PageTextDisplay.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,24 @@ describe('PageTextDisplay', () => {
6666
renderPage({ visible: false });
6767
expect(screen.getByText(svgTextMatcher('a firstWord on a line'))).toHaveAttribute(
6868
'style',
69-
'fill: rgba(0, 0, 0, 0);'
69+
'fill: rgba(0, 0, 0, 0);',
7070
);
7171
expect(screen.getByText(svgTextMatcher('another secondWord on another line'))).toHaveAttribute(
7272
'style',
73-
'fill: rgba(0, 0, 0, 0);'
73+
'fill: rgba(0, 0, 0, 0);',
7474
);
7575
});
7676

7777
it('should not re-render by itself when the opacity changes', () => {
7878
const { rerender } = renderPage();
7979
expect(screen.getByText(svgTextMatcher('a firstWord on a line'))).toHaveAttribute(
8080
'style',
81-
'fill: rgba(0, 0, 0, 0.75);'
81+
'fill: rgba(0, 0, 0, 0.75);',
8282
);
8383
renderPage({ opacity: 0.25 }, rerender);
8484
expect(screen.getByText(svgTextMatcher('a firstWord on a line'))).toHaveAttribute(
8585
'style',
86-
'fill: rgba(0, 0, 0, 0.75);'
86+
'fill: rgba(0, 0, 0, 0.75);',
8787
);
8888
});
8989

@@ -92,11 +92,11 @@ describe('PageTextDisplay', () => {
9292
expect(screen.getByText(svgTextMatcher('a firstWord on a line'))).not.toBeNull();
9393
renderPage(
9494
{ source: 'http://example.com/pages/2', lines: lineFixtures.withoutSpans, opacity: 0.25 },
95-
rerender
95+
rerender,
9696
);
9797
expect(screen.getByText('a word on a line')).toHaveAttribute(
9898
'style',
99-
'fill: rgba(0, 0, 0, 0.25);'
99+
'fill: rgba(0, 0, 0, 0.25);',
100100
);
101101
});
102102

__tests__/lib/ocrFormats.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import contentAsTextAnnos from '../../__fixtures__/anno_iifv2.json';
1111
* https://stackoverflow.com/a/53464807 (CC-BY-SA)
1212
*/
1313
const closeTo = (expected, precision = 1) => ({
14-
asymmetricMatch: (actual) => Math.abs(expected - actual) < Math.pow(10, -precision) / 2,
14+
asymmetricMatch: (actual) => Math.abs(expected - actual) < 10 ** -precision / 2,
1515
});
1616

1717
describe('parsing ALTO', () => {
@@ -49,7 +49,7 @@ describe('parsing ALTO', () => {
4949

5050
it('should convert style nodes to proper CSS', () => {
5151
expect(parsed.lines[96].spans[16].style).toBe(
52-
'font-family: Times New Roman;font-style: italic'
52+
'font-family: Times New Roman;font-style: italic',
5353
);
5454
});
5555
});

__tests__/state/sagas.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe('Fetching external annotation sources', () => {
222222
.put(
223223
receiveAnnotation(targetId, annotationId, {
224224
resources: [{ resource: simpleExternalContent }],
225-
})
225+
}),
226226
)
227227
.run());
228228

@@ -245,7 +245,7 @@ describe('Fetching external annotation sources', () => {
245245
},
246246
},
247247
],
248-
})
248+
}),
249249
)
250250
.run());
251251

src/components/MiradorTextOverlay.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ class MiradorTextOverlay extends Component {
2929

3030
/** Register OpenSeadragon callback when viewport changes */
3131
componentDidUpdate(prevProps) {
32-
const {
33-
enabled,
34-
viewer,
35-
pageTexts,
36-
textColor,
37-
bgColor,
38-
useAutoColors,
39-
visible,
40-
selectable,
41-
} = this.props;
32+
const { enabled, viewer, pageTexts, textColor, bgColor, useAutoColors, visible, selectable } =
33+
this.props;
4234
let { opacity } = this.props;
4335

4436
this.patchAnnotationOverlay();
@@ -152,7 +144,7 @@ class MiradorTextOverlay extends Component {
152144
this.renderRefs[itemNo].current.updateTransforms(
153145
img.viewportToImageZoom(viewportZoom),
154146
vpBounds.x * canvasWorldScale - canvasWorldOffset,
155-
vpBounds.y * canvasWorldScale
147+
vpBounds.y * canvasWorldScale,
156148
);
157149
}
158150
}
@@ -272,7 +264,7 @@ class MiradorTextOverlay extends Component {
272264
);
273265
})}
274266
</div>,
275-
viewer.canvas
267+
viewer.canvas,
276268
);
277269
}
278270
}

src/components/PageTextDisplay.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,22 @@ class PageTextDisplay extends React.Component {
172172
* how to render lines and spans, sorry :-/ */
173173
const isGecko = runningInGecko();
174174
// eslint-disable-next-line require-jsdoc
175-
let LineWrapper = ({ children }) => <text style={textStyle}>{children}</text>;
175+
function LineWrapper({ children }) {
176+
return <text style={textStyle}>{children}</text>;
177+
}
176178
// eslint-disable-next-line react/jsx-props-no-spreading, require-jsdoc
177-
let SpanElem = (props) => <tspan {...props} />;
179+
function SpanElem(props) {
180+
return <tspan {...props} />;
181+
}
178182
if (isGecko) {
179183
// NOTE: Gecko really works best with a flattened bunch of text nodes. Wrapping the
180184
// lines in a <g>, e.g. breaks text selection in similar ways to the below
181185
// WebKit-specific note, for some reason ¯\_(ツ)_/¯
182186
LineWrapper = React.Fragment;
183187
// eslint-disable-next-line react/jsx-props-no-spreading, require-jsdoc
184-
SpanElem = (props) => <text style={textStyle} {...props} />;
188+
SpanElem = function (props) {
189+
return <text style={textStyle} {...props} />;
190+
};
185191
}
186192
return (
187193
<div ref={this.containerRef} style={containerStyle}>
@@ -244,7 +250,7 @@ class PageTextDisplay extends React.Component {
244250
>
245251
{line.text}
246252
</text>
247-
)
253+
),
248254
)}
249255
</g>
250256
</svg>

src/components/settings/ButtonContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ const useStyles = makeStyles(({ palette, breakpoints }) => {
3434
});
3535

3636
/** Container for a settings button */
37-
const ButtonContainer = ({ children, withBorder, paddingPrev, paddingNext }) => {
37+
function ButtonContainer({ children, withBorder, paddingPrev, paddingNext }) {
3838
const classes = useStyles({ withBorder, paddingPrev, paddingNext });
3939
return <div className={classes.root}>{children}</div>;
40-
};
40+
}
4141
ButtonContainer.propTypes = {
4242
children: PropTypes.node.isRequired,
4343
withBorder: PropTypes.bool,

src/components/settings/ColorInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useStyles = makeStyles({
3737
});
3838

3939
/** Input to select a color */
40-
const ColorInput = ({ color, onChange, title, autoColors, className }) => {
40+
function ColorInput({ color, onChange, title, autoColors, className }) {
4141
const classes = useStyles({ color, autoColors });
4242
// We rely on the browser behavior that clicking on an input's label is equivalent
4343
// to clicking the input to show a custom color picker button.
@@ -65,7 +65,7 @@ const ColorInput = ({ color, onChange, title, autoColors, className }) => {
6565
/>
6666
</label>
6767
);
68-
};
68+
}
6969
ColorInput.propTypes = {
7070
className: PropTypes.string,
7171
color: PropTypes.string.isRequired,

src/components/settings/ColorWidget.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => {
5757
});
5858

5959
/** Widget to update text and background color */
60-
const ColorWidget = ({
61-
textColor,
62-
bgColor,
63-
onChange,
64-
t,
65-
pageColors,
66-
useAutoColors,
67-
containerId,
68-
}) => {
60+
function ColorWidget({ textColor, bgColor, onChange, t, pageColors, useAutoColors, containerId }) {
6961
const showResetButton =
7062
!useAutoColors && pageColors && pageColors.some((c) => c && (c.textColor || c.bgColor));
7163
const classes = useStyles({ showResetButton });
@@ -118,7 +110,7 @@ const ColorWidget = ({
118110
/>
119111
</div>
120112
);
121-
};
113+
}
122114
ColorWidget.propTypes = {
123115
containerId: PropTypes.string.isRequired,
124116
textColor: PropTypes.string.isRequired,
@@ -130,7 +122,7 @@ ColorWidget.propTypes = {
130122
PropTypes.shape({
131123
textColor: PropTypes.string,
132124
bgColor: PropTypes.string,
133-
})
125+
}),
134126
).isRequired,
135127
};
136128

src/components/settings/OpacityWidget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => {
3333
});
3434

3535
/** Widget to control the opacity of the displayed text */
36-
const OpacityWidget = ({ opacity, onChange, t }) => {
36+
function OpacityWidget({ opacity, onChange, t }) {
3737
const classes = useStyles();
3838
const theme = useTheme();
3939
const isSmallDisplay = useMediaQuery(theme.breakpoints.down('sm'));
@@ -54,7 +54,7 @@ const OpacityWidget = ({ opacity, onChange, t }) => {
5454
/>
5555
</div>
5656
);
57-
};
57+
}
5858
OpacityWidget.propTypes = {
5959
opacity: PropTypes.number.isRequired,
6060
onChange: PropTypes.func.isRequired,

src/components/settings/OverlaySettings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => {
4646
});
4747

4848
/** Control text overlay settings */
49-
const OverlaySettings = ({
49+
function OverlaySettings({
5050
windowTextOverlayOptions,
5151
imageToolsEnabled,
5252
textsAvailable,
@@ -55,7 +55,7 @@ const OverlaySettings = ({
5555
t,
5656
pageColors,
5757
containerId,
58-
}) => {
58+
}) {
5959
const {
6060
enabled,
6161
visible,
@@ -221,7 +221,7 @@ const OverlaySettings = ({
221221
{!isSmallDisplay && toggleButton}
222222
</div>
223223
);
224-
};
224+
}
225225

226226
OverlaySettings.propTypes = {
227227
containerId: PropTypes.string.isRequired,
@@ -236,7 +236,7 @@ OverlaySettings.propTypes = {
236236
PropTypes.shape({
237237
textColor: PropTypes.string,
238238
bgColor: PropTypes.string,
239-
})
239+
}),
240240
).isRequired,
241241
};
242242

src/lib/color.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function luminance([r, g, b]) {
3535
if (vSrgb <= 0.03928) {
3636
return vSrgb / 12.92;
3737
}
38-
return Math.pow((vSrgb + 0.055) / 1.055, 2.4);
38+
return ((vSrgb + 0.055) / 1.055) ** 2.4;
3939
});
4040
return colors[0] * 0.2126 + colors[1] * 0.7152 + colors[2] * 0.0722;
4141
}

src/lib/ocrFormats.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function parseHocr(hocrText, referenceSize) {
8080
const scaledHeight = Math.round(scaleFactorX * pageSize[3]);
8181
if (scaledWidth !== referenceSize.width || scaledHeight !== referenceSize.height) {
8282
console.warn(
83-
`Differing scale factors for x and y axis: x=${scaleFactorX}, y=${scaleFactorY}`
83+
`Differing scale factors for x and y axis: x=${scaleFactorX}, y=${scaleFactorY}`,
8484
);
8585
}
8686
scaleFactor = scaleFactorX;
@@ -350,7 +350,7 @@ export function parseIiifAnnotations(annos, imgSize) {
350350
const lineAnnos = annos.filter(
351351
(anno) =>
352352
anno.textGranularity === 'line' || // IIIF Text Granularity
353-
anno.dcType === 'Line' // Europeana
353+
anno.dcType === 'Line', // Europeana
354354
);
355355
const targetAnnos = lineAnnos.length > 0 ? lineAnnos : annos;
356356
const boxes = targetAnnos.map((anno) => {

0 commit comments

Comments
 (0)