From 6424ce2306dffaf7956213436eef1ad70cf9c113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 7 May 2020 07:21:27 +0200 Subject: [PATCH] Ran prettier everywhere --- plugins/home-page/dev/index.tsx | 4 +--- .../InventoryPage/InventoryPage.tsx | 2 +- .../src/components/AuditView/index.test.tsx | 14 ++++++------- .../src/components/AuditView/index.tsx | 4 ++-- .../src/components/CreateAudit/index.test.tsx | 2 +- .../src/components/CreateAudit/index.tsx | 8 ++++---- .../lighthouse/src/components/Intro/index.tsx | 2 +- plugins/lighthouse/src/utils.ts | 4 ++-- .../tech-radar/src/components/Radar/Radar.js | 20 ++++++------------- .../src/components/RadarBubble/RadarBubble.js | 8 ++++---- .../src/components/RadarComponent.tsx | 2 +- .../src/components/RadarGrid/RadarGrid.js | 2 +- .../src/components/RadarLegend/RadarLegend.js | 6 +++--- .../src/components/RadarPlot/RadarPlot.js | 6 +++--- 14 files changed, 37 insertions(+), 47 deletions(-) diff --git a/plugins/home-page/dev/index.tsx b/plugins/home-page/dev/index.tsx index d97643057b..812a5585d4 100644 --- a/plugins/home-page/dev/index.tsx +++ b/plugins/home-page/dev/index.tsx @@ -17,6 +17,4 @@ import { createDevApp } from '@backstage/dev-utils'; import { plugin } from '../src/plugin'; -createDevApp() - .registerPlugin(plugin) - .render(); +createDevApp().registerPlugin(plugin).render(); diff --git a/plugins/inventory/src/components/InventoryPage/InventoryPage.tsx b/plugins/inventory/src/components/InventoryPage/InventoryPage.tsx index 0b837d840c..647899eb35 100644 --- a/plugins/inventory/src/components/InventoryPage/InventoryPage.tsx +++ b/plugins/inventory/src/components/InventoryPage/InventoryPage.tsx @@ -47,7 +47,7 @@ const InventoryPage: FC<{}> = () => { - {STATIC_DATA.map(d => ( + {STATIC_DATA.map((d) => ( {d.id} {d.kind} diff --git a/plugins/lighthouse/src/components/AuditView/index.test.tsx b/plugins/lighthouse/src/components/AuditView/index.test.tsx index 31034440d6..000780a1cb 100644 --- a/plugins/lighthouse/src/components/AuditView/index.test.tsx +++ b/plugins/lighthouse/src/components/AuditView/index.test.tsx @@ -46,7 +46,7 @@ describe('AuditView', () => { apis = ApiRegistry.from([ [lighthouseApiRef, new LighthouseRestApi('https://lighthouse')], ]); - id = websiteResponse.audits.find(a => a.status === 'COMPLETED') + id = websiteResponse.audits.find((a) => a.status === 'COMPLETED') ?.id as string; useParams.mockReturnValue({ id }); }); @@ -98,7 +98,7 @@ describe('AuditView', () => { await rendered.findByTestId('audit-sidebar'); - websiteResponse.audits.forEach(a => { + websiteResponse.audits.forEach((a) => { expect( rendered.queryByText(formatTime(a.timeCreated)), ).toBeInTheDocument(); @@ -116,14 +116,14 @@ describe('AuditView', () => { await rendered.findByTestId('audit-sidebar'); - const audit = websiteResponse.audits.find(a => a.id === id) as Audit; + const audit = websiteResponse.audits.find((a) => a.id === id) as Audit; const auditElement = rendered.getByText(formatTime(audit.timeCreated)); expect(auditElement.parentElement?.parentElement?.className).toContain( 'selected', ); const notSelectedAudit = websiteResponse.audits.find( - a => a.id !== id, + (a) => a.id !== id, ) as Audit; const notSelectedAuditElement = rendered.getByText( formatTime(notSelectedAudit.timeCreated), @@ -144,7 +144,7 @@ describe('AuditView', () => { await rendered.findByTestId('audit-sidebar'); - websiteResponse.audits.forEach(a => { + websiteResponse.audits.forEach((a) => { expect( rendered.getByText(formatTime(a.timeCreated)).parentElement ?.parentElement, @@ -183,7 +183,7 @@ describe('AuditView', () => { describe.skip('when a loading audit is accessed', () => { it('shows a loading view', async () => { - id = websiteResponse.audits.find(a => a.status === 'RUNNING') + id = websiteResponse.audits.find((a) => a.status === 'RUNNING') ?.id as string; useParams.mockReturnValueOnce({ id }); @@ -203,7 +203,7 @@ describe('AuditView', () => { describe.skip('when a failed audit is accessed', () => { it('shows an error message', async () => { - id = websiteResponse.audits.find(a => a.status === 'FAILED') + id = websiteResponse.audits.find((a) => a.status === 'FAILED') ?.id as string; useParams.mockReturnValueOnce({ id }); diff --git a/plugins/lighthouse/src/components/AuditView/index.tsx b/plugins/lighthouse/src/components/AuditView/index.tsx index bb766b3997..889c6c53f3 100644 --- a/plugins/lighthouse/src/components/AuditView/index.tsx +++ b/plugins/lighthouse/src/components/AuditView/index.tsx @@ -68,7 +68,7 @@ const AuditLinkList: FC = ({ component="nav" aria-label="lighthouse audit history" > - {audits.map(audit => ( + {audits.map((audit) => ( = () => { - a.id === params.id)} /> + a.id === params.id)} /> ); diff --git a/plugins/lighthouse/src/components/CreateAudit/index.test.tsx b/plugins/lighthouse/src/components/CreateAudit/index.test.tsx index 3ce07dbb02..f15ee19ede 100644 --- a/plugins/lighthouse/src/components/CreateAudit/index.test.tsx +++ b/plugins/lighthouse/src/components/CreateAudit/index.test.tsx @@ -164,7 +164,7 @@ describe('CreateAudit', () => { fireEvent.click(rendered.getByText(/Create Audit/)); await wait(() => expect(rendered.getByLabelText(/URL/)).toBeEnabled()); - await new Promise(r => setTimeout(r, 0)); + await new Promise((r) => setTimeout(r, 0)); expect(errorApi.post).toHaveBeenCalledWith(expect.any(Error)); }); diff --git a/plugins/lighthouse/src/components/CreateAudit/index.tsx b/plugins/lighthouse/src/components/CreateAudit/index.tsx index 19db33791b..55ae99d1db 100644 --- a/plugins/lighthouse/src/components/CreateAudit/index.tsx +++ b/plugins/lighthouse/src/components/CreateAudit/index.tsx @@ -40,7 +40,7 @@ import { lighthouseApiRef } from '../../api'; import { useQuery } from '../../utils'; import LighthouseSupportButton from '../SupportButton'; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ input: { minWidth: 300, }, @@ -113,7 +113,7 @@ const CreateAudit: FC<{}> = () => {
{ + onSubmit={(ev) => { ev.preventDefault(); triggerAudit(); }} @@ -128,7 +128,7 @@ const CreateAudit: FC<{}> = () => { helperText="The target URL for Lighthouse to use." required disabled={submitting} - onChange={ev => setUrl(ev.target.value)} + onChange={(ev) => setUrl(ev.target.value)} value={url} inputProps={{ 'aria-label': 'URL' }} /> @@ -142,7 +142,7 @@ const CreateAudit: FC<{}> = () => { select required disabled={submitting} - onChange={ev => setEmulatedFormFactor(ev.target.value)} + onChange={(ev) => setEmulatedFormFactor(ev.target.value)} value={emulatedFormFactor} inputProps={{ 'aria-label': 'Emulated form factor' }} > diff --git a/plugins/lighthouse/src/components/Intro/index.tsx b/plugins/lighthouse/src/components/Intro/index.tsx index ee5d5d66af..72847eef42 100644 --- a/plugins/lighthouse/src/components/Intro/index.tsx +++ b/plugins/lighthouse/src/components/Intro/index.tsx @@ -71,7 +71,7 @@ export default builder.build() as ApiHolder; \`\`\` `; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ tabs: { marginBottom: -18 }, tab: { minWidth: 72, paddingLeft: 1, paddingRight: 1 }, content: { marginBottom: theme.spacing(2) }, diff --git a/plugins/lighthouse/src/utils.ts b/plugins/lighthouse/src/utils.ts index cc09b52f4f..a243b5f8d1 100644 --- a/plugins/lighthouse/src/utils.ts +++ b/plugins/lighthouse/src/utils.ts @@ -53,13 +53,13 @@ export function buildSparklinesDataForItem( (audit: Audit): audit is AuditCompleted => audit.status === 'COMPLETED', ) .reduce((scores, audit) => { - Object.values(audit.categories).forEach(category => { + Object.values(audit.categories).forEach((category) => { scores[category.id] = scores[category.id] || []; scores[category.id].unshift(category.score); }); // edge case: if only one audit exists, force a "flat" sparkline - Object.values(scores).forEach(arr => { + Object.values(scores).forEach((arr) => { if (arr.length === 1) arr.push(arr[0]); }); diff --git a/plugins/tech-radar/src/components/Radar/Radar.js b/plugins/tech-radar/src/components/Radar/Radar.js index e353e44589..ee956bfb89 100644 --- a/plugins/tech-radar/src/components/Radar/Radar.js +++ b/plugins/tech-radar/src/components/Radar/Radar.js @@ -105,14 +105,14 @@ export default class Radar extends React.Component { static adjustEntries(entries, activeEntry, quadrants, rings, radius) { let seed = 42; entries.forEach((entry, idx) => { - const quadrant = quadrants.find(q => { + const quadrant = quadrants.find((q) => { const match = typeof entry.quadrant === 'object' ? entry.quadrant.id : entry.quadrant; return q.id === match; }); - const ring = rings.find(r => { + const ring = rings.find((r) => { const match = typeof entry.ring === 'object' ? entry.ring.id : entry.ring; return r.id === match; @@ -137,21 +137,13 @@ export default class Radar extends React.Component { entry.active = activeEntry ? entry.id === activeEntry.id : false; entry.color = entry.active ? entry.ring.color - : color(entry.ring.color) - .desaturate(0.5) - .lighten(0.1) - .string(); + : color(entry.ring.color).desaturate(0.5).lighten(0.1).string(); }); const simulation = forceSimulation() .nodes(entries) .velocityDecay(0.19) - .force( - 'collision', - forceCollide() - .radius(12) - .strength(0.85), - ) + .force('collision', forceCollide().radius(12).strength(0.85)) .stop(); for ( @@ -198,7 +190,7 @@ export default class Radar extends React.Component { return ( { + ref={(node) => { this.node = node; }} width={width} @@ -213,7 +205,7 @@ export default class Radar extends React.Component { quadrants={quadrants} rings={rings} activeEntry={activeEntry} - onEntryMouseEnter={entry => this._setActiveEntry(entry)} + onEntryMouseEnter={(entry) => this._setActiveEntry(entry)} onEntryMouseLeave={() => this._clearActiveEntry()} /> diff --git a/plugins/tech-radar/src/components/RadarBubble/RadarBubble.js b/plugins/tech-radar/src/components/RadarBubble/RadarBubble.js index 072f80ca20..83487d637e 100644 --- a/plugins/tech-radar/src/components/RadarBubble/RadarBubble.js +++ b/plugins/tech-radar/src/components/RadarBubble/RadarBubble.js @@ -49,16 +49,16 @@ class RadarBubble extends React.PureComponent { this._updatePosition(); } - _setRect = rect => { + _setRect = (rect) => { this.rect = rect; }; - _setNode = node => { + _setNode = (node) => { this.node = node; }; - _setText = text => { + _setText = (text) => { this.text = text; }; - _setPath = path => { + _setPath = (path) => { this.path = path; }; diff --git a/plugins/tech-radar/src/components/RadarComponent.tsx b/plugins/tech-radar/src/components/RadarComponent.tsx index ffa6953986..7a6c4fedaf 100644 --- a/plugins/tech-radar/src/components/RadarComponent.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.tsx @@ -53,7 +53,7 @@ const useTechRadarLoader = (props: TechRadarComponentProps) => { return state; }; -const RadarComponent: FC = props => { +const RadarComponent: FC = (props) => { const errorApi = useApi(errorApiRef); const { loading, error, data } = useTechRadarLoader(props); diff --git a/plugins/tech-radar/src/components/RadarGrid/RadarGrid.js b/plugins/tech-radar/src/components/RadarGrid/RadarGrid.js index ce6c046242..f48a8e9514 100644 --- a/plugins/tech-radar/src/components/RadarGrid/RadarGrid.js +++ b/plugins/tech-radar/src/components/RadarGrid/RadarGrid.js @@ -84,7 +84,7 @@ class RadarGrid extends React.PureComponent { />, ]; - const ringNodes = rings.map(r => r.outerRadius).map(makeRingNode); + const ringNodes = rings.map((r) => r.outerRadius).map(makeRingNode); return axisNodes.concat(ringNodes); } diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.js b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.js index 674dd34cbb..5fb7b5a1ba 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.js +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.js @@ -88,7 +88,7 @@ class RadarLegend extends React.PureComponent {

{quadrant.name}

- {rings.map(ring => + {rings.map((ring) => RadarLegend._renderRing( ring, RadarLegend._getSegment(segments, quadrant, ring), @@ -117,7 +117,7 @@ class RadarLegend extends React.PureComponent {

(empty)

) : (
    - {entries.map(entry => { + {entries.map((entry) => { let node = {entry.title}; if (entry.url) { @@ -175,7 +175,7 @@ class RadarLegend extends React.PureComponent { return ( - {quadrants.map(quadrant => + {quadrants.map((quadrant) => RadarLegend._renderQuadrant( segments, quadrant, diff --git a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.js b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.js index b93d20cbff..afa4c4cd95 100644 --- a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.js +++ b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.js @@ -46,16 +46,16 @@ export default class RadarPlot extends React.PureComponent { rings={rings} entries={entries} onEntryMouseEnter={ - onEntryMouseEnter && (entry => onEntryMouseEnter(entry)) + onEntryMouseEnter && ((entry) => onEntryMouseEnter(entry)) } onEntryMouseLeave={ - onEntryMouseLeave && (entry => onEntryMouseLeave(entry)) + onEntryMouseLeave && ((entry) => onEntryMouseLeave(entry)) } /> - {entries.map(entry => ( + {entries.map((entry) => (