Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): upgrade to prettier 2.5.1 #750

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"pg": "^8.2.1",
"pg-hstore": "^2.3.3",
"preact-render-to-json": "^3.6.6",
"prettier": "1.16.4",
"prettier": "2.5.1",
"prop-types": "^15.7.2",
"puppeteer": "^13.1.2",
"rimraf": "^3.0.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/collect/puppeteer-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class PuppeteerManager {
// Otherwise, check to see if the expected puppeteer download exists.
const puppeteer = PuppeteerManager._requirePuppeteer();
const puppeteerUnknown = /** @type {unknown} */ (puppeteer);
const pupppeteerNode = /** @type {import('puppeteer').PuppeteerNode | undefined} */ (puppeteerUnknown);
const pupppeteerNode = /** @type {import('puppeteer').PuppeteerNode | undefined} */ (
puppeteerUnknown
);
const chromiumPath = pupppeteerNode && pupppeteerNode.executablePath();
return chromiumPath && fs.existsSync(chromiumPath) ? chromiumPath : undefined;
}
Expand Down
11 changes: 4 additions & 7 deletions packages/cli/src/upload/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,10 @@ async function runFilesystemTarget(options) {
isRepresentativeRun: representativeLhrs.includes(lhr),
htmlPath: path.join(targetDir, htmlPath),
jsonPath: path.join(targetDir, jsonPath),
summary: Object.keys(lhr.categories).reduce(
(summary, key) => {
summary[key] = lhr.categories[key].score;
return summary;
},
/** @type {Record<string, number>} */ ({})
),
summary: Object.keys(lhr.categories).reduce((summary, key) => {
summary[key] = lhr.categories[key].score;
return summary;
}, /** @type {Record<string, number>} */ ({})),
};

