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": [ "prettier/prettier": [
"error", "error",
{ {
"singleQuote": true "singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"embeddedLanguageFormatting": "off"
} }
], ],
"require-atomic-updates": 0, "require-atomic-updates": 0,

View File

@ -5,13 +5,11 @@ module.exports = {
{ value: 'docs', name: 'docs: Documentation only changes' }, { value: 'docs', name: 'docs: Documentation only changes' },
{ {
value: 'style', value: 'style',
name: name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)'
'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)'
}, },
{ {
value: 'refactor', value: 'refactor',
name: name: 'refactor: A code change that neither fixes a bug nor adds a feature'
'refactor: A code change that neither fixes a bug nor adds a feature'
}, },
{ {
value: 'perf', value: 'perf',
@ -20,8 +18,7 @@ module.exports = {
{ value: 'test', name: 'test: Adding missing tests' }, { value: 'test', name: 'test: Adding missing tests' },
{ {
value: 'chore', value: 'chore',
name: name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation'
'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: 'revert', name: 'revert: Revert to a commit' },
{ value: 'WIP', name: 'WIP: Work in progress' } { value: 'WIP', name: 'WIP: Work in progress' }
@ -57,8 +54,7 @@ module.exports = {
// used if allowCustomScopes is true // used if allowCustomScopes is true
// customScope: 'Denote the SCOPE of this change:', // customScope: 'Denote the SCOPE of this change:',
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
body: body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional):\n', breaking: 'List any BREAKING CHANGES (optional):\n',
footer: footer:
'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n', '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') .alias('help', 'h')
.config(config) .config(config)
.alias('version', 'V') .alias('version', 'V')
.coerce('budget', function(arg) { .coerce('budget', function (arg) {
if (arg) { if (arg) {
if (typeof arg === 'object' && !Array.isArray(arg)) { if (typeof arg === 'object' && !Array.isArray(arg)) {
if (arg.configPath) { if (arg.configPath) {
@ -1507,7 +1507,7 @@ module.exports.parseCommandLine = function parseCommandLine() {
return plugins; return plugins;
} }
}) })
.coerce('webpagetest', function(arg) { .coerce('webpagetest', function (arg) {
if (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) // 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)) { if (arg.script && fs.existsSync(arg.script)) {

View File

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

View File

@ -40,9 +40,7 @@ function validateMessageFormat(message) {
if (previousDepth && previousDepth !== typeDepth) { if (previousDepth && previousDepth !== typeDepth) {
throw new Error( throw new Error(
`All messages of type ${baseType} must have the same structure. ` + `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; return domainOrFile;
} }
module.exports = function(input, timestamp, options) { module.exports = function (input, timestamp, options) {
const outputFolder = options.outputFolder; const outputFolder = options.outputFolder;
const resultBaseURL = options.resultBaseURL; const resultBaseURL = options.resultBaseURL;
const resultsSubFolders = []; const resultsSubFolders = [];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ function addExtraScripts(scriptsByCategory, pluginScripts) {
// For all different script in the array // For all different script in the array
for (let scripts of pluginScripts) { for (let scripts of pluginScripts) {
// and then for all scripts in that category // 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); set(scriptsByCategory, scripts.category + '.' + name, script);
}); });
} }
@ -80,7 +80,7 @@ function setupAsynScripts(asyncScripts) {
// For all different script in the array // For all different script in the array
for (let scripts of asyncScripts) { for (let scripts of asyncScripts) {
// and then for all scripts in that category // 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); 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 // We step 100 ms each step ... but if you wanna show all and the last change is late
// use 200 ms // use 200 ms
const step = const step =
maxTiming > 10000 && (options.filmstrip && options.filmstrip.showAll) maxTiming > 10000 && options.filmstrip && options.filmstrip.showAll
? 200 ? 200
: 100; : 100;
let fileName = ''; let fileName = '';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,13 +14,8 @@ class StatsDSender extends Sender {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const client = dgram.createSocket('udp4'); const client = dgram.createSocket('udp4');
client.send( client.send(data, 0, data.length, this.port, this.host, error =>
data, client.close() && error ? reject(error) : resolve()
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, resultUrls: this.context.resultUrls,
assetsPath: assetsBaseURL || rootPath, assetsPath: assetsBaseURL || rootPath,
menu: 'pages', menu: 'pages',
pageTitle: `Run ${parseInt(runIndex) + pageTitle: `Run ${
1} for ${url} at ${runTimestamp}`, parseInt(runIndex) + 1
} for ${url} at ${runTimestamp}`,
pageDescription: `${metricHelper.getMetricsFromRun( pageDescription: `${metricHelper.getMetricsFromRun(
pageInfo pageInfo
)} collected by sitespeed.io ${packageInfo.version}`, )} collected by sitespeed.io ${packageInfo.version}`,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ const get = require('lodash.get');
const h = require('../../support/helpers'); const h = require('../../support/helpers');
const tsdbUtil = require('../../support/tsdbUtil'); 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 base = dataCollector.getSummary() || {};
const metrics = { const metrics = {
firstPaint: { firstPaint: {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
module.exports = function(url, longVersion) { module.exports = function (url, longVersion) {
if (longVersion) { if (longVersion) {
if (url.length > 100) { if (url.length > 100) {
let shortUrl = url.replace(/\?.*/, ''); 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", "changelog-parser": "2.8.0",
"clean-css-cli": "4.3.0", "clean-css-cli": "4.3.0",
"cz-customizable": "^6.2.0", "cz-customizable": "^6.2.0",
"eslint": "6.2.2", "eslint": "8.0.0",
"eslint-config-prettier": "6.1.0", "eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.1.0", "eslint-plugin-prettier": "4.0.0",
"feed": "4.2.2", "feed": "4.2.2",
"jsdoc": "^3.6.7", "jsdoc": "^3.6.7",
"license-checker": "^16.0.0", "license-checker": "^16.0.0",
"mocha": "^5.0.4", "mocha": "^5.0.4",
"sass": "1.34.0", "sass": "1.34.0",
"prettier": "^1.11.1", "prettier": "2.4.1",
"pug-lint": "^2.6.0", "pug-lint": "^2.6.0",
"pug-lint-config-clock": "^2.0.0" "pug-lint-config-clock": "^2.0.0"
}, },

View File

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

View File

@ -3,9 +3,9 @@
const cliUtil = require('../lib/cli/util'), const cliUtil = require('../lib/cli/util'),
expect = require('chai').expect; expect = require('chai').expect;
describe('cliUtil', function() { describe('cliUtil', function () {
describe('getURLs', function() { describe('getURLs', function () {
it('should extract urls', function() { it('should extract urls', function () {
let urls = cliUtil.getURLs(['test/fixtures/sitespeed-urls.txt']); let urls = cliUtil.getURLs(['test/fixtures/sitespeed-urls.txt']);
expect(urls[0] === 'https://www.sitespeed.io'); expect(urls[0] === 'https://www.sitespeed.io');
expect(urls[3] === 'https://www.sitespeed.io/documentation/faq'); expect(urls[3] === 'https://www.sitespeed.io/documentation/faq');
@ -16,8 +16,8 @@ describe('cliUtil', function() {
}); });
}); });
describe('getAliases', function() { describe('getAliases', function () {
it('should extract aliases', function() { it('should extract aliases', function () {
let aliases = cliUtil.getAliases(['test/fixtures/sitespeed-urls.txt']); let aliases = cliUtil.getAliases(['test/fixtures/sitespeed-urls.txt']);
expect(aliases['https://www.sitespeed.io']).to.be.undefined; expect(aliases['https://www.sitespeed.io']).to.be.undefined;
expect( expect(
@ -159,9 +159,7 @@ describe('cliUtil', function() {
}; };
cliUtil.registerPluginOptions(fakeYargs, plugin); cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls) expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
.to.be.an('array')
.with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }]; const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql( expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql(
@ -197,9 +195,7 @@ describe('cliUtil', function() {
}; };
cliUtil.registerPluginOptions(fakeYargs, plugin); cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls) expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
.to.be.an('array')
.with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }]; const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql( expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql(
@ -233,9 +229,7 @@ describe('cliUtil', function() {
}; };
cliUtil.registerPluginOptions(fakeYargs, plugin); cliUtil.registerPluginOptions(fakeYargs, plugin);
expect(fakeYargs.calls) expect(fakeYargs.calls).to.be.an('array').with.lengthOf(2);
.to.be.an('array')
.with.lengthOf(2);
const expectedProp1 = ['test.prop1', { default: 80 }]; const expectedProp1 = ['test.prop1', { default: 80 }];
expect(fakeYargs.calls.find(call => call[0] === 'test.prop1')).to.eql( 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 coachRunPath = path.resolve(__dirname, 'fixtures', 'coach.run-0.json');
const coachRun = JSON.parse(fs.readFileSync(coachRunPath, 'utf8')); const coachRun = JSON.parse(fs.readFileSync(coachRunPath, 'utf8'));
describe('coach', function() { describe('coach', function () {
describe('aggregator', function() { describe('aggregator', function () {
it('should summarize data', function() { it('should summarize data', function () {
aggregator.addToAggregate(coachRun, 'www.sitespeed.io'); aggregator.addToAggregate(coachRun, 'www.sitespeed.io');
expect(aggregator.summarize()).to.not.be.empty; expect(aggregator.summarize()).to.not.be.empty;

View File

@ -8,11 +8,11 @@ let aggregator = require('../lib/plugins/domains/aggregator'),
Promise.promisifyAll(fs); Promise.promisifyAll(fs);
describe('domains', function() { describe('domains', function () {
describe('aggregator', function() { describe('aggregator', function () {
let har; let har;
beforeEach(function() { beforeEach(function () {
return fs return fs
.readFileAsync( .readFileAsync(
path.resolve(__dirname, 'fixtures', 'www-theverge-com.har'), path.resolve(__dirname, 'fixtures', 'www-theverge-com.har'),
@ -24,8 +24,8 @@ describe('domains', function() {
}); });
}); });
describe('#addToAggregate', function() { describe('#addToAggregate', function () {
it('should add har to aggregate', function() { it('should add har to aggregate', function () {
aggregator.addToAggregate(har, 'http://www.vox.com'); aggregator.addToAggregate(har, 'http://www.vox.com');
const summary = aggregator.summarize(); const summary = aggregator.summarize();
const voxDomain = summary.groups.total['cdn1.vox-cdn.com']; 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, expect = require('chai').expect,
dayjs = require('dayjs'); dayjs = require('dayjs');
describe('graphite', function() { describe('graphite', function () {
describe('dataGenerator', function() { describe('dataGenerator', function () {
it('should generate data for gpsi.pageSummary', function() { it('should generate data for gpsi.pageSummary', function () {
const message = { const message = {
type: 'gpsi.pageSummary', type: 'gpsi.pageSummary',
timestamp: '2016-01-08T12:59:06+01:00', timestamp: '2016-01-08T12:59:06+01:00',
@ -41,7 +41,7 @@ describe('graphite', function() {
expect(data).to.match(/foo_bar/); expect(data).to.match(/foo_bar/);
}); });
it('should generate data for domains.summary', function() { it('should generate data for domains.summary', function () {
const message = { const message = {
type: 'domains.summary', type: 'domains.summary',
timestamp: '2016-01-08T12:59:06+01:00', 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 = { const message = {
type: 'domains.summary', type: 'domains.summary',
timestamp: '2016-01-08T12:59:06+01:00', timestamp: '2016-01-08T12:59:06+01:00',
@ -111,7 +111,7 @@ describe('graphite', function() {
}); });
const data = generator.dataFromMessage(message, dayjs()); const data = generator.dataFromMessage(message, dayjs());
data.forEach(function(line) { data.forEach(function (line) {
expect(line).to.match( 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$/ /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 messageMaker = require('../lib/support/messageMaker');
const filterRegistry = require('../lib/support/filterRegistry'); const filterRegistry = require('../lib/support/filterRegistry');
const intel = require('intel'); const intel = require('intel');
@ -128,7 +128,7 @@ describe('graphite', function() {
let plugin; let plugin;
let options; let options;
beforeEach(function() { beforeEach(function () {
plugin = require('../lib/plugins/graphite'); plugin = require('../lib/plugins/graphite');
options = { options = {
graphite: { 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); plugin.open(context, options);
expect(plugin.sender.facility).to.match(/graphite/i); expect(plugin.sender.facility).to.match(/graphite/i);
}); });
it('Should use statsd interface', function() { it('Should use statsd interface', function () {
Object.assign(options.graphite, { Object.assign(options.graphite, {
statsd: true statsd: true
}); });
@ -152,46 +152,46 @@ describe('graphite', function() {
expect(plugin.sender.facility).to.match(/statsd/i); 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); plugin.open(context, options);
expect(plugin.sender.facility).to.match(/graphite/i); 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'); 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; 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( ['true', 1, null, false, undefined].forEach(
value => expect(isStatsD({ statsd: value })).to.be.false 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'); 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'); 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 => ['StatsD', 'stats', 'graphite', null, false, undefined].forEach(value =>
expect(formatEntry(value)).to.equal('%s %s %s') expect(formatEntry(value)).to.equal('%s %s %s')
); );
}); });
}); });
describe('GraphiteSender', function() { describe('GraphiteSender', function () {
const GraphiteSender = require('../lib/plugins/graphite/graphite-sender'); const GraphiteSender = require('../lib/plugins/graphite/graphite-sender');
const net = require('net'); const net = require('net');
const { connect } = net; const { connect } = net;
afterEach(function() { afterEach(function () {
net.connect = connect; 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()); mock(() => done());
const sender = new GraphiteSender('127.0.0.1', '2003'); const sender = new GraphiteSender('127.0.0.1', '2003');
sender.send('some.data'); 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; let sent = 0;
mock(() => { mock(() => {
++sent === 2 && done(); ++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 StatsDSender = require('../lib/plugins/graphite/statsd-sender');
const dgram = require('dgram'); const dgram = require('dgram');
const { createSocket } = dgram; const { createSocket } = dgram;
afterEach(function() { afterEach(function () {
dgram.createSocket = createSocket; dgram.createSocket = createSocket;
}); });
@ -233,7 +233,7 @@ describe('graphite', function() {
dgram.createSocket = () => ({ send: fn }); 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; let sent = false;
mock(() => { mock(() => {
sent = true; sent = true;
@ -245,7 +245,7 @@ describe('graphite', function() {
expect(sent).to.be.true; 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; let sent = 0;
mock(() => { mock(() => {
sent++; sent++;

View File

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

View File

@ -3,23 +3,23 @@
const pathFromRootToPageDir = require('../lib/core/resultsStorage/pathToFolder'); const pathFromRootToPageDir = require('../lib/core/resultsStorage/pathToFolder');
const expect = require('chai').expect; const expect = require('chai').expect;
describe('pathFromRootToPageDir', function() { describe('pathFromRootToPageDir', function () {
it('should create path from site root', function() { it('should create path from site root', function () {
const path = pathFromRootToPageDir('http://www.foo.bar', {}); const path = pathFromRootToPageDir('http://www.foo.bar', {});
expect(path).to.equal('pages/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', {}); const path = pathFromRootToPageDir('http://www.foo.bar/x/y/z.html', {});
expect(path).to.equal('pages/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', {}); 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/'); 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', {}); 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/'); 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');
await commands.measure.start('https://www.sitespeed.io/examples/'); await commands.measure.start('https://www.sitespeed.io/examples/');
return commands.measure.start('https://www.sitespeed.io/documentation/'); 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!!!'); 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!!!'); context.log.info('In pretask!!!');
await commands.navigate('https://www.sitespeed.io/'); await commands.navigate('https://www.sitespeed.io/');
context.taskData.loadedSitespeed = true; context.taskData.loadedSitespeed = true;

View File

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

View File

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

View File

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

View File

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

View File

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