Update to latest prettier/eslint setup (#3478)

This commit is contained in:
Peter Hedenskog 2021-10-11 18:44:59 +02:00 committed by GitHub
parent 426fb42bca
commit 1e9bea8bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 598 additions and 673 deletions

View File

@ -13,7 +13,10 @@
"prettier/prettier": [
"error",
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"embeddedLanguageFormatting": "off"
}
],
"require-atomic-updates": 0,

View File

@ -5,13 +5,11 @@ module.exports = {
{ value: 'docs', name: 'docs: Documentation only changes' },
{
value: 'style',
name:
'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)'
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)'
},
{
value: 'refactor',
name:
'refactor: A code change that neither fixes a bug nor adds a feature'
name: 'refactor: A code change that neither fixes a bug nor adds a feature'
},
{
value: 'perf',
@ -20,8 +18,7 @@ module.exports = {
{ value: 'test', name: 'test: Adding missing tests' },
{
value: 'chore',
name:
'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation'
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation'
},
{ value: 'revert', name: 'revert: Revert to a commit' },
{ value: 'WIP', name: 'WIP: Work in progress' }
@ -57,8 +54,7 @@ module.exports = {
// used if allowCustomScopes is true
// customScope: 'Denote the SCOPE of this change:',
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
body:
'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional):\n',
footer:
'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',

View File

@ -1461,7 +1461,7 @@ module.exports.parseCommandLine = function parseCommandLine() {
.alias('help', 'h')
.config(config)
.alias('version', 'V')
.coerce('budget', function(arg) {
.coerce('budget', function (arg) {
if (arg) {
if (typeof arg === 'object' && !Array.isArray(arg)) {
if (arg.configPath) {
@ -1507,7 +1507,7 @@ module.exports.parseCommandLine = function parseCommandLine() {
return plugins;
}
})
.coerce('webpagetest', function(arg) {
.coerce('webpagetest', function (arg) {
if (arg) {
// for backwards compatible reasons we check if the passed parameters is a path to a script, if so just us it (PR #1445)
if (arg.script && fs.existsSync(arg.script)) {

View File

@ -40,10 +40,7 @@ module.exports = {
} else {
const filePath = path.resolve(url);
try {
const lines = fs
.readFileSync(filePath)
.toString()
.split('\n');
const lines = fs.readFileSync(filePath).toString().split('\n');
for (let line of lines) {
if (line.trim().length > 0) {
let lineArray = line.split(' ', 2);
@ -91,10 +88,7 @@ module.exports = {
pos += 1;
} else {
const filePath = url;
const lines = fs
.readFileSync(filePath)
.toString()
.split('\n');
const lines = fs.readFileSync(filePath).toString().split('\n');
for (let line of lines) {
if (line.trim().length > 0) {
let url,

View File

@ -40,9 +40,7 @@ function validateMessageFormat(message) {
if (previousDepth && previousDepth !== typeDepth) {
throw new Error(
`All messages of type ${baseType} must have the same structure. ` +
`${
message.type
} has ${typeDepth} part(s), but earlier messages had ${previousDepth} part(s).`
`${message.type} has ${typeDepth} part(s), but earlier messages had ${previousDepth} part(s).`
);
}

View File

@ -15,7 +15,7 @@ function getDomainOrFileName(input) {
return domainOrFile;
}
module.exports = function(input, timestamp, options) {
module.exports = function (input, timestamp, options) {
const outputFolder = options.outputFolder;
const resultBaseURL = options.resultBaseURL;
const resultsSubFolders = [];

View File

@ -30,19 +30,13 @@ module.exports = function pathFromRootToPageDir(url, options, alias) {
if (useHash && !isEmpty(parsedUrl.hash)) {
const md5 = crypto.createHash('md5'),
hash = md5
.update(parsedUrl.hash)
.digest('hex')
.substring(0, 8);
hash = md5.update(parsedUrl.hash).digest('hex').substring(0, 8);
urlSegments.push('hash-' + hash);
}
if (!isEmpty(parsedUrl.search)) {
const md5 = crypto.createHash('md5'),
hash = md5
.update(parsedUrl.search)
.digest('hex')
.substring(0, 8);
hash = md5.update(parsedUrl.search).digest('hex').substring(0, 8);
urlSegments.push('query-' + hash);
}
@ -64,7 +58,7 @@ module.exports = function pathFromRootToPageDir(url, options, alias) {
// pathSegments.push('data');
pathSegments.forEach(function(segment, index) {
pathSegments.forEach(function (segment, index) {
if (segment) {
pathSegments[index] = segment.replace(/[^-a-z0-9_.\u0621-\u064A]/gi, '-');
}

View File

@ -117,17 +117,15 @@ module.exports = {
summary.size[group] = {};
summary.timing[group] = {};
for (let assetTypes of Object.keys(this.largestAssetsByGroup[group])) {
summary.size[group][assetTypes] = this.largestAssetsByGroup[group][
assetTypes
].getItems();
summary.size[group][assetTypes] =
this.largestAssetsByGroup[group][assetTypes].getItems();
}
summary.timing[group] = this.slowestAssetsByGroup[group].getItems();
}
for (let assetTypes of Object.keys(this.largestAssets)) {
summary.size.total[assetTypes] = this.largestAssets[
assetTypes
].getItems();
summary.size.total[assetTypes] =
this.largestAssets[assetTypes].getItems();
}
summary.timing.total = this.slowestAssets

View File

@ -23,7 +23,7 @@ class AssetsBySize {
}
if (this.items.length > this.maxSize) {
this.items.sort(function(asset, asset2) {
this.items.sort(function (asset, asset2) {
return asset2.contentSize - asset.contentSize;
});
@ -36,7 +36,7 @@ class AssetsBySize {
}
getItems() {
this.items.sort(function(asset, asset2) {
this.items.sort(function (asset, asset2) {
return asset2.contentSize - asset.contentSize;
});
return this.items;

View File

@ -32,7 +32,7 @@ class AssetsBySpeed {
}
if (this.items.length > this.maxSize) {
this.items.sort(function(asset, asset2) {
this.items.sort(function (asset, asset2) {
return asset2.totalTime - asset.totalTime;
});
@ -45,7 +45,7 @@ class AssetsBySpeed {
}
getItems() {
this.items.sort(function(asset, asset2) {
this.items.sort(function (asset, asset2) {
return asset2.totalTime - asset.totalTime;
});

View File

@ -1,6 +1,6 @@
const axe = require('axe-core').source;
module.exports = async function(context) {
module.exports = async function (context) {
// Insert the axe source
await context.selenium.driver.executeScript(axe);

View File

@ -68,7 +68,7 @@ function addExtraScripts(scriptsByCategory, pluginScripts) {
// For all different script in the array
for (let scripts of pluginScripts) {
// and then for all scripts in that category
forEach(scripts.scripts, function(script, name) {
forEach(scripts.scripts, function (script, name) {
set(scriptsByCategory, scripts.category + '.' + name, script);
});
}
@ -80,7 +80,7 @@ function setupAsynScripts(asyncScripts) {
// For all different script in the array
for (let scripts of asyncScripts) {
// and then for all scripts in that category
forEach(scripts.scripts, function(script, name) {
forEach(scripts.scripts, function (script, name) {
set(allAsyncScripts, scripts.category + '.' + name, script);
});
}

View File

@ -202,7 +202,7 @@ module.exports = {
// We step 100 ms each step ... but if you wanna show all and the last change is late
// use 200 ms
const step =
maxTiming > 10000 && (options.filmstrip && options.filmstrip.showAll)
maxTiming > 10000 && options.filmstrip && options.filmstrip.showAll
? 200
: 100;
let fileName = '';

View File

@ -234,8 +234,9 @@ module.exports = {
url,
this.allAlias[url]
);
_meta.screenshot = `${base}data/screenshots/${runIndex +
1}/afterPageCompleteCheck.${this.screenshotType}`;
_meta.screenshot = `${base}data/screenshots/${
runIndex + 1
}/afterPageCompleteCheck.${this.screenshotType}`;
_meta.result = `${base}${runIndex + 1}.html`;
if (options.video) {
_meta.video = `${base}data/video/${runIndex + 1}.mp4`;
@ -483,14 +484,12 @@ module.exports = {
);
if (options.chrome && options.chrome.collectConsoleLog) {
result[
resultIndex
].statistics.console = consoleLogAggregator.summarizeStats();
result[resultIndex].statistics.console =
consoleLogAggregator.summarizeStats();
}
result[resultIndex].statistics.errors = statsHelpers.summarizeStats(
errorStats
);
result[resultIndex].statistics.errors =
statsHelpers.summarizeStats(errorStats);
// Post the result on the queue so other plugins can use it
queue.postMessage(

View File

@ -26,7 +26,7 @@ function getHelperFunction(metric) {
) {
return size;
} else if (metric.indexOf('timings') > -1) {
return function(time) {
return function (time) {
return time + ' ms';
};
} else return noop;

View File

@ -4,7 +4,7 @@ const fs = require('fs'),
log = require('intel').getLogger('sitespeedio.plugin.budget'),
path = require('path');
exports.writeJson = function(results, dir) {
exports.writeJson = function (results, dir) {
const file = path.join(dir, 'budgetResult.json');
log.info('Write budget to %s', path.resolve(file));
fs.writeFileSync(file, JSON.stringify(results, null, 2));

View File

@ -6,7 +6,7 @@ const builder = require('junit-report-builder'),
path = require('path'),
merge = require('lodash.merge');
exports.writeJunit = function(results, dir, options) {
exports.writeJunit = function (results, dir, options) {
// lets have one suite per URL
const urls = Object.keys(merge({}, results.failing, results.working));

View File

@ -6,7 +6,7 @@ const tap = require('tape'),
path = require('path'),
EOL = require('os').EOL;
exports.writeTap = function(results, dir) {
exports.writeTap = function (results, dir) {
const file = path.join(dir, 'budget.tap');
log.info('Write budget to %s', path.resolve(file));
const tapOutput = fs.createWriteStream(file);
@ -17,7 +17,7 @@ exports.writeTap = function(results, dir) {
for (const url of urls) {
for (const result of results.failing[url]) {
tap(result.type + '.' + result.metric + ' ' + url, function(t) {
tap(result.type + '.' + result.metric + ' ' + url, function (t) {
let extra = '';
if (resultType === 'failing') {
extra =

View File

@ -96,18 +96,13 @@ module.exports = {
if (originResult.originLoadingExperience[formFactor].error) {
log.info(
`${
originResult.originLoadingExperience[formFactor].error.message
} for domain ${url} using ${formFactor}`
`${originResult.originLoadingExperience[formFactor].error.message} for domain ${url} using ${formFactor}`
);
queue.postMessage(
make(
'error',
`${
originResult.originLoadingExperience[formFactor].error
.message
} for domain ${url} using ${formFactor}`,
`${originResult.originLoadingExperience[formFactor].error.message} for domain ${url} using ${formFactor}`,
{
url
}
@ -142,17 +137,13 @@ module.exports = {
if (urlResult.loadingExperience[formFactor].error) {
log.info(
`${
urlResult.loadingExperience[formFactor].error.message
} for ${url} using ${formFactor}`
`${urlResult.loadingExperience[formFactor].error.message} for ${url} using ${formFactor}`
);
queue.postMessage(
make(
'error',
`${
urlResult.loadingExperience[formFactor].error.message
} for ${url} using ${formFactor}`,
`${urlResult.loadingExperience[formFactor].error.message} for ${url} using ${formFactor}`,
{
url
}

View File

@ -1,16 +1,16 @@
'use strict';
module.exports = function(cruxResult) {
module.exports = function (cruxResult) {
const result = {};
if (cruxResult.record.metrics.first_contentful_paint) {
result.FIRST_CONTENTFUL_PAINT_MS = {
p75: cruxResult.record.metrics.first_contentful_paint.percentiles.p75,
fast:
cruxResult.record.metrics.first_contentful_paint.histogram[0].density,
fast: cruxResult.record.metrics.first_contentful_paint.histogram[0]
.density,
moderate:
cruxResult.record.metrics.first_contentful_paint.histogram[1].density,
slow:
cruxResult.record.metrics.first_contentful_paint.histogram[2].density
slow: cruxResult.record.metrics.first_contentful_paint.histogram[2]
.density
};
}
if (cruxResult.record.metrics.first_input_delay) {
@ -26,24 +26,24 @@ module.exports = function(cruxResult) {
if (cruxResult.record.metrics.cumulative_layout_shift) {
result.CUMULATIVE_LAYOUT_SHIFT_SCORE = {
p75: cruxResult.record.metrics.cumulative_layout_shift.percentiles.p75,
fast:
cruxResult.record.metrics.cumulative_layout_shift.histogram[0].density,
fast: cruxResult.record.metrics.cumulative_layout_shift.histogram[0]
.density,
moderate:
cruxResult.record.metrics.cumulative_layout_shift.histogram[1].density,
slow:
cruxResult.record.metrics.cumulative_layout_shift.histogram[2].density
slow: cruxResult.record.metrics.cumulative_layout_shift.histogram[2]
.density
};
}
if (cruxResult.record.metrics.largest_contentful_paint) {
result.LARGEST_CONTENTFUL_PAINT_MS = {
p75: cruxResult.record.metrics.largest_contentful_paint.percentiles.p75,
fast:
cruxResult.record.metrics.largest_contentful_paint.histogram[0].density,
fast: cruxResult.record.metrics.largest_contentful_paint.histogram[0]
.density,
moderate:
cruxResult.record.metrics.largest_contentful_paint.histogram[1].density,
slow:
cruxResult.record.metrics.largest_contentful_paint.histogram[2].density
slow: cruxResult.record.metrics.largest_contentful_paint.histogram[2]
.density
};
}
result.data = cruxResult;

View File

@ -11,7 +11,7 @@ module.exports = {
}
data = JSON.stringify(data);
// Return new promise
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
// Do async job
const req = https.request(
{
@ -24,12 +24,10 @@ module.exports = {
},
method: 'POST'
},
function(res) {
function (res) {
if (res.statusCode >= 499) {
log.error(
`Got error from CrUx. Error Code: ${res.statusCode} Message: ${
res.statusMessage
}`
`Got error from CrUx. Error Code: ${res.statusCode} Message: ${res.statusMessage}`
);
return reject(new Error(`Status Code: ${res.statusCode}`));
}

View File

@ -98,9 +98,7 @@ module.exports = {
const baseDir = this.storageManager.getBaseDir();
log.info(
`Uploading ${baseDir} to Google Cloud Storage bucket ${
gcsOptions.bucketname
}, this can take a while ...`
`Uploading ${baseDir} to Google Cloud Storage bucket ${gcsOptions.bucketname}, this can take a while ...`
);
try {

View File

@ -94,7 +94,7 @@ class GraphiteDataGenerator {
if (this.options.graphite && this.options.graphite.perIteration) {
if (message.type === 'browsertime.run') {
if (key.includes('timings') && key.includes('marks')) {
key = key.replace(/marks\.(\d+)/, function(match, idx) {
key = key.replace(/marks\.(\d+)/, function (match, idx) {
return (
'marks.' + message.data.timings.userTimings.marks[idx].name
);
@ -102,7 +102,7 @@ class GraphiteDataGenerator {
}
if (key.includes('timings') && key.includes('measures')) {
key = key.replace(/measures\.(\d+)/, function(match, idx) {
key = key.replace(/measures\.(\d+)/, function (match, idx) {
return (
'measures.' +
message.data.timings.userTimings.measures[idx].name
@ -114,7 +114,7 @@ class GraphiteDataGenerator {
if (key.includes('assets')) {
key = key.replace(
/assets\.(\d+)/,
function(match, idx) {
function (match, idx) {
let url = new URL(message.data.assets[idx].url);
url.search = '';
return 'assets.' + graphiteUtil.toSafeKey(url.toString());

View File

@ -12,15 +12,11 @@ class GraphiteSender extends Sender {
this.log(data);
return new Promise((resolve, reject) => {
const socket = net.connect(
this.port,
this.host,
() => {
socket.write(data);
socket.end();
resolve();
}
);
const socket = net.connect(this.port, this.host, () => {
socket.write(data);
socket.end();
resolve();
});
socket.on('error', reject);
});
}

View File

@ -14,13 +14,8 @@ class StatsDSender extends Sender {
return new Promise((resolve, reject) => {
const client = dgram.createSocket('udp4');
client.send(
data,
0,
data.length,
this.port,
this.host,
error => (client.close() && error ? reject(error) : resolve())
client.send(data, 0, data.length, this.port, this.host, error =>
client.close() && error ? reject(error) : resolve()
);
});
}

View File

@ -373,8 +373,9 @@ class HTMLBuilder {
resultUrls: this.context.resultUrls,
assetsPath: assetsBaseURL || rootPath,
menu: 'pages',
pageTitle: `Run ${parseInt(runIndex) +
1} for ${url} at ${runTimestamp}`,
pageTitle: `Run ${
parseInt(runIndex) + 1
} for ${url} at ${runTimestamp}`,
pageDescription: `${metricHelper.getMetricsFromRun(
pageInfo
)} collected by sitespeed.io ${packageInfo.version}`,

View File

@ -71,9 +71,7 @@ module.exports = {
'data.browsertime.pageSummary.statistics.timings'
);
if (visualMetrics) {
return `Median First Visual Change: ${
visualMetrics.FirstVisualChange.median
},
return `Median First Visual Change: ${visualMetrics.FirstVisualChange.median},
Median Speed Index: ${visualMetrics.SpeedIndex.median},
Median Visual Complete 85%: ${visualMetrics.VisualComplete85.median},
Median Last Visual Change: ${visualMetrics.LastVisualChange.median}`;
@ -81,8 +79,8 @@ module.exports = {
return timings.loadEventEnd
? `Median LoadEventEnd: ${timings.loadEventEnd.median}`
: '' + timings.fullyLoaded
? `Median Fully loaded: ${timings.fullyLoaded.median}`
: '';
? `Median Fully loaded: ${timings.fullyLoaded.median}`
: '';
} else {
return '';
}

View File

@ -16,7 +16,7 @@ function row(stat, name, metricName, formatter) {
};
}
module.exports = function(data) {
module.exports = function (data) {
if (!data) {
return [];
}

View File

@ -106,7 +106,7 @@ function _box(stat, name, label, formatter, url) {
};
}
module.exports = function(data, html) {
module.exports = function (data, html) {
if (!data) {
return [];
}

View File

@ -1,4 +1,4 @@
window.addEventListener('DOMContentLoaded', function() {
window.addEventListener('DOMContentLoaded', function () {
let tabsRoot = document.querySelector('#tabs');
let navigationLinks = document.querySelectorAll('#pageNavigation a');

View File

@ -97,9 +97,7 @@ module.exports = {
const req = lib.request(postOptions, res => {
if (res.statusCode !== 204) {
const e = new Error(
`Got ${res.statusCode} from InfluxDB when sending annotation ${
res.statusMessage
}`
`Got ${res.statusCode} from InfluxDB when sending annotation ${res.statusMessage}`
);
log.warn(e.message);
reject(e);

View File

@ -97,11 +97,10 @@ module.exports = {
// We have failing URLs in the budget
if (Object.keys(message.data.failing).length > 0) {
const failingURLs = Object.keys(message.data.failing);
text += `<h1>&#9888;&#65039; Budget failing (${
failingURLs.length
} URLs)</h1>`;
text += `<p><b>${get(this.options, 'name', '') +
'</b> '}${getBrowserData(this.browserData)}</p>`;
text += `<h1>&#9888;&#65039; Budget failing (${failingURLs.length} URLs)</h1>`;
text += `<p><b>${
get(this.options, 'name', '') + '</b> '
}${getBrowserData(this.browserData)}</p>`;
for (let url of failingURLs) {
text += `<h5>&#10060; ${url}`;
if (this.resultUrls.hasBaseUrl()) {
@ -119,18 +118,14 @@ module.exports = {
}
text += '<ul>';
for (let failing of message.data.failing[url]) {
text += `<li>${failing.metric} : ${failing.friendlyValue} (${
failing.friendlyLimit
})</li>`;
text += `<li>${failing.metric} : ${failing.friendlyValue} (${failing.friendlyLimit})</li>`;
}
text += `</ul>`;
}
}
if (Object.keys(message.data.error).length > 0) {
const errorURLs = Object.keys(message.data.error);
text += `<h1>&#9888;&#65039; Budget errors testing ${
errorURLs.length
} URLs</h1>`;
text += `<h1>&#9888;&#65039; Budget errors testing ${errorURLs.length} URLs</h1>`;
for (let url of errorURLs) {
text += `<h5>&#10060; ${url}</h5>`;
text += `<pre>${message.data.error[url]}</pre>`;
@ -143,8 +138,9 @@ module.exports = {
text += `<p><b>&#127881; All (${
Object.keys(message.data.working).length
}) URLs passed the budget. </b></p>`;
text += `<p><b>${get(this.options, 'name', '') +
'</b> '}${getBrowserData(this.browserData)}</p>`;
text += `<p><b>${
get(this.options, 'name', '') + '</b> '
}${getBrowserData(this.browserData)}</p>`;
}
if (!this.waitForUpload) {
const room = get(options, 'rooms.budget', options.room);

View File

@ -42,9 +42,7 @@ function send(
}, backoff);
} else {
log.error(
`Got error from Matrix. Error Code: ${res.statusCode} Message: ${
res.statusMessage
}`
`Got error from Matrix. Error Code: ${res.statusCode} Message: ${res.statusMessage}`
);
reject(new Error(`Status Code: ${res.statusCode}`));
}

View File

@ -16,9 +16,9 @@ module.exports = {
let stats = this.stats;
let groups = this.groups;
pageSummary.forEach(function(summary) {
pageSummary.forEach(function (summary) {
// stats for the whole page
METRIC_NAMES.forEach(function(metric) {
METRIC_NAMES.forEach(function (metric) {
// There's a bug in Firefox/https://github.com/devtools-html/har-export-trigger
// that sometimes generate content size that is null, see
// https://github.com/sitespeedio/sitespeed.io/issues/2090
@ -32,8 +32,8 @@ module.exports = {
}
});
Object.keys(summary.contentTypes).forEach(function(contentType) {
METRIC_NAMES.forEach(function(metric) {
Object.keys(summary.contentTypes).forEach(function (contentType) {
METRIC_NAMES.forEach(function (metric) {
// There's a bug in Firefox/https://github.com/devtools-html/har-export-trigger
// that sometimes generate content size that is null, see
// https://github.com/sitespeedio/sitespeed.io/issues/2090
@ -48,7 +48,7 @@ module.exports = {
});
});
Object.keys(summary.responseCodes).forEach(function(responseCode) {
Object.keys(summary.responseCodes).forEach(function (responseCode) {
statsHelpers.pushGroupStats(
stats,
groups[group],
@ -59,7 +59,7 @@ module.exports = {
// extras for firstParty vs third
if (summary.firstParty.requests) {
METRIC_NAMES.forEach(function(metric) {
METRIC_NAMES.forEach(function (metric) {
if (summary.firstParty[metric] !== undefined) {
statsHelpers.pushGroupStats(
stats,

View File

@ -109,9 +109,7 @@ module.exports = {
const baseDir = this.storageManager.getBaseDir();
log.info(
`Uploading ${baseDir} to S3 bucket ${
s3Options.bucketname
}, this can take a while ...`
`Uploading ${baseDir} to S3 bucket ${s3Options.bucketname}, this can take a while ...`
);
try {

View File

@ -11,7 +11,7 @@ function getMetric(metric, f) {
}
}
module.exports = function(
module.exports = function (
dataCollector,
resultUrls,
slackOptions,

View File

@ -4,7 +4,7 @@ const get = require('lodash.get');
const h = require('../../support/helpers');
const tsdbUtil = require('../../support/tsdbUtil');
module.exports = function(dataCollector, errors, resultUrls, name, options) {
module.exports = function (dataCollector, errors, resultUrls, name, options) {
const base = dataCollector.getSummary() || {};
const metrics = {
firstPaint: {

View File

@ -44,9 +44,7 @@ module.exports = {
(screenShotsEnabledInBrowsertime || webPageTestResultURL) &&
screenshotsEnabledForDatasource
? `<a href='${resultPageUrl}' target='_blank'><img src='${screenshotPath}' ${screenshotSize}></a><p><a href='${resultPageUrl}'>Result</a> - <a href='${harPath}'>Download HAR</a></p>`
: `<a href='${resultPageUrl}' target='_blank'>Result ${
options.browsertime.iterations
} run${s}</a>`;
: `<a href='${resultPageUrl}' target='_blank'>Result ${options.browsertime.iterations} run${s}</a>`;
if (webPageTestResultURL) {
message = message + ` <a href='${webPageTestResultURL}'>WebPageTest</a>`;

View File

@ -72,9 +72,7 @@ module.exports = {
target[keyPrefix] = value;
} else {
log.warn(
`Non-finite number '${value}' found at path '${keyPrefix}' for '${type}' message (url = ${
data.url
})`
`Non-finite number '${value}' found at path '${keyPrefix}' for '${type}' message (url = ${data.url})`
);
}
}
@ -125,9 +123,7 @@ module.exports = {
case 'undefined':
{
log.debug(
`Undefined value found at path '${keyPrefix}' for '${type}' message (url = ${
data.url
})`
`Undefined value found at path '${keyPrefix}' for '${type}' message (url = ${data.url})`
);
}
break;

View File

@ -1,5 +1,5 @@
'use strict';
module.exports = function(word) {
module.exports = function (word) {
return word.substr(0, 1).toUpperCase() + word.substr(1);
};

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(decimals) {
module.exports = function (decimals) {
let number = Number(decimals).toFixed(3);
if (number === '0.000') {
return 0;

View File

@ -1,7 +1,7 @@
'use strict';
const get = require('lodash.get');
module.exports = function(object, property, defaultValue) {
module.exports = function (object, property, defaultValue) {
if (arguments.length < 3) {
defaultValue = 0;
}

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(httpCodes) {
module.exports = function (httpCodes) {
let data = '';
for (let code of Object.keys(httpCodes)) {
if (Number(code) > 399) {

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(value, ok, warning) {
module.exports = function (value, ok, warning) {
value = value || 0;
if (value > ok) {
return 'ok';

View File

@ -1,5 +1,5 @@
'use strict';
module.exports = function(value) {
module.exports = function (value) {
return value;
};

View File

@ -1,5 +1,5 @@
'use strict';
module.exports = function(value) {
module.exports = function (value) {
return `${value}%`;
};

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(number, text) {
module.exports = function (number, text) {
if (number === 0 || number > 1) {
text += 's';
}

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(value) {
module.exports = function (value) {
value = value || 0;
if (value > 90) {
return 'ok';

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(text, number) {
module.exports = function (text, number) {
if (text.length > number) {
return text.slice(0, number) + '...';
}

View File

@ -1,6 +1,6 @@
'use strict';
module.exports = function(url, longVersion) {
module.exports = function (url, longVersion) {
if (longVersion) {
if (url.length > 100) {
let shortUrl = url.replace(/\?.*/, '');

796
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -57,15 +57,15 @@
"changelog-parser": "2.8.0",
"clean-css-cli": "4.3.0",
"cz-customizable": "^6.2.0",
"eslint": "6.2.2",
"eslint-config-prettier": "6.1.0",
"eslint-plugin-prettier": "3.1.0",
"eslint": "8.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"feed": "4.2.2",
"jsdoc": "^3.6.7",
"license-checker": "^16.0.0",
"mocha": "^5.0.4",
"sass": "1.34.0",
"prettier": "^1.11.1",
"prettier": "2.4.1",
"pug-lint": "^2.6.0",
"pug-lint-config-clock": "^2.0.0"
},

View File

@ -106,12 +106,8 @@ async function generateFeed() {
sortedVersionFiles.forEach(file => {
feed.addItem({
title: `${file.name} ${file.version}`,
id: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#${
file.version
}`,
link: `https://github.com/sitespeedio/${
file.name
}/blob/main/CHANGELOG.md#`,
id: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#${file.version}`,
link: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#`,
description: descriptions[file.name],
// content: content[file.name],
author: [

View File

@ -3,9 +3,9 @@
const cliUtil = require('../lib/cli/util'),
expect = require('chai').expect;
describe('cliUtil', function() {
describe('getURLs', function() {
it('should extract urls', function() {
describe('cliUtil', function () {
describe('getURLs', function () {
it('should extract urls', function () {
let urls = cliUtil.getURLs(['test/fixtures/sitespeed-urls.txt']);
expect(urls[0] === 'https://www.sitespeed.io');
expect(urls[3] === 'https://www.sitespeed.io/documentation/faq');
@ -16,8 +16,8 @@ describe('cliUtil', function() {
});
});
describe('getAliases', function() {
it('should extract aliases', function() {
describe('getAliases', function () {
it('should extract aliases', function () {
let aliases = cliUtil.getAliases(['test/fixtures/sitespeed-urls.txt']);
expect(aliases['https://www.sitespeed.io']).to.be.undefined;
expect(
@ -159,9 +159,7 @@ describe('cliUtil', function() {
};
cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls)
.to.be.an('array')
.with.lengthOf(2);
expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql(
@ -197,9 +195,7 @@ describe('cliUtil', function() {
};
cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls)
.to.be.an('array')
.with.lengthOf(2);
expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql(
@ -233,9 +229,7 @@ describe('cliUtil', function() {
};
cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls)
.to.be.an('array')
.with.lengthOf(2);
expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql(

View File

@ -8,9 +8,9 @@ const aggregator = require('../lib/plugins/coach/aggregator'),
const coachRunPath = path.resolve(__dirname, 'fixtures', 'coach.run-0.json');
const coachRun = JSON.parse(fs.readFileSync(coachRunPath, 'utf8'));
describe('coach', function() {
describe('aggregator', function() {
it('should summarize data', function() {
describe('coach', function () {
describe('aggregator', function () {
it('should summarize data', function () {
aggregator.addToAggregate(coachRun, 'www.sitespeed.io');
expect(aggregator.summarize()).to.not.be.empty;

View File

@ -8,11 +8,11 @@ let aggregator = require('../lib/plugins/domains/aggregator'),
Promise.promisifyAll(fs);
describe('domains', function() {
describe('aggregator', function() {
describe('domains', function () {
describe('aggregator', function () {
let har;
beforeEach(function() {
beforeEach(function () {
return fs
.readFileAsync(
path.resolve(__dirname, 'fixtures', 'www-theverge-com.har'),
@ -24,8 +24,8 @@ describe('domains', function() {
});
});
describe('#addToAggregate', function() {
it('should add har to aggregate', function() {
describe('#addToAggregate', function () {
it('should add har to aggregate', function () {
aggregator.addToAggregate(har, 'http://www.vox.com');
const summary = aggregator.summarize();
const voxDomain = summary.groups.total['cdn1.vox-cdn.com'];

View File

@ -4,9 +4,9 @@ const DataGenerator = require('../lib/plugins/graphite/data-generator'),
expect = require('chai').expect,
dayjs = require('dayjs');
describe('graphite', function() {
describe('dataGenerator', function() {
it('should generate data for gpsi.pageSummary', function() {
describe('graphite', function () {
describe('dataGenerator', function () {
it('should generate data for gpsi.pageSummary', function () {
const message = {
type: 'gpsi.pageSummary',
timestamp: '2016-01-08T12:59:06+01:00',
@ -41,7 +41,7 @@ describe('graphite', function() {
expect(data).to.match(/foo_bar/);
});
it('should generate data for domains.summary', function() {
it('should generate data for domains.summary', function () {
const message = {
type: 'domains.summary',
timestamp: '2016-01-08T12:59:06+01:00',
@ -78,7 +78,7 @@ describe('graphite', function() {
);
});
it('should generate data in statsD format', function() {
it('should generate data in statsD format', function () {
const message = {
type: 'domains.summary',
timestamp: '2016-01-08T12:59:06+01:00',
@ -111,7 +111,7 @@ describe('graphite', function() {
});
const data = generator.dataFromMessage(message, dayjs());
data.forEach(function(line) {
data.forEach(function (line) {
expect(line).to.match(
/ns.summary.sub_domain_com.chrome.cable.domains.www.sitespeed.io.dns.(median|mean|min|p10|p90|p99|max):[\d]{1,}\|ms$/
);
@ -119,7 +119,7 @@ describe('graphite', function() {
});
});
describe('index', function() {
describe('index', function () {
const messageMaker = require('../lib/support/messageMaker');
const filterRegistry = require('../lib/support/filterRegistry');
const intel = require('intel');
@ -128,7 +128,7 @@ describe('graphite', function() {
let plugin;
let options;
beforeEach(function() {
beforeEach(function () {
plugin = require('../lib/plugins/graphite');
options = {
graphite: {
@ -137,13 +137,13 @@ describe('graphite', function() {
};
});
it('Should use graphite interface by default', function() {
it('Should use graphite interface by default', function () {
plugin.open(context, options);
expect(plugin.sender.facility).to.match(/graphite/i);
});
it('Should use statsd interface', function() {
it('Should use statsd interface', function () {
Object.assign(options.graphite, {
statsd: true
});
@ -152,46 +152,46 @@ describe('graphite', function() {
expect(plugin.sender.facility).to.match(/statsd/i);
});
it('Should use graphite interface by default', function() {
it('Should use graphite interface by default', function () {
plugin.open(context, options);
expect(plugin.sender.facility).to.match(/graphite/i);
});
});
describe('helpers/is-statsd', function() {
describe('helpers/is-statsd', function () {
const isStatsD = require('../lib/plugins/graphite/helpers/is-statsd');
it('Should be set to statsd', function() {
it('Should be set to statsd', function () {
expect(isStatsD({ statsd: true })).to.be.true;
});
it('Should not be set to statsd', function() {
it('Should not be set to statsd', function () {
['true', 1, null, false, undefined].forEach(
value => expect(isStatsD({ statsd: value })).to.be.false
);
});
});
describe('helpers/format-entry', function() {
describe('helpers/format-entry', function () {
const formatEntry = require('../lib/plugins/graphite/helpers/format-entry');
it('Should retrieve the format of statsd', function() {
it('Should retrieve the format of statsd', function () {
expect(formatEntry('statsd')).to.equal('%s:%s|ms');
});
it('Should retrieve the default format of graphite', function() {
it('Should retrieve the default format of graphite', function () {
['StatsD', 'stats', 'graphite', null, false, undefined].forEach(value =>
expect(formatEntry(value)).to.equal('%s %s %s')
);
});
});
describe('GraphiteSender', function() {
describe('GraphiteSender', function () {
const GraphiteSender = require('../lib/plugins/graphite/graphite-sender');
const net = require('net');
const { connect } = net;
afterEach(function() {
afterEach(function () {
net.connect = connect;
});
@ -202,14 +202,14 @@ describe('graphite', function() {
};
}
it('Should send data to graphite via net', function(done) {
it('Should send data to graphite via net', function (done) {
mock(() => done());
const sender = new GraphiteSender('127.0.0.1', '2003');
sender.send('some.data');
});
it('Should send data to graphite in bulks', function(done) {
it('Should send data to graphite in bulks', function (done) {
let sent = 0;
mock(() => {
++sent === 2 && done();
@ -220,12 +220,12 @@ describe('graphite', function() {
});
});
describe('StatsDSender', function() {
describe('StatsDSender', function () {
const StatsDSender = require('../lib/plugins/graphite/statsd-sender');
const dgram = require('dgram');
const { createSocket } = dgram;
afterEach(function() {
afterEach(function () {
dgram.createSocket = createSocket;
});
@ -233,7 +233,7 @@ describe('graphite', function() {
dgram.createSocket = () => ({ send: fn });
}
it('Should send data to statsd via dgram', function() {
it('Should send data to statsd via dgram', function () {
let sent = false;
mock(() => {
sent = true;
@ -245,7 +245,7 @@ describe('graphite', function() {
expect(sent).to.be.true;
});
it('Should send data to statsd in bulks', function() {
it('Should send data to statsd in bulks', function () {
let sent = 0;
mock(() => {
sent++;

View File

@ -4,9 +4,9 @@ const DataGenerator = require('../lib/plugins/influxdb/data-generator'),
dayjs = require('dayjs'),
expect = require('chai').expect;
describe('influxdb', function() {
describe('dataGenerator', function() {
it('should generate data for coach.summary', function() {
describe('influxdb', function () {
describe('dataGenerator', function () {
it('should generate data for coach.summary', function () {
const message = {
uuid: '33774328-e781-4152-babe-a367cee27153',
type: 'coach.summary',

View File

@ -3,23 +3,23 @@
const pathFromRootToPageDir = require('../lib/core/resultsStorage/pathToFolder');
const expect = require('chai').expect;
describe('pathFromRootToPageDir', function() {
it('should create path from site root', function() {
describe('pathFromRootToPageDir', function () {
it('should create path from site root', function () {
const path = pathFromRootToPageDir('http://www.foo.bar', {});
expect(path).to.equal('pages/www_foo_bar/');
});
it('should create path from url', function() {
it('should create path from url', function () {
const path = pathFromRootToPageDir('http://www.foo.bar/x/y/z.html', {});
expect(path).to.equal('pages/www_foo_bar/x/y/z.html/');
});
it('should create path from url with sanitized characters', function() {
it('should create path from url with sanitized characters', function () {
const path = pathFromRootToPageDir('http://www.foo.bar/x/y/z:200.html', {});
expect(path).to.equal('pages/www_foo_bar/x/y/z-200.html/');
});
it('should create path from url with query string', function() {
it('should create path from url with query string', function () {
const path = pathFromRootToPageDir('http://www.foo.bar/x/y/z?foo=bar', {});
expect(path).to.equal('pages/www_foo_bar/x/y/z/query-115ffe20/');
});

View File

@ -1,4 +1,4 @@
module.exports = async function(context, commands) {
module.exports = async function (context, commands) {
await commands.measure.start('https://www.sitespeed.io');
await commands.measure.start('https://www.sitespeed.io/examples/');
return commands.measure.start('https://www.sitespeed.io/documentation/');

View File

@ -1,3 +1,3 @@
module.exports = async function(context) {
module.exports = async function (context) {
context.log.info('In posttask!!!');
};

View File

@ -1,4 +1,4 @@
module.exports = async function(context, commands) {
module.exports = async function (context, commands) {
context.log.info('In pretask!!!');
await commands.navigate('https://www.sitespeed.io/');
context.taskData.loadedSitespeed = true;

View File

@ -12,9 +12,9 @@ function createResultUrls(url, outputFolder, resultBaseURL) {
.resultUrls;
}
describe('resultUrls', function() {
describe('#hasBaseUrl', function() {
it('should be false if base url is missing', function() {
describe('resultUrls', function () {
describe('#hasBaseUrl', function () {
it('should be false if base url is missing', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
undefined,
@ -23,7 +23,7 @@ describe('resultUrls', function() {
expect(resultUrls.hasBaseUrl()).to.be.false;
});
it('should be true if base url is present', function() {
it('should be true if base url is present', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
undefined,
@ -33,8 +33,8 @@ describe('resultUrls', function() {
});
});
describe('#reportSummaryUrl', function() {
it('should create url with default output folder', function() {
describe('#reportSummaryUrl', function () {
it('should create url with default output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
undefined,
@ -44,7 +44,7 @@ describe('resultUrls', function() {
`http://results.com/www.foo.bar/${timestampString}`
);
});
it('should create url with absolute output folder', function() {
it('should create url with absolute output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'/root/leaf',
@ -52,7 +52,7 @@ describe('resultUrls', function() {
);
expect(resultUrls.reportSummaryUrl()).to.equal('http://results.com/leaf');
});
it('should create url with relative output folder', function() {
it('should create url with relative output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'../leaf',
@ -61,8 +61,8 @@ describe('resultUrls', function() {
expect(resultUrls.reportSummaryUrl()).to.equal('http://results.com/leaf');
});
});
describe('#absoluteSummaryPageUrl', function() {
it('should create url with default output folder', function() {
describe('#absoluteSummaryPageUrl', function () {
it('should create url with default output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
undefined,
@ -74,7 +74,7 @@ describe('resultUrls', function() {
`http://results.com/www.foo.bar/${timestampString}/pages/www_foo_bar/xyz/`
);
});
it('should create url with absolute output folder', function() {
it('should create url with absolute output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'/root/leaf',
@ -84,7 +84,7 @@ describe('resultUrls', function() {
resultUrls.absoluteSummaryPageUrl('http://www.foo.bar/xyz')
).to.equal('http://results.com/leaf/pages/www_foo_bar/xyz/');
});
it('should create url with relative output folder', function() {
it('should create url with relative output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'../leaf',
@ -95,8 +95,8 @@ describe('resultUrls', function() {
).to.equal('http://results.com/leaf/pages/www_foo_bar/xyz/');
});
});
describe('#relativeSummaryPageUrl', function() {
it('should create url with default output folder', function() {
describe('#relativeSummaryPageUrl', function () {
it('should create url with default output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
undefined,
@ -106,7 +106,7 @@ describe('resultUrls', function() {
resultUrls.relativeSummaryPageUrl('http://www.foo.bar/xyz')
).to.equal('pages/www_foo_bar/xyz/');
});
it('should create url with absolute output folder', function() {
it('should create url with absolute output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'/root/leaf',
@ -116,7 +116,7 @@ describe('resultUrls', function() {
resultUrls.relativeSummaryPageUrl('http://www.foo.bar/xyz')
).to.equal('pages/www_foo_bar/xyz/');
});
it('should create url with relative output folder', function() {
it('should create url with relative output folder', function () {
const resultUrls = createResultUrls(
'http://www.foo.bar',
'../leaf',

View File

@ -12,9 +12,9 @@ function createManager(url, outputFolder) {
return resultsStorage(url, timestamp, { outputFolder }).storageManager;
}
describe('storageManager', function() {
describe('#rootPathFromUrl', function() {
it('should create path from url', function() {
describe('storageManager', function () {
describe('#rootPathFromUrl', function () {
it('should create path from url', function () {
const storageManager = createManager('http://www.foo.bar');
const path = storageManager.rootPathFromUrl(
'http://www.foo.bar/x/y/z.html'
@ -22,7 +22,7 @@ describe('storageManager', function() {
expect(path).to.equal('../../../../../');
});
it('should create path from url with query string', function() {
it('should create path from url with query string', function () {
const storageManager = createManager('http://www.foo.bar');
const path = storageManager.rootPathFromUrl(
'http://www.foo.bar/x/y/z?foo=bar'
@ -31,14 +31,14 @@ describe('storageManager', function() {
});
});
describe('#getBaseDir', function() {
it('should create base dir with default output folder', function() {
describe('#getBaseDir', function () {
it('should create base dir with default output folder', function () {
const storageManager = createManager('http://www.foo.bar');
expect(storageManager.getBaseDir()).to.equal(
path.resolve('sitespeed-result', 'www.foo.bar', timestampString)
);
});
it('should create base dir with custom output folder', function() {
it('should create base dir with custom output folder', function () {
const storageManager = createManager(
'http://www.foo.bar',
'/tmp/sitespeed.io/foo'
@ -47,14 +47,14 @@ describe('storageManager', function() {
});
});
describe('#getStoragePrefix', function() {
it('should create prefix with default output folder', function() {
describe('#getStoragePrefix', function () {
it('should create prefix with default output folder', function () {
const storageManager = createManager('http://www.foo.bar');
expect(storageManager.getStoragePrefix()).to.equal(
path.join('www.foo.bar', timestampString)
);
});
it('should create prefix with custom output folder', function() {
it('should create prefix with custom output folder', function () {
const storageManager = createManager(
'http://www.foo.bar',
'/tmp/sitespeed.io/foo'

View File

@ -9,7 +9,7 @@ checker.init(
{
start: '.'
},
function(err, json) {
function (err, json) {
if (err) {
console.error(err.message);
process.exit(1);

View File

@ -4,8 +4,8 @@
const net = require('net');
const server = net
.createServer(function(sock) {
sock.on('data', function(data) {
.createServer(function (sock) {
sock.on('data', function (data) {
console.log(data.toString());
});
})

View File

@ -4,11 +4,11 @@
const dgram = require('dgram');
const server = dgram.createSocket('udp4');
server.on('message', function(msg) {
server.on('message', function (msg) {
console.log(msg.toString());
});
server.on('listening', function() {
server.on('listening', function () {
const address = server.address();
console.log('udp server listening ' + address.address + ':' + address.port);
});