fs.writeFileSync(entry.htmlPath, getHTMLReportForLHR(lhr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ app.get('/', (_, res) => {
`);
});

const {
SERVER_START_MESSAGE = 'Server listening on port...',
SERVER_START_PORT = 52425,
} = process.env;
const {SERVER_START_MESSAGE = 'Server listening on port...', SERVER_START_PORT = 52425} =
process.env;

app.listen(SERVER_START_PORT, () => process.stdout.write(SERVER_START_MESSAGE));
5 changes: 1 addition & 4 deletions packages/cli/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ describe('Lighthouse CI server CLI', () => {

it('should print debug information when port is invalid from config', async () => {
const normalizePathsForWindows = stderr =>
stderr
.replace(__dirname, '.')
.replace(__dirname, '.')
.replace(/\\/g, '/');
stderr.replace(__dirname, '.').replace(__dirname, '.').replace(/\\/g, '/');

const {status, stderr} = await runCLI([
'server',
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ async function runWizardCLI(args, inputs, overrides = {}) {
await waitForCondition(
() => wizardProcess.stdoutMemory.includes(inputWaitCondition),
() =>
`Output never contained "${inputWaitCondition}"\nSTDOUT: ${
wizardProcess.stdoutMemory
}\nSTDERR:${wizardProcess.stderrMemory}`
`Output never contained "${inputWaitCondition}"\nSTDOUT: ${wizardProcess.stdoutMemory}\nSTDERR:${wizardProcess.stderrMemory}`
);
await writeAllInputs(wizardProcess, inputs);
await waitForCondition(() => status >= 0).catch(() => undefined);
Expand Down
5 changes: 4 additions & 1 deletion packages/server/src/api/storage/storage-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ class StorageMethod {
const runsTimer = startDebugTimer('createStatistics.getRuns');
const runs = await storageMethod.getRuns(projectId, buildId);
/** @type {Array<Array<[LHCI.ServerCommand.Run, LH.Result]>>} */
const runsByUrl = _.groupBy(runs.map(run => [run, JSON.parse(run.lhr)]), ([run, _]) => run.url);
const runsByUrl = _.groupBy(
runs.map(run => [run, JSON.parse(run.lhr)]),
([run, _]) => run.url
);
runsTimer.end();

log(`creating statistics for ${runs.length} run(s)`);
Expand Down
6 changes: 1 addition & 5 deletions packages/server/src/cron/psi-collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ async function psiCollectForProject(storageMethod, psi, site) {
commitMessage: `Autocollected at ${new Date().toLocaleString()}`,
author: `Lighthouse CI Server <[email protected]>`,
avatarUrl: getGravatarUrlFromEmail('[email protected]'),
hash: Date.now()
.toString(16)
.split('')
.reverse()
.join(''),
hash: Date.now().toString(16).split('').reverse().join(''),

runAt: new Date().toISOString(),
committedAt: new Date().toISOString(),
Expand Down
10 changes: 2 additions & 8 deletions packages/server/src/ui/components/d3-graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ import * as d3 from 'd3';
* @param {{top: number, right: number, bottom: number, left: number}} margin
*/
export function createRootSvg(rootEl, margin) {
d3.select(rootEl)
.selectAll('*')
.remove();
d3.select(rootEl).selectAll('*').remove();

const height = rootEl.clientHeight;
const width = rootEl.clientWidth;
const graphWidth = width - margin.left - margin.right;
const graphHeight = height - margin.top - margin.bottom;
const svgRoot = d3
.select(rootEl)
.append('svg')
.attr('width', width)
.attr('height', height);
const svgRoot = d3.select(rootEl).append('svg').attr('width', width).attr('height', height);

return {
width,
Expand Down
4 changes: 1 addition & 3 deletions packages/server/src/ui/routes/build-view/build-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ const BuildView_ = props => {
hookElements={{
warnings: computeWarnings(warningProps).hasWarning ? (
<BuildViewWarnings {...warningProps} />
) : (
undefined
),
) : undefined,
dropdowns: (
<Fragment>
<Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ export function renderScoreDistributionGraph(rootEl, data) {

const {svg, width, graphWidth, graphHeight} = createRootSvg(rootEl, GRAPH_MARGIN);

const xScale = d3
.scaleLinear()
.domain([0, 1])
.range([0, graphWidth]);
const xScale = d3.scaleLinear().domain([0, 1]).range([0, graphWidth]);
const xScaleForHover = d3
.scaleLinear()
.domain([0, binnedStatistics.length])
Expand All @@ -49,10 +46,7 @@ export function renderScoreDistributionGraph(rootEl, data) {
.scaleLinear()
.domain([0, Math.max(...binnedStatistics.map(bin => bin.length))])
.range([graphHeight, 10]);
const yAxis = d3
.axisLeft(yScale)
.ticks(3)
.tickSize(0);
const yAxis = d3.axisLeft(yScale).ticks(3).tickSize(0);

// The numbers on the y-axis to the right-hand side
svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ export function renderScoreGraph(rootEl, data) {
const scoreLineMaskId = `scoreLineMask-${statName}`;

/** @type {[number, number][]} */
const passingGuideLine = [[0, 90], [n, 90]];
const passingGuideLine = [
[0, 90],
[n, 90],
];
/** @type {[number, number][]} */
const failingGuideLine = [[0, 50], [n, 50]];
const failingGuideLine = [
[0, 50],
[n, 50],
];

const xScale = buildXScale(graphWidth, data);
const yScale = d3
.scaleLinear()
.domain([0, 100])
.range([graphHeight, 0]);
const yAxis = d3
.axisLeft(yScale)
.ticks(6)
.tickSize(0);
const yScale = d3.scaleLinear().domain([0, 100]).range([graphHeight, 0]);
const yAxis = d3.axisLeft(yScale).ticks(6).tickSize(0);

/** @type {() => import('d3').Line<StatisticWithBuild>} */
const statisticLine = d3.line;
Expand Down Expand Up @@ -114,25 +114,13 @@ export function renderScoreGraph(rootEl, data) {
.call(yAxis);

// The grey error bar area behind the score line
svg
.append('path')
.datum(statistics)
.attr('class', 'score-error-range')
.attr('d', scoreRange);
svg.append('path').datum(statistics).attr('class', 'score-error-range').attr('d', scoreRange);

// Passing/Average horizontal score guide
svg
.append('path')
.datum(passingGuideLine)
.attr('class', 'score-guide')
.attr('d', guideLine);
svg.append('path').datum(passingGuideLine).attr('class', 'score-guide').attr('d', guideLine);

// Average/Failing horizontal score guide
svg
.append('path')
.datum(failingGuideLine)
.attr('class', 'score-guide')
.attr('d', guideLine);
svg.append('path').datum(failingGuideLine).attr('class', 'score-guide').attr('d', guideLine);

// The shaded area for the version changes
for (const {index} of versionChanges) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ function renderPatternMasks(masks, maskId) {
.attr('patternUnits', 'userSpaceOnUse')
.attr('patternTransform', `rotate(60 50 50)`);

passPattern
.append('line')
.attr('stroke-width', 2)
.attr('y2', 10);
passPattern.append('line').attr('stroke-width', 2).attr('y2', 10);

masks
.append('pattern')
Expand Down Expand Up @@ -103,10 +100,7 @@ function renderDonutGraph(rootEl, data) {
.attr(
'd',
// @ts-ignore - can't figure out the right type for this
d3
.arc()
.innerRadius(innerRadius)
.outerRadius(outerRadius)
d3.arc().innerRadius(innerRadius).outerRadius(outerRadius)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,15 @@ function renderHistogram(rootEl, data) {
const [passThreshold, failThreshold] = data.scoreLevels;
const {svg, graphWidth, graphHeight} = createRootSvg(rootEl, GRAPH_MARGIN);

const xScale = d3
.scaleLinear()
.domain([0, xMax])
.range([0, graphWidth]);
const xScale = d3.scaleLinear().domain([0, xMax]).range([0, graphWidth]);
const xScaleForHover = d3
.scaleLinear()
.domain([0, binnedStatistics.length])
.range([0, graphWidth]);

const yMax = Math.max(...binnedStatistics.map(bin => bin.length));
const yScale = d3
.scaleLinear()
.domain([0, yMax])
.range([graphHeight, 10]);
const yAxis = d3
.axisLeft(yScale)
.ticks(Math.min(3, yMax))
.tickSize(0);
const yScale = d3.scaleLinear().domain([0, yMax]).range([graphHeight, 10]);
const yAxis = d3.axisLeft(yScale).ticks(Math.min(3, yMax)).tickSize(0);

// The numbers on the y-axis to the right-hand side
svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ function renderLineGraph(rootEl, data) {
const yMaxSeconds = Math.ceil((yMax * 1.1) / 1000);

const xScale = buildXScale(graphWidth, data);
const yScale = d3
.scaleLinear()
.domain([0, yMaxSeconds])
.range([graphHeight, 0]);
const yScale = d3.scaleLinear().domain([0, yMaxSeconds]).range([graphHeight, 0]);
const yAxis = d3
.axisRight(yScale)
.ticks(Math.min(yMaxSeconds, 6))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ const computeBranchSelection = props => {
const computeUrlSelection = props => {
const availableUrls = props.urls.length ? props.urls : [{url: 'None'}];
// Default to the shortest URL because that's usually the root homepage, e.g. `/`
const shortestUrl = _.minBy(availableUrls.map(({url}) => url), url => url.length);
const shortestUrl = _.minBy(
availableUrls.map(({url}) => url),
url => url.length
);
const selectedUrl = props.runUrl || shortestUrl || 'None';

return {
Expand Down
7 changes: 5 additions & 2 deletions packages/server/test/cron/delete-old-builds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/** @type {jest.MockInstance} */
let cronJob = jest.fn().mockReturnValue({start: () => {}});
jest.mock('cron', () => ({
CronJob: function(...args) {
CronJob: function (...args) {
// use this indirection because we have to invoke it with `new` and it's harder to mock assertions
return cronJob(...args);
},
Expand Down Expand Up @@ -43,7 +43,10 @@ describe('cron/delete-old-builds', () => {

it('should collect', async () => {
storageMethod.deleteBuild.mockClear();
const deleteObjects = [{id: 'id-1', projectId: 'pid-1'}, {id: 'id-2', projectId: 'pid-2'}];
const deleteObjects = [
{id: 'id-1', projectId: 'pid-1'},
{id: 'id-2', projectId: 'pid-2'},
];
storageMethod.findBuildsBeforeTimestamp.mockResolvedValue(deleteObjects);
await deleteOldBuilds(storageMethod, 30, null, null);
expect(storageMethod.deleteBuild).toHaveBeenCalledTimes(deleteObjects.length);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/cron/psi-collect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/** @type {jest.MockInstance} */
let cronJob = jest.fn().mockReturnValue({start: () => {}});
jest.mock('cron', () => ({
CronJob: function(...args) {
CronJob: function (...args) {
// use this indirection because we have to invoke it with `new` and it's harder to mock assertions
return cronJob(...args);
},
Expand Down
3 changes: 1 addition & 2 deletions packages/server/test/server-test-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,7 @@ function runTests(state) {
client.setBuildToken(projectA.token);
await expect(client.createBuild(payload)).rejects.toMatchObject({
status: 422,
body:
'{"message":"Build already exists for hash \\"e0acdd50ed0fdcfdceb2508498be50cc55c696ef\\""}',
body: '{"message":"Build already exists for hash \\"e0acdd50ed0fdcfdceb2508498be50cc55c696ef\\""}',
});
});

Expand Down
7 changes: 6 additions & 1 deletion packages/server/test/ui/components/async-loader.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ describe('combineAsyncData', () => {
});

it('should return values when 4 set', () => {
const values = [['loaded', 1], ['loaded', 2], ['loaded', 3], ['loaded', 4]];
const values = [
['loaded', 1],
['loaded', 2],
['loaded', 3],
['loaded', 4],
];

expect(combineAsyncData(...values)).toEqual([1, 2, 3, 4]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ describe('LhrComparison', () => {
},
a11y: {
title: 'Accessibility',
auditRefs: [{id: 'badimages', group: 'images'}, {id: 'debugdata', group: 'missing'}],
auditRefs: [
{id: 'badimages', group: 'images'},
{id: 'debugdata', group: 'missing'},
],
},
seo: {
title: 'SEO',
Expand Down
4 changes: 2 additions & 2 deletions packages/server/test/ui/storybook.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ initStoryshots({
suite: 'Image Storyshots',
test: imageSnapshot({
storybookUrl: `http://localhost:${process.env.STORYBOOK_PORT}`,
beforeScreenshot: async (page) => {
beforeScreenshot: async page => {
// The browser is reused, so set the viewport back to a good default.
await page.setViewport({width: 800, height: 600});

Expand All @@ -40,7 +40,7 @@ initStoryshots({
const elements = [...document.querySelectorAll('#root, #root *')];
return {
width: Math.ceil(Math.max(...elements.map(e => e.clientWidth))),
height: Math.ceil(Math.max(...elements.map(e => e.clientHeight)))
height: Math.ceil(Math.max(...elements.map(e => e.clientHeight))),
};
});
await page.setViewport(dimensions);
Expand Down
10 changes: 2 additions & 8 deletions packages/utils/src/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,8 @@ function resolveAssertionOptionsAndLhrs(baseOptions, unfilteredLhrs) {
* @return {AssertionResult[]}
*/
function getAllAssertionResultsForUrl(baseOptions, unfilteredLhrs) {
const {
assertions,
auditsToAssert,
medianLhrs,
lhrs,
url,
aggregationMethod,
} = resolveAssertionOptionsAndLhrs(baseOptions, unfilteredLhrs);
const {assertions, auditsToAssert, medianLhrs, lhrs, url, aggregationMethod} =
resolveAssertionOptionsAndLhrs(baseOptions, unfilteredLhrs);

// If we don't have any data, just return early.
if (!lhrs.length) return [];
Expand Down
Loading