- ${joinFragments(fileSet, name =>
+ ${joinFragments(fileSet, (name) =>
PlaceholderFileListItem({
name,
href: maybePrefixExampleDocHref(
diff --git a/build-system/server/app-index/form.js b/build-system/server/app-index/form.js
index 566a6a4381c2..b8bd5a625d7b 100644
--- a/build-system/server/app-index/form.js
+++ b/build-system/server/app-index/form.js
@@ -19,13 +19,11 @@
const {html} = require('./html');
const Option = ({value, name}) =>
- html`
-
- `;
+ html`
`;
-const KeyValueOptions = options =>
+const KeyValueOptions = (options) =>
Object.keys(options)
- .map(name =>
+ .map((name) =>
Option({
name,
value: options[name],
diff --git a/build-system/server/app-index/html.js b/build-system/server/app-index/html.js
index 87c1786a1a98..26488560a77d 100644
--- a/build-system/server/app-index/html.js
+++ b/build-system/server/app-index/html.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-const identity = a => a;
+const identity = (a) => a;
/**
* Takes a set of HTML fragments and concatenates them.
diff --git a/build-system/server/app-index/template.js b/build-system/server/app-index/template.js
index 9a8c0868fea9..ebc36f6fb269 100644
--- a/build-system/server/app-index/template.js
+++ b/build-system/server/app-index/template.js
@@ -53,10 +53,7 @@ const Header = ({isMainPage, links}) => html`
`;
-const HeaderBackToMainLink = () =>
- html`
-
← Back to main
- `;
+const HeaderBackToMainLink = () => html`
← Back to main `;
const ProxyFormOptional = ({isMainPage}) => (isMainPage ? ProxyForm() : '');
diff --git a/build-system/server/app-index/url.js b/build-system/server/app-index/url.js
index 91a5fa43e903..7e8beddcfef0 100644
--- a/build-system/server/app-index/url.js
+++ b/build-system/server/app-index/url.js
@@ -18,7 +18,7 @@ const appendQueryParamsToUrl = (url, params) =>
url +
'?' +
Object.keys(params)
- .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
+ .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
.join('&');
const leadingSlashRegex = /^\//;
diff --git a/build-system/server/app-index/util/listing.js b/build-system/server/app-index/util/listing.js
index 57bb873a718f..7a560033642e 100644
--- a/build-system/server/app-index/util/listing.js
+++ b/build-system/server/app-index/util/listing.js
@@ -53,7 +53,7 @@ function isMainPageFromUrl(url) {
* @return {string}
*/
function formatBasepath(basepath) {
- return basepath.replace(/[^\/]$/, lastChar => `${lastChar}/`);
+ return basepath.replace(/[^\/]$/, (lastChar) => `${lastChar}/`);
}
module.exports = {
diff --git a/build-system/server/app-utils.js b/build-system/server/app-utils.js
index c016730073d0..f7f836a4d972 100644
--- a/build-system/server/app-utils.js
+++ b/build-system/server/app-utils.js
@@ -78,7 +78,7 @@ function logServeMode() {
* @param {string} serveMode
* @return {boolean}
*/
-const isRtvMode = serveMode => {
+const isRtvMode = (serveMode) => {
return /^\d{15}$/.test(serveMode);
};
diff --git a/build-system/server/app.js b/build-system/server/app.js
index 06699a2e283f..21e6efbddfb3 100644
--- a/build-system/server/app.js
+++ b/build-system/server/app.js
@@ -243,7 +243,7 @@ app.use('/pwa', (req, res) => {
}
res.statusCode = 200;
res.setHeader('Content-Type', contentType);
- fs.promises.readFile(pc.cwd() + file).then(file => {
+ fs.promises.readFile(pc.cwd() + file).then((file) => {
res.end(file);
});
});
@@ -304,7 +304,7 @@ app.use('/form/echo-json/post', (req, res) => {
cors.assertCors(req, res, ['POST']);
const form = new formidable.IncomingForm();
const fields = Object.create(null);
- form.on('field', function(name, value) {
+ form.on('field', function (name, value) {
if (!(name in fields)) {
fields[name] = value;
return;
@@ -320,7 +320,7 @@ app.use('/form/echo-json/post', (req, res) => {
}
fields[realName].push(value);
});
- form.parse(req, unusedErr => {
+ form.parse(req, (unusedErr) => {
res.setHeader('Content-Type', 'application/json; charset=utf-8');
if (fields['email'] == 'already@subscribed.com') {
res.statusCode = 500;
@@ -414,7 +414,7 @@ app.use('/form/autocomplete/query', (req, res) => {
res.json({items: autocompleteColors});
} else {
const lowerCaseQuery = query.toLowerCase();
- const filtered = autocompleteColors.filter(l =>
+ const filtered = autocompleteColors.filter((l) =>
l.toLowerCase().includes(lowerCaseQuery)
);
res.json({items: filtered});
@@ -432,7 +432,7 @@ app.use('/form/mention/query', (req, res) => {
return;
}
const lowerCaseQuery = query.toLowerCase().trim();
- const filtered = autocompleteEmailData.filter(l =>
+ const filtered = autocompleteEmailData.filter((l) =>
l.toLowerCase().startsWith(lowerCaseQuery)
);
res.json({items: filtered});
@@ -493,7 +493,7 @@ function proxyToAmpProxy(req, res, mode) {
(req.query['amp_js_v'] ? 'v' : 'c') +
req.url;
console.log('Fetching URL: ' + url);
- request(url, function(error, response, body) {
+ request(url, function (error, response, body) {
body = body
// Unversion URLs.
.replace(
@@ -585,7 +585,7 @@ app.use('/examples/live-list-update(-reverse)?.amp.html', (req, res, next) => {
pagination.textContent = '';
const liveChildren = [].slice
.call(items.children)
- .filter(x => !x.hasAttribute('data-tombstone'));
+ .filter((x) => !x.hasAttribute('data-tombstone'));
const pageCount = Math.ceil(liveChildren.length / perPage);
const pageListItems = Array.apply(null, Array(pageCount))
@@ -867,7 +867,7 @@ app.get('/a4a_template/*', (req, res) => {
`0.1/data/${match[2]}.template`;
fs.promises
.readFile(filePath)
- .then(file => {
+ .then((file) => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('AMP-template-amp-creative', 'amp-mustache');
res.end(file);
@@ -948,7 +948,7 @@ app.get(
const urlPrefix = getUrlPrefix(req);
fs.promises
.readFile(pc.cwd() + filePath, 'utf8')
- .then(file => {
+ .then((file) => {
if (req.query['amp_js_v']) {
file = addViewerIntegrationScript(req.query['amp_js_v'], file);
}
@@ -1029,7 +1029,7 @@ app.get(
if (stream > 0) {
res.writeHead(200, {'Content-Type': 'text/html'});
let pos = 0;
- const writeChunk = function() {
+ const writeChunk = function () {
const chunk = file.substring(
pos,
Math.min(pos + stream, file.length)
@@ -1172,7 +1172,7 @@ app.get('/adzerk/*', (req, res) => {
pc.cwd() + '/extensions/amp-ad-network-adzerk-impl/0.1/data/' + match[1];
fs.promises
.readFile(filePath)
- .then(file => {
+ .then((file) => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('AMP-Ad-Template-Extension', 'amp-mustache');
res.setHeader('AMP-Ad-Response-Type', 'template');
@@ -1229,7 +1229,7 @@ app.get(
// This will not be useful until extension-location.js change in prod
// Require url from cdn
const filePath = 'https://cdn.ampproject.org/' + fileName;
- request(filePath, function(error, response) {
+ request(filePath, function (error, response) {
if (error) {
res.status(404);
res.end();
@@ -1266,7 +1266,7 @@ app.get('/dist/sw(.max)?.js', (req, res, next) => {
const filePath = req.path;
fs.promises
.readFile(pc.cwd() + filePath, 'utf8')
- .then(file => {
+ .then((file) => {
let n = new Date();
// Round down to the nearest 5 minutes.
n -=
@@ -1298,7 +1298,7 @@ app.get('/dist/rtv/9[89]*/*.js', (req, res, next) => {
const path = req.path.replace(/rtv\/\d+/, '');
return fs.promises
.readFile(pc.cwd() + path, 'utf8')
- .then(file => {
+ .then((file) => {
res.end(file);
})
.catch(next);
@@ -1316,7 +1316,7 @@ app.get(['/dist/cache-sw.html'], (req, res, next) => {
const filePath = '/test/manual/cache-sw.html';
fs.promises
.readFile(pc.cwd() + filePath, 'utf8')
- .then(file => {
+ .then((file) => {
let n = new Date();
// Round down to the nearest 5 minutes.
n -=
@@ -1360,7 +1360,7 @@ app.get('/dist/diversions', (req, res) => {
* Web worker binary.
*/
app.get('/dist/ww(.max)?.js', (req, res) => {
- fs.promises.readFile(pc.cwd() + req.path).then(file => {
+ fs.promises.readFile(pc.cwd() + req.path).then((file) => {
res.setHeader('Content-Type', 'text/javascript');
res.setHeader('Access-Control-Allow-Origin', '*');
res.end(file);
@@ -1498,7 +1498,7 @@ app.use('(/dist)?/rtv/*/v0/analytics-vendors/:vendor.json', (req, res) => {
fs.promises
.readFile(localVendorConfigPath)
- .then(file => {
+ .then((file) => {
res.setHeader('Content-Type', 'application/json');
res.end(file);
})
diff --git a/build-system/server/lazy-build.js b/build-system/server/lazy-build.js
index 1a25c561f57c..44153b9708e1 100644
--- a/build-system/server/lazy-build.js
+++ b/build-system/server/lazy-build.js
@@ -87,7 +87,7 @@ async function build(bundles, name, buildFunc) {
bundle.pendingBuild = buildFunc(bundles, name, {
watch: true,
minify: argv.compiled,
- onWatchBuild: async bundlePromise => {
+ onWatchBuild: async (bundlePromise) => {
bundle.pendingBuild = bundlePromise;
await bundlePromise;
bundle.pendingBuild = undefined;
diff --git a/build-system/server/recaptcha-router.js b/build-system/server/recaptcha-router.js
index eb5f48535644..9f4946b09abe 100644
--- a/build-system/server/recaptcha-router.js
+++ b/build-system/server/recaptcha-router.js
@@ -32,7 +32,7 @@ window.grecaptcha = {
const recaptchaFrameRequestHandler = (req, res, next) => {
if (argv._.includes('unit') || argv._.includes('integration')) {
- fs.promises.readFile(pc.cwd() + req.path, 'utf8').then(file => {
+ fs.promises.readFile(pc.cwd() + req.path, 'utf8').then((file) => {
file = file.replace(
/initRecaptcha\(.*\)/g,
'initRecaptcha("/recaptcha/mock.js?sitekey=")'
@@ -55,12 +55,12 @@ recaptchaRouter.post('/submit', upload.array(), (req, res) => {
message: 'Success!',
};
- Object.keys(req.body).forEach(bodyKey => {
+ Object.keys(req.body).forEach((bodyKey) => {
responseJson[bodyKey] = req.body[bodyKey];
});
const containsRecaptchaInResponse = Object.keys(responseJson).some(
- responseJsonKey => {
+ (responseJsonKey) => {
return responseJsonKey.toLowerCase().includes('recaptcha');
}
);
diff --git a/build-system/server/routes/a4a-envelopes.js b/build-system/server/routes/a4a-envelopes.js
index 2514716a9032..1247b611f63b 100644
--- a/build-system/server/routes/a4a-envelopes.js
+++ b/build-system/server/routes/a4a-envelopes.js
@@ -28,7 +28,7 @@ const {red} = require('ansi-colors');
app.use(['/inabox', '/inabox-mraid'], (req, res) => {
const templatePath =
process.cwd() + '/build-system/server/server-inabox-template.html';
- fs.promises.readFile(templatePath, 'utf8').then(template => {
+ fs.promises.readFile(templatePath, 'utf8').then((template) => {
template = template.replace(/SOURCE/g, 'AD_URL');
if (req.baseUrl == '/inabox-mraid') {
// MRAID does not load amp4ads-host-v0.js
@@ -47,7 +47,7 @@ app.use('/inabox-(friendly|safeframe)', (req, res) => {
const templatePath = '/build-system/server/server-inabox-template.html';
fs.promises
.readFile(process.cwd() + templatePath, 'utf8')
- .then(template => {
+ .then((template) => {
let url;
if (req.baseUrl == '/inabox-friendly') {
url = getInaboxUrl(req, 'inabox-viewport-friendly');
@@ -68,10 +68,10 @@ app.use('/inabox-(friendly|safeframe)', (req, res) => {
}
return requestFromUrl(template, url.href, req.query);
})
- .then(result => {
+ .then((result) => {
res.end(result);
})
- .catch(err => {
+ .catch((err) => {
log(red('Error:'), err);
res.status(500);
res.end();
@@ -86,12 +86,14 @@ app.use('/a4a(|-3p)/', (req, res) => {
const force3p = req.baseUrl.startsWith('/a4a-3p');
const templatePath = '/build-system/server/server-a4a-template.html';
const url = getInaboxUrl(req);
- fs.promises.readFile(process.cwd() + templatePath, 'utf8').then(template => {
- const content = fillTemplate(template, url.href, req.query)
- .replace(/CHECKSIG/g, force3p || '')
- .replace(/DISABLE3PFALLBACK/g, !force3p);
- res.end(replaceUrls(getServeMode(), content));
- });
+ fs.promises
+ .readFile(process.cwd() + templatePath, 'utf8')
+ .then((template) => {
+ const content = fillTemplate(template, url.href, req.query)
+ .replace(/CHECKSIG/g, force3p || '')
+ .replace(/DISABLE3PFALLBACK/g, !force3p);
+ res.end(replaceUrls(getServeMode(), content));
+ });
});
/**
diff --git a/build-system/server/routes/list.js b/build-system/server/routes/list.js
index e7743c862762..33d064e22b32 100644
--- a/build-system/server/routes/list.js
+++ b/build-system/server/routes/list.js
@@ -42,11 +42,11 @@ router.use('/vegetable-data/get', (req, res) => {
/*
* Infinite scroll related endpoints.
*/
-const randInt = n => {
+const randInt = (n) => {
return Math.floor(Math.random()) * n;
};
-const squareImgUrl = width => {
+const squareImgUrl = (width) => {
return `http://picsum.photos/${width}?${randInt(50)}`;
};
@@ -96,13 +96,13 @@ const generateResults = (category, count = 2) => {
return r;
};
-router.get('/infinite-scroll-random/:category', function(request, response) {
+router.get('/infinite-scroll-random/:category', function (request, response) {
const {category} = request.params;
const result = generateResults(category);
response.json(result);
});
-router.get('/infinite-scroll-faulty', function(req, res) {
+router.get('/infinite-scroll-faulty', function (req, res) {
const {query} = req;
const code = query['code'];
const items = generateJson(12);
@@ -113,14 +113,14 @@ router.get('/infinite-scroll-faulty', function(req, res) {
res.json({items, next});
});
-router.get('/infinite-scroll-error', function(req, res) {
+router.get('/infinite-scroll-error', function (req, res) {
const {query} = req;
const code = query['code'] || 404;
res.status(code);
res.json({'msg': code});
});
-router.get('/infinite-scroll', function(req, res) {
+router.get('/infinite-scroll', function (req, res) {
const {query} = req;
const numberOfItems = query['items'] || 10;
const pagesLeft = query['left'] || 1;
@@ -158,7 +158,7 @@ const generateJsonWithState = (numberOfItems, pagesLeft) => {
return results;
};
-router.get('/infinite-scroll-state', function(req, res) {
+router.get('/infinite-scroll-state', function (req, res) {
const {query} = req;
const numberOfItems = query['items'] || 2;
const pagesLeft = query['left'] || 0;
@@ -175,7 +175,7 @@ router.get('/infinite-scroll-state', function(req, res) {
res.json(results);
});
-router.get('/ecommerce-nested-menu', function(req, res) {
+router.get('/ecommerce-nested-menu', function (req, res) {
res.json({
'menu': [
{
diff --git a/build-system/server/routes/test.js b/build-system/server/routes/test.js
index ea1909cf72a1..98a09876d016 100644
--- a/build-system/server/routes/test.js
+++ b/build-system/server/routes/test.js
@@ -16,7 +16,7 @@
const router = require('express').Router();
-router.use('/form/post/success', function(req, res) {
+router.use('/form/post/success', function (req, res) {
delete req.query.__amp_source_origin;
res.json({
name: 'John Miller',
diff --git a/build-system/server/test-server.js b/build-system/server/test-server.js
index 03d0708ce5e0..86bfddab756c 100644
--- a/build-system/server/test-server.js
+++ b/build-system/server/test-server.js
@@ -33,26 +33,26 @@ function setCorsHeaders(req, res, next) {
}
app.use(setCorsHeaders);
-app.use('/get', function(req, res) {
+app.use('/get', function (req, res) {
res.json({
args: req.query,
headers: req.headers,
});
});
-app.use('/redirect-to', function(req, res) {
+app.use('/redirect-to', function (req, res) {
res.redirect(302, req.query.url);
});
-app.use('/status/404', function(req, res) {
+app.use('/status/404', function (req, res) {
res.status(404).end();
});
-app.use('/status/500', function(req, res) {
+app.use('/status/500', function (req, res) {
res.status(500).end();
});
-app.use('/cookies/set', function(req, res) {
+app.use('/cookies/set', function (req, res) {
delete req.query.__amp_source_origin;
for (const name in req.query) {
res./*OK*/ cookie(name, req.query[name]);
@@ -62,7 +62,7 @@ app.use('/cookies/set', function(req, res) {
});
});
-app.use('/response-headers', function(req, res) {
+app.use('/response-headers', function (req, res) {
delete req.query.__amp_source_origin;
for (const name in req.query) {
res.setHeader(name, req.query[name]);
@@ -70,14 +70,14 @@ app.use('/response-headers', function(req, res) {
res.json({});
});
-app.use('/post', function(req, res) {
+app.use('/post', function (req, res) {
delete req.query.__amp_source_origin;
res.json({
json: req.body,
});
});
-app.use('/form/post/success', function(req, res) {
+app.use('/form/post/success', function (req, res) {
delete req.query.__amp_source_origin;
res.json({
name: 'John Miller',
@@ -85,7 +85,7 @@ app.use('/form/post/success', function(req, res) {
});
});
-app.use('/form/post/error', function(req, res) {
+app.use('/form/post/error', function (req, res) {
delete req.query.__amp_source_origin;
res.status(500).json({
error: 'alreadySubscribed',
@@ -94,14 +94,14 @@ app.use('/form/post/error', function(req, res) {
});
});
-app.use('/form/post', function(req, res) {
+app.use('/form/post', function (req, res) {
delete req.query.__amp_source_origin;
res.json({
json: req.body,
});
});
-app.use('/form/verify-error', function(req, res) {
+app.use('/form/verify-error', function (req, res) {
res.status(400).json({
verifyErrors: [{name: 'email', message: 'That email is already taken.'}],
});
diff --git a/build-system/server/variable-substitution.js b/build-system/server/variable-substitution.js
index f85db9800837..0dae1fbfc80d 100644
--- a/build-system/server/variable-substitution.js
+++ b/build-system/server/variable-substitution.js
@@ -56,7 +56,7 @@ function runVariableSubstitution(req, res) {
variables = variables || {};
// Don't include the incremented number sent in to make a new request
const testParameters = Object.keys(req.query)
- .map(value => {
+ .map((value) => {
return `${value}=${req.query[value]}`;
})
.slice(1)
diff --git a/build-system/tasks/bundle-size/index.js b/build-system/tasks/bundle-size/index.js
index 100170e1282c..1d850bbcf95e 100644
--- a/build-system/tasks/bundle-size/index.js
+++ b/build-system/tasks/bundle-size/index.js
@@ -58,7 +58,7 @@ async function getBrotliBundleSizes() {
const bundleSizes = {};
log(cyan('brotli'), 'bundle sizes are:');
- const values = serialReport(process.cwd(), content =>
+ const values = serialReport(process.cwd(), (content) =>
content.replace(replacementExpression, normalizedRtvNumber)
);
let next = await values.next();
diff --git a/build-system/tasks/caches-json.js b/build-system/tasks/caches-json.js
index 9c32abe2f2dd..346b9ee33fbc 100644
--- a/build-system/tasks/caches-json.js
+++ b/build-system/tasks/caches-json.js
@@ -31,7 +31,7 @@ const cachesJsonPath = 'build-system/global-configs/caches.json';
*/
async function cachesJson() {
return gulp.src([cachesJsonPath]).pipe(
- through2.obj(function(file) {
+ through2.obj(function (file) {
let obj;
try {
obj = JSON.parse(file.contents.toString());
diff --git a/build-system/tasks/check-exact-versions.js b/build-system/tasks/check-exact-versions.js
index 3c8bac0e9338..d7bc0c013b2d 100644
--- a/build-system/tasks/check-exact-versions.js
+++ b/build-system/tasks/check-exact-versions.js
@@ -35,7 +35,7 @@ const checkerExecutable = 'npx npm-exact-versions';
*/
async function checkExactVersions() {
let success = true;
- PACKAGE_JSON_PATHS.forEach(file => {
+ PACKAGE_JSON_PATHS.forEach((file) => {
const checkerCmd = `${checkerExecutable} --path ${file}`;
const err = getStderr(checkerCmd);
if (err) {
diff --git a/build-system/tasks/check-links.js b/build-system/tasks/check-links.js
index ebc0808793e8..2f8284f8ed31 100644
--- a/build-system/tasks/check-links.js
+++ b/build-system/tasks/check-links.js
@@ -62,8 +62,8 @@ async function checkLinks() {
*/
function reportResults(results) {
const filesWithDeadLinks = results
- .filter(result => result.containsDeadLinks)
- .map(result => result.file);
+ .filter((result) => result.containsDeadLinks)
+ .map((result) => result.file);
if (filesWithDeadLinks.length > 0) {
log(
red('ERROR:'),
@@ -98,7 +98,7 @@ function reportResults(results) {
* @return {boolean} True if the link points to a file introduced by the PR.
*/
function isLinkToFileIntroducedByPR(link) {
- return filesIntroducedByPr.some(file => {
+ return filesIntroducedByPr.some((file) => {
return file.length > 0 && link.includes(path.parse(file).base);
});
}
@@ -140,7 +140,7 @@ function checkLinksInFile(file) {
// Skip links to files that were introduced by the PR.
if (isLinkToFileIntroducedByPR(link) && status == 'dead') {
// Log links with the correct github base as alive, otherwise flag deadlinks.
- const isValid = filesIntroducedByPr.some(file => {
+ const isValid = filesIntroducedByPr.some((file) => {
return link === GITHUB_BASE_PATH + file;
});
if (isValid) {
diff --git a/build-system/tasks/check-owners.js b/build-system/tasks/check-owners.js
index 6c572a0d3ee6..178e5b22e264 100644
--- a/build-system/tasks/check-owners.js
+++ b/build-system/tasks/check-owners.js
@@ -93,10 +93,10 @@ async function checkFile(file) {
const {requestErrors, fileErrors, rules} = response.body;
if (requestErrors) {
- requestErrors.forEach(err => log(red(err)));
+ requestErrors.forEach((err) => log(red(err)));
throw new Error('Could not reach the owners syntax check API');
} else if (fileErrors && fileErrors.length) {
- fileErrors.forEach(err => log(red(err)));
+ fileErrors.forEach((err) => log(red(err)));
throw new Error(`Errors encountered parsing "${file}"`);
}
diff --git a/build-system/tasks/check-types.js b/build-system/tasks/check-types.js
index 66960012b644..98fdf317b25b 100644
--- a/build-system/tasks/check-types.js
+++ b/build-system/tasks/check-types.js
@@ -47,14 +47,14 @@ async function checkTypes() {
'./ads/inabox/inabox-host.js',
'./src/web-worker/web-worker.js',
];
- const extensionValues = Object.keys(extensions).map(function(key) {
+ const extensionValues = Object.keys(extensions).map(function (key) {
return extensions[key];
});
const extensionSrcs = extensionValues
- .filter(function(extension) {
+ .filter(function (extension) {
return !extension.noTypeCheck;
})
- .map(function(extension) {
+ .map(function (extension) {
return (
'./extensions/' +
extension.name +
diff --git a/build-system/tasks/compile-jison.js b/build-system/tasks/compile-jison.js
index 4ceeb6e0c83d..ad4da510578d 100644
--- a/build-system/tasks/compile-jison.js
+++ b/build-system/tasks/compile-jison.js
@@ -45,8 +45,8 @@ async function compileJison() {
fs.mkdirSync('build/parsers', {recursive: true});
const startTime = Date.now();
const promises = [];
- jisonPaths.forEach(jisonPath => {
- glob.sync(jisonPath).forEach(jisonFile => {
+ jisonPaths.forEach((jisonPath) => {
+ glob.sync(jisonPath).forEach((jisonFile) => {
const jsFile = path.basename(jisonFile, '.jison');
const extension = jsFile.replace('-expr-impl', '');
const parser = extension + 'Parser';
diff --git a/build-system/tasks/create-golden-css/index.js b/build-system/tasks/create-golden-css/index.js
index e3e84dae4510..b9335a359dfe 100644
--- a/build-system/tasks/create-golden-css/index.js
+++ b/build-system/tasks/create-golden-css/index.js
@@ -21,7 +21,7 @@ async function createGoldenCss() {
return transformCss('./build-system/tasks/create-golden-css/css/main.css', {
normalizeWhitespace: false,
discardComments: false,
- }).then(function(result) {
+ }).then(function (result) {
fs.writeFileSync('./test/golden-files/main.css', result);
});
}
diff --git a/build-system/tasks/css.js b/build-system/tasks/css.js
index 49e397b762e2..2ef65c363ad8 100644
--- a/build-system/tasks/css.js
+++ b/build-system/tasks/css.js
@@ -75,7 +75,7 @@ const cssEntryPoints = [
*/
function compileCss(watch) {
if (watch) {
- gulpWatch('css/**/*.css', function() {
+ gulpWatch('css/**/*.css', function () {
compileCss();
});
}
@@ -99,7 +99,7 @@ function compileCss(watch) {
}
)
.pipe(gulp.dest('build'))
- .on('end', function() {
+ .on('end', function () {
mkdirSync('build');
mkdirSync('build/css');
if (append) {
@@ -119,7 +119,7 @@ function compileCss(watch) {
* @return {!Promise}
*/
function writeCssEntryPoint(path, outJs, outCss, append) {
- return jsifyCssAsync(`css/${path}`).then(css =>
+ return jsifyCssAsync(`css/${path}`).then((css) =>
writeCss(css, outJs, outCss, append)
);
}
@@ -131,7 +131,7 @@ function compileCss(watch) {
let promise = Promise.resolve();
- cssEntryPoints.forEach(entryPoint => {
+ cssEntryPoints.forEach((entryPoint) => {
const {path, outJs, outCss, append} = entryPoint;
promise = promise.then(() =>
writeCssEntryPoint(path, outJs, outCss, append)
diff --git a/build-system/tasks/csvify-size/index.js b/build-system/tasks/csvify-size/index.js
index 85f56a77355a..c429943cab6a 100644
--- a/build-system/tasks/csvify-size/index.js
+++ b/build-system/tasks/csvify-size/index.js
@@ -50,7 +50,7 @@ const dateTimes = [];
* @return {!Array
}
*/
function getLog(format) {
- return exec(`git log --format="${format}" ${filePath}`).then(logs =>
+ return exec(`git log --format="${format}" ${filePath}`).then((logs) =>
logs.trim().split('\n')
);
}
@@ -64,7 +64,7 @@ function parseSizeFile(file) {
const headers = lines[0]
.trim()
.split('|')
- .map(x => x.trim());
+ .map((x) => x.trim());
let minPos = -1;
// Find the "min" column which is the closure compiled or the "size" column
// which was previously babelify compiled file.
@@ -81,8 +81,8 @@ function parseSizeFile(file) {
lines.shift();
return lines
- .map(line => {
- const columns = line.split('|').map(x => x.trim());
+ .map((line) => {
+ const columns = line.split('|').map((x) => x.trim());
let name = columns[columns.length - 1];
// Older size.txt files contained duplicate entries of the same "entity",
@@ -131,7 +131,7 @@ function parseSizeFile(file) {
size: `"${reversePrettyBytes(columns[minPos])}"`,
};
})
- .filter(x => !!x);
+ .filter((x) => !!x);
}
/**
@@ -146,8 +146,8 @@ function mergeTables(dateTimes, tables) {
const rows = [];
// Aggregate all fields with same file name into an array
- tables.forEach(table => {
- table.forEach(field => {
+ tables.forEach((table) => {
+ table.forEach((field) => {
const {name} = field;
if (!obj[name]) {
obj[name] = [];
@@ -162,7 +162,7 @@ function mergeTables(dateTimes, tables) {
// Populate the headers array with unique file names for row 1
Object.keys(obj)
.sort()
- .forEach(fileName => {
+ .forEach((fileName) => {
// TODO(erwinm): figure out where this is occurring.
if (fileName.trim() == '""') {
return;
@@ -172,7 +172,7 @@ function mergeTables(dateTimes, tables) {
// Populate column A with all the dates we've seen and then
// populate all other columns with their respective file size if any.
- dateTimes.forEach(dateTime => {
+ dateTimes.forEach((dateTime) => {
// Seed array with empty string values
const row = Array.apply(null, Array(tableHeaders[0].length)).map(
() => '""'
@@ -228,25 +228,25 @@ function serializeCheckout(logs) {
const sha = parts.shift();
const dateTime = parts.join(' ');
- return acc.then(tables => {
+ return acc.then((tables) => {
// We checkout all the known commits for the file and accumulate
// all the tables.
return exec(`git checkout ${sha} ${filePath}`)
.then(() => {
return fs.promises.readFile(`${filePath}`);
})
- .then(file => {
+ .then((file) => {
const quotedDateTime = `"${dateTime}"`;
dateTimes.push(quotedDateTime);
// We convert the read file string into an Table objects
- const fields = parseSizeFile(file.toString()).map(field => {
+ const fields = parseSizeFile(file.toString()).map((field) => {
field.dateTime = quotedDateTime;
return field;
});
tables.push(fields);
return tables;
})
- .catch(e => {
+ .catch((e) => {
// Ignore if pathspec error. This can happen if the file was
// deleted in git.
if (/error: pathspec/.test(e.message)) {
@@ -262,11 +262,11 @@ function serializeCheckout(logs) {
async function csvifySize() {
const shaAndDate = '%H %ai';
- return getLog(shaAndDate).then(logs => {
+ return getLog(shaAndDate).then((logs) => {
// Reverse it from oldest to newest
- return serializeCheckout(logs.reverse()).then(rows => {
+ return serializeCheckout(logs.reverse()).then((rows) => {
rows.unshift.apply(rows, tableHeaders);
- const tbl = rows.map(row => row.join(',')).join('\n');
+ const tbl = rows.map((row) => row.join(',')).join('\n');
return fs.promises.writeFile('test/size.csv', `${tbl}\n`);
});
});
diff --git a/build-system/tasks/csvify-size/test.js b/build-system/tasks/csvify-size/test.js
index 37d68cb875c2..0df1efd4a284 100644
--- a/build-system/tasks/csvify-size/test.js
+++ b/build-system/tasks/csvify-size/test.js
@@ -19,7 +19,7 @@ const m = require('./');
const test = require('ava');
/*eslint "max-len": 0*/
-test('sync - parse size.txt', t => {
+test('sync - parse size.txt', (t) => {
t.plan(2);
const sizeFiles = [
` max | min | gzip | brotli | file
@@ -45,7 +45,7 @@ test('sync - parse size.txt', t => {
]);
});
-test('sync - parse table typedef', t => {
+test('sync - parse table typedef', (t) => {
t.plan(1);
const dateTimes = ['"0"', '"1"', '"2"'];
const tables = [
diff --git a/build-system/tasks/dep-check.js b/build-system/tasks/dep-check.js
index 0d312f3689e4..5762be2e6cee 100644
--- a/build-system/tasks/dep-check.js
+++ b/build-system/tasks/dep-check.js
@@ -88,7 +88,7 @@ function Rule(config) {
* @param {!Array} deps
* @return {!Array}
*/
-Rule.prototype.run = function(moduleName, deps) {
+Rule.prototype.run = function (moduleName, deps) {
// If forbidden rule and current module has no dependencies at all
// then no need to match.
if (this.type_ == 'forbidden' && !deps.length) {
@@ -103,12 +103,12 @@ Rule.prototype.run = function(moduleName, deps) {
* @param {!Array} deps
* @return {!Array}
*/
-Rule.prototype.matchBadDeps = function(moduleName, deps) {
+Rule.prototype.matchBadDeps = function (moduleName, deps) {
if (this.type_ != 'forbidden') {
return [];
}
- const isFilenameMatch = this.filesMatching_.some(x =>
+ const isFilenameMatch = this.filesMatching_.some((x) =>
minimatch(moduleName, x)
);
if (!isFilenameMatch) {
@@ -118,8 +118,8 @@ Rule.prototype.matchBadDeps = function(moduleName, deps) {
const mustNotDependErrors = [];
// These nested loops are ok as we usually only have a few rules
// to run against.
- deps.forEach(dep => {
- this.mustNotDependOn_.forEach(badDepPattern => {
+ deps.forEach((dep) => {
+ this.mustNotDependOn_.forEach((badDepPattern) => {
if (minimatch(dep, badDepPattern)) {
// Allow extension files to depend on their own code.
const dir = path.dirname(dep);
@@ -154,7 +154,7 @@ Rule.prototype.matchBadDeps = function(moduleName, deps) {
return mustNotDependErrors;
};
-const rules = depCheckConfig.rules.map(config => new Rule(config));
+const rules = depCheckConfig.rules.map((config) => new Rule(config));
/**
* Returns a list of entryPoint modules.
@@ -167,18 +167,18 @@ const rules = depCheckConfig.rules.map(config => new Rule(config));
function getSrcs() {
return fs
.readdir('extensions')
- .then(dirItems => {
+ .then((dirItems) => {
// Look for extension entry points
return flatten(
dirItems
- .map(x => `extensions/${x}`)
- .filter(x => fs.statSync(x).isDirectory())
+ .map((x) => `extensions/${x}`)
+ .filter((x) => fs.statSync(x).isDirectory())
.map(getEntryModule)
// Concat the core binary and integration binary as entry points.
.concat('src/amp.js', '3p/integration.js')
);
})
- .then(files => {
+ .then((files) => {
// Write all the entry modules into a single file so they can be processed
// together.
fs.mkdirpSync('./.amp-build');
@@ -186,7 +186,7 @@ function getSrcs() {
fs.writeFileSync(
filename,
files
- .map(file => {
+ .map((file) => {
return `import '../${file}';`;
})
.join('\n')
@@ -201,7 +201,7 @@ function getSrcs() {
*/
function getGraph(entryModule) {
let resolve;
- const promise = new Promise(r => {
+ const promise = new Promise((r) => {
resolve = r;
});
const module = Object.create(null);
@@ -216,7 +216,7 @@ function getGraph(entryModule) {
}).transform(babelify, {...BABELIFY_GLOBAL_TRANSFORM, compact: false});
bundler.pipeline.get('deps').push(
- through.obj(function(row, enc, next) {
+ through.obj(function (row, enc, next) {
module.deps.push({
name: row.file.replace(absPathRegExp, ''),
deps: row.deps,
@@ -244,11 +244,11 @@ function getEntryModule(extensionFolder) {
const extension = path.basename(extensionFolder);
return fs
.readdirSync(extensionFolder)
- .map(x => `${extensionFolder}/${x}`)
- .filter(x => fs.statSync(x).isDirectory())
- .map(x => `${x}/${extension}.js`)
- .filter(x => fs.existsSync(x))
- .filter(x => fs.statSync(x).isFile());
+ .map((x) => `${extensionFolder}/${x}`)
+ .filter((x) => fs.statSync(x).isDirectory())
+ .map((x) => `${x}/${extension}.js`)
+ .filter((x) => fs.existsSync(x))
+ .filter((x) => fs.statSync(x).isFile());
}
/**
@@ -263,14 +263,14 @@ function getEntryModule(extensionFolder) {
function flattenGraph(entryPoints) {
// Flatten the graph by just getting all the deps from all
// the entry points.
- entryPoints = entryPoints.map(entryPoint => entryPoint.deps);
+ entryPoints = entryPoints.map((entryPoint) => entryPoint.deps);
// Now make the graph have unique entries
return flatten(entryPoints).reduce((acc, cur) => {
const {name} = cur;
if (!acc[name]) {
acc[name] = Object.keys(cur.deps)
// Get rid of the absolute path for minimatch'ing
- .map(x => cur.deps[x].replace(absPathRegExp, ''));
+ .map((x) => cur.deps[x].replace(absPathRegExp, ''));
}
return acc;
}, Object.create(null));
@@ -286,17 +286,17 @@ function runRules(modules) {
const errors = [];
Object.entries(modules).forEach(([moduleName, deps]) => {
// Run Rules against the modules and flatten for reporting.
- const results = rules.flatMap(rule => rule.run(moduleName, deps));
+ const results = rules.flatMap((rule) => rule.run(moduleName, deps));
errors.push(...results);
});
rules
- .flatMap(r => Array.from(r.unusedAllowlistEntries))
- .forEach(unusedEntry => {
+ .flatMap((r) => Array.from(r.unusedAllowlistEntries))
+ .forEach((unusedEntry) => {
errors.push(cyan(unusedEntry) + ' is an unused allowlist entry');
});
- errors.forEach(error => {
+ errors.forEach((error) => {
log(red('ERROR:'), error);
});
@@ -311,15 +311,15 @@ async function depCheck() {
log('Checking dependencies...');
}
return getSrcs()
- .then(entryPoints => {
+ .then((entryPoints) => {
// This check is for extension folders that actually dont have
// an extension entry point module yet.
- entryPoints = entryPoints.filter(x => fs.existsSync(x));
+ entryPoints = entryPoints.filter((x) => fs.existsSync(x));
return Promise.all(entryPoints.map(getGraph));
})
.then(flattenGraph)
.then(runRules)
- .then(errorsFound => {
+ .then((errorsFound) => {
if (errorsFound) {
log(
yellow('NOTE:'),
diff --git a/build-system/tasks/dev-dashboard-tests.js b/build-system/tasks/dev-dashboard-tests.js
index 7b127d1eb6c6..b8d2a858fd78 100644
--- a/build-system/tasks/dev-dashboard-tests.js
+++ b/build-system/tasks/dev-dashboard-tests.js
@@ -31,18 +31,18 @@ async function devDashboardTests() {
// Add our files
const allDevDashboardTests = globby.sync(config.devDashboardTestPaths);
- allDevDashboardTests.forEach(file => {
+ allDevDashboardTests.forEach((file) => {
mocha.addFile(file);
});
// Create our deffered
let resolver;
- const deferred = new Promise(resolverIn => {
+ const deferred = new Promise((resolverIn) => {
resolver = resolverIn;
});
// Run the tests.
- mocha.run(function(failures) {
+ mocha.run(function (failures) {
if (failures) {
process.exitCode = 1;
}
diff --git a/build-system/tasks/dist.js b/build-system/tasks/dist.js
index 6eb05433c5a5..394813d658b1 100644
--- a/build-system/tasks/dist.js
+++ b/build-system/tasks/dist.js
@@ -188,8 +188,8 @@ function buildLoginDone(version) {
async function buildWebPushPublisherFiles() {
const distDir = 'dist/v0';
const promises = [];
- WEB_PUSH_PUBLISHER_VERSIONS.forEach(version => {
- WEB_PUSH_PUBLISHER_FILES.forEach(fileName => {
+ WEB_PUSH_PUBLISHER_VERSIONS.forEach((version) => {
+ WEB_PUSH_PUBLISHER_FILES.forEach((fileName) => {
const tempBuildDir = `build/all/amp-web-push-${version}/`;
const builtName = fileName + '.js';
const minifiedName = maybeToEsmName(fileName + '.js');
@@ -273,7 +273,7 @@ async function generateFileListing() {
const distDir = 'dist';
const filesOut = `${distDir}/files.txt`;
fs.writeFileSync(filesOut, '');
- const files = (await walk(distDir)).map(f => f.replace(`${distDir}/`, ''));
+ const files = (await walk(distDir)).map((f) => f.replace(`${distDir}/`, ''));
fs.writeFileSync(filesOut, files.join('\n') + '\n');
endBuildStep('Generated', filesOut, startTime);
}
@@ -288,8 +288,8 @@ async function preBuildWebPushPublisherFiles() {
mkdirSync('dist/v0');
const promises = [];
- WEB_PUSH_PUBLISHER_VERSIONS.forEach(version => {
- WEB_PUSH_PUBLISHER_FILES.forEach(fileName => {
+ WEB_PUSH_PUBLISHER_VERSIONS.forEach((version) => {
+ WEB_PUSH_PUBLISHER_FILES.forEach((fileName) => {
const basePath = `extensions/amp-web-push/${version}/`;
const tempBuildDir = `build/all/amp-web-push-${version}/`;
@@ -313,9 +313,9 @@ async function preBuildWebPushPublisherFiles() {
*/
function postBuildWebPushPublisherFilesVersion() {
const distDir = 'dist/v0';
- WEB_PUSH_PUBLISHER_VERSIONS.forEach(version => {
+ WEB_PUSH_PUBLISHER_VERSIONS.forEach((version) => {
const basePath = `extensions/amp-web-push/${version}/`;
- WEB_PUSH_PUBLISHER_FILES.forEach(fileName => {
+ WEB_PUSH_PUBLISHER_FILES.forEach((fileName) => {
const minifiedName = maybeToEsmName(fileName + '.js');
if (!fs.existsSync(distDir + '/' + minifiedName)) {
throw new Error(`Cannot find ${distDir}/${minifiedName}`);
diff --git a/build-system/tasks/e2e/amp-driver.js b/build-system/tasks/e2e/amp-driver.js
index 6f39d22abc98..4b9ea71ecf67 100644
--- a/build-system/tasks/e2e/amp-driver.js
+++ b/build-system/tasks/e2e/amp-driver.js
@@ -45,7 +45,7 @@ const EnvironmentBehaviorMap = {
ready(controller) {
return controller
.findElement('#AMP_DOC_dynamic[data-loaded]')
- .then(frame => controller.switchToFrame(frame));
+ .then((frame) => controller.switchToFrame(frame));
},
url(url) {
@@ -90,7 +90,7 @@ const EnvironmentBehaviorMap = {
async ready(controller) {
return controller
.findElement('amp-ad > iframe')
- .then(frame => controller.switchToFrame(frame));
+ .then((frame) => controller.switchToFrame(frame));
},
url(url) {
@@ -102,7 +102,7 @@ const EnvironmentBehaviorMap = {
async ready(controller) {
return controller
.findElement('#inabox-frame')
- .then(frame => controller.switchToFrame(frame));
+ .then((frame) => controller.switchToFrame(frame));
},
url(url) {
@@ -114,7 +114,7 @@ const EnvironmentBehaviorMap = {
async ready(controller) {
return controller
.findElement('#inabox-frame')
- .then(frame => controller.switchToFrame(frame));
+ .then((frame) => controller.switchToFrame(frame));
},
url(url) {
@@ -126,7 +126,7 @@ const EnvironmentBehaviorMap = {
async ready(controller) {
return controller
.findElement('#inabox-frame')
- .then(frame => controller.switchToFrame(frame));
+ .then((frame) => controller.switchToFrame(frame));
},
url(url) {
@@ -156,7 +156,7 @@ class AmpDriver {
async toggleExperiment(name, toggle) {
await this.controller_.evaluate(
(name, toggle) => {
- (window.AMP = window.AMP || []).push(AMP => {
+ (window.AMP = window.AMP || []).push((AMP) => {
AMP.toggleExperiment(name, toggle);
});
},
diff --git a/build-system/tasks/e2e/controller-promise.js b/build-system/tasks/e2e/controller-promise.js
index 2766f3c18bd4..8d4964e3c509 100644
--- a/build-system/tasks/e2e/controller-promise.js
+++ b/build-system/tasks/e2e/controller-promise.js
@@ -62,7 +62,7 @@ class ControllerPromise {
/** @override */
then(opt_onFulfilled, opt_onRejected) {
- opt_onFulfilled = opt_onFulfilled || (x => x);
+ opt_onFulfilled = opt_onFulfilled || ((x) => x);
// Allow this and future `then`s to update the wait value.
let wrappedWait = null;
if (this.waitForValue) {
@@ -87,8 +87,8 @@ class ControllerPromise {
*/
function wrapWait(wait, mutate) {
return (condition, opt_mutate) => {
- opt_mutate = opt_mutate || (x => x);
- return wait(condition, value => opt_mutate(mutate(value)));
+ opt_mutate = opt_mutate || ((x) => x);
+ return wait(condition, (value) => opt_mutate(mutate(value)));
};
}
diff --git a/build-system/tasks/e2e/describes-e2e.js b/build-system/tasks/e2e/describes-e2e.js
index a42315ca75dd..e2c67bb231d4 100644
--- a/build-system/tasks/e2e/describes-e2e.js
+++ b/build-system/tasks/e2e/describes-e2e.js
@@ -232,7 +232,7 @@ let TestSpec;
/**
* An end2end test using Selenium Web Driver or Puppeteer
*/
-const endtoend = describeEnv(spec => new EndToEndFixture(spec));
+const endtoend = describeEnv((spec) => new EndToEndFixture(spec));
/**
* Maps an environment enum value to a `describes.repeated` variant object.
@@ -324,7 +324,7 @@ class ItConfig {
return this.it.skip(name, fn);
}
- this.it(name, function() {
+ this.it(name, function () {
return fn.apply(this, arguments);
});
}
@@ -345,7 +345,7 @@ function describeEnv(factory) {
* @param {function(string, function())} describeFunc
* @return {function()}
*/
- const templateFunc = function(suiteName, spec, fn, describeFunc) {
+ const templateFunc = function (suiteName, spec, fn, describeFunc) {
const fixture = factory(spec);
let environments = spec.environments || 'ampdoc-preset';
if (typeof environments === 'string') {
@@ -355,7 +355,7 @@ function describeEnv(factory) {
throw new Error('Invalid environment preset: ' + spec.environments);
}
const variants = Object.create(null);
- environments.forEach(environment => {
+ environments.forEach((environment) => {
const o = EnvironmentVariantMap[environment];
variants[o.name] = o.value;
});
@@ -369,9 +369,9 @@ function describeEnv(factory) {
const allowedBrowsers = getAllowedBrowsers();
spec.browsers
- .filter(x => allowedBrowsers.has(x))
- .forEach(browserName => {
- describe(browserName, function() {
+ .filter((x) => allowedBrowsers.has(x))
+ .forEach((browserName) => {
+ describe(browserName, function () {
createVariantDescribe(browserName);
});
});
@@ -381,7 +381,7 @@ function describeEnv(factory) {
const {engine, browsers} = getConfig();
const allowedBrowsers = browsers
- ? new Set(browsers.split(',').map(x => x.trim()))
+ ? new Set(browsers.split(',').map((x) => x.trim()))
: supportedBrowsers;
if (engine === EngineType.PUPPETEER) {
@@ -405,24 +405,24 @@ function describeEnv(factory) {
function createVariantDescribe(browserName) {
for (const name in variants) {
- it.configure = function() {
+ it.configure = function () {
return new ItConfig(it, variants[name]);
};
- describe(name ? ` ${name} ` : SUB, function() {
+ describe(name ? ` ${name} ` : SUB, function () {
doTemplate.call(this, name, variants[name], browserName);
});
}
}
- return describeFunc(suiteName, function() {
+ return describeFunc(suiteName, function () {
createBrowserDescribe();
});
function doTemplate(name, variant, browserName) {
const env = Object.create(variant);
this.timeout(TEST_TIMEOUT);
- beforeEach(async function() {
+ beforeEach(async function () {
this.timeout(SETUP_TIMEOUT);
await fixture.setup(env, browserName, SETUP_RETRIES);
@@ -432,7 +432,7 @@ function describeEnv(factory) {
}
});
- afterEach(async function() {
+ afterEach(async function () {
// If there is an async expect error, throw it in the final state.
const lastExpectError = getLastExpectError();
if (lastExpectError) {
@@ -450,7 +450,7 @@ function describeEnv(factory) {
}
});
- describe(SUB, function() {
+ describe(SUB, function () {
fn.call(this, env);
});
}
@@ -462,7 +462,7 @@ function describeEnv(factory) {
* @param {function(!Object)} fn
* @return {function()}
*/
- const mainFunc = function(name, spec, fn) {
+ const mainFunc = function (name, spec, fn) {
return templateFunc(name, spec, fn, describe);
};
@@ -472,11 +472,11 @@ function describeEnv(factory) {
* @param {function(!Object)} fn
* @return {function()}
*/
- mainFunc.only = function(name, spec, fn) {
+ mainFunc.only = function (name, spec, fn) {
return templateFunc(name, spec, fn, describe./*OK*/ only);
};
- mainFunc.skip = function(name, variants, fn) {
+ mainFunc.skip = function (name, variants, fn) {
return templateFunc(name, variants, fn, describe.skip);
};
@@ -595,7 +595,7 @@ async function toggleExperiments(ampDriver, testUrl, experiments) {
* @template T
*/
function intersect(a, b) {
- return new Set(Array.from(a).filter(aItem => b.has(aItem)));
+ return new Set(Array.from(a).filter((aItem) => b.has(aItem)));
}
module.exports = {
diff --git a/build-system/tasks/e2e/driver/query-xpath.js b/build-system/tasks/e2e/driver/query-xpath.js
index 670ee5d0e475..d42b61aff98b 100644
--- a/build-system/tasks/e2e/driver/query-xpath.js
+++ b/build-system/tasks/e2e/driver/query-xpath.js
@@ -84,7 +84,7 @@ function queryXpath(xpathString, context) {
const xpathIterator = createXpathIterator(
evaluate(xpathString, fakeDocument, null, XPathResult.ANY_TYPE)
);
- const elements = [...xpathIterator].map(node => {
+ const elements = [...xpathIterator].map((node) => {
const testId = getData(node);
const selector = `[${TEST_ID_ATTRIBUTE}="${testId}"]`;
return context./*OK*/ querySelector(selector);
diff --git a/build-system/tasks/e2e/expect.js b/build-system/tasks/e2e/expect.js
index 102b50b482c5..3ae0368663e9 100644
--- a/build-system/tasks/e2e/expect.js
+++ b/build-system/tasks/e2e/expect.js
@@ -167,8 +167,8 @@ function installWrappers(chai, utils) {
function overwriteAlwaysUseSuper(utils) {
const {flag} = utils;
- return function(_super) {
- return function() {
+ return function (_super) {
+ return function () {
const obj = this._obj;
const isControllerPromise = obj instanceof ControllerPromise;
if (!isControllerPromise) {
@@ -176,7 +176,7 @@ function overwriteAlwaysUseSuper(utils) {
}
const {waitForValue} = obj;
if (!waitForValue) {
- return obj.then(result => {
+ return obj.then((result) => {
flag(this, 'object', result);
return _super.apply(this, arguments);
});
@@ -190,7 +190,7 @@ function overwriteAlwaysUseSuper(utils) {
* @return {boolean} true if the ControllerPromise polling value
* satisfies the `expect` chain.
*/
- const valueSatisfiesExpectation = value => {
+ const valueSatisfiesExpectation = (value) => {
try {
// Tell chai to use value as the subject of the expect chain.
flag(this, 'object', value);
@@ -220,13 +220,13 @@ function overwriteAlwaysUseSuper(utils) {
}
function inheritChainingBehavior(_super) {
- return function() {
+ return function () {
_super.apply(this, arguments);
};
}
function overwriteUnsupported(_super) {
- return function() {
+ return function () {
const obj = this._obj;
const isControllerPromise = obj instanceof ControllerPromise;
if (isControllerPromise) {
@@ -248,7 +248,7 @@ function installBrowserWrappers(chai, utils) {
// Assert that a request with a testUrl was sent
// Example usage: await expect(testUrl).to.have.been.sent;
- utils.addProperty(Assertion.prototype, 'sent', async function() {
+ utils.addProperty(Assertion.prototype, 'sent', async function () {
const url = this._obj;
const requests = await networkLogger.getSentRequests(url);
this.assert(0 < requests.length, 'expected #{this} to have been sent');
@@ -257,7 +257,7 @@ function installBrowserWrappers(chai, utils) {
// Assert that a request was sent n number of times
// Example usage: await expect(testUrl).to.have.sentCount(n);
- utils.addMethod(Assertion.prototype, 'sentCount', async function(count) {
+ utils.addMethod(Assertion.prototype, 'sentCount', async function (count) {
const url = this._obj;
const requests = await networkLogger.getSentRequests(url);
this.assert(
diff --git a/build-system/tasks/e2e/index.js b/build-system/tasks/e2e/index.js
index 693e7650b623..dd0eaeaf4988 100644
--- a/build-system/tasks/e2e/index.js
+++ b/build-system/tasks/e2e/index.js
@@ -66,7 +66,7 @@ async function e2e() {
// set up promise to return to gulp.task()
let resolver;
- const deferred = new Promise(resolverIn => {
+ const deferred = new Promise((resolverIn) => {
resolver = resolverIn;
});
@@ -93,13 +93,13 @@ async function e2e() {
// specify tests to run
if (argv.files) {
- glob.sync(argv.files).forEach(file => {
+ glob.sync(argv.files).forEach((file) => {
delete require.cache[file];
mocha.addFile(file);
});
} else {
- config.e2eTestPaths.forEach(path => {
- glob.sync(path).forEach(file => {
+ config.e2eTestPaths.forEach((path) => {
+ glob.sync(path).forEach((file) => {
delete require.cache[file];
mocha.addFile(file);
});
@@ -107,7 +107,7 @@ async function e2e() {
}
await reportTestStarted();
- mocha.run(async failures => {
+ mocha.run(async (failures) => {
// end web server
cleanUp_();
@@ -119,7 +119,7 @@ async function e2e() {
const filesToWatch = argv.files ? [argv.files] : [config.e2eTestPaths];
const watcher = watch(filesToWatch);
log('Watching', cyan(filesToWatch), 'for changes...');
- watcher.on('change', file => {
+ watcher.on('change', (file) => {
log('Detected a change in', cyan(file));
log('Running tests...');
// clear file from node require cache if running test again
diff --git a/build-system/tasks/e2e/network-logger.js b/build-system/tasks/e2e/network-logger.js
index 86c21935b14e..28bcbaa97985 100644
--- a/build-system/tasks/e2e/network-logger.js
+++ b/build-system/tasks/e2e/network-logger.js
@@ -39,7 +39,7 @@ class NetworkLogger {
.logs()
.get(logging.Type.PERFORMANCE);
- return entries.filter(entry => {
+ return entries.filter((entry) => {
const json = JSON.parse(entry.message);
entry.message = json.message;
return entry.message.method == networkMethod;
@@ -56,7 +56,7 @@ class NetworkLogger {
PerformanceMethods.REQUEST_WILL_BE_SENT
);
if (url) {
- return entries.filter(entry => entry.message.params.request.url == url);
+ return entries.filter((entry) => entry.message.params.request.url == url);
}
return entries;
}
diff --git a/build-system/tasks/e2e/puppeteer-controller.js b/build-system/tasks/e2e/puppeteer-controller.js
index 1da6a6e3b809..a9f8269006fc 100644
--- a/build-system/tasks/e2e/puppeteer-controller.js
+++ b/build-system/tasks/e2e/puppeteer-controller.js
@@ -317,7 +317,7 @@ class PuppeteerController {
*/
async getDocumentElement() {
const root = await this.getRoot_();
- const getter = root => root.ownerDocument.documentElement;
+ const getter = (root) => root.ownerDocument.documentElement;
const element = await this.evaluate(getter, root);
return new ElementHandle(element);
}
@@ -359,7 +359,7 @@ class PuppeteerController {
*/
getElementText(handle) {
const element = handle.getElement();
- const getter = element => ({value: element./*OK*/ innerText.trim()});
+ const getter = (element) => ({value: element./*OK*/ innerText.trim()});
return new ControllerPromise(
this.evaluateValue_(getter, element),
this.getWaitFn_(getter, element)
@@ -430,7 +430,7 @@ class PuppeteerController {
*/
getElementRect(handle) {
const element = handle.getElement();
- const getter = element => {
+ const getter = (element) => {
// Extracting the values seems to perform better than returning
// the raw ClientRect from the element, in terms of flakiness.
// The raw ClientRect also has hundredths of a pixel. We round to int.
@@ -456,7 +456,7 @@ class PuppeteerController {
};
};
return new ControllerPromise(
- this.evaluate(getter, element).then(handle => handle.jsonValue()),
+ this.evaluate(getter, element).then((handle) => handle.jsonValue()),
this.getWaitFn_(getter, element)
);
}
@@ -553,9 +553,9 @@ class PuppeteerController {
* @override
*/
getTitle() {
- const title = this.getCurrentFrame_().then(frame => frame.title());
+ const title = this.getCurrentFrame_().then((frame) => frame.title());
return new ControllerPromise(title, () =>
- this.getCurrentFrame_().then(frame => frame.title())
+ this.getCurrentFrame_().then((frame) => frame.title())
);
}
@@ -565,7 +565,7 @@ class PuppeteerController {
*/
async getActiveElement() {
const root = await this.getRoot_();
- const getter = root =>
+ const getter = (root) =>
root.activeElement || root.ownerDocument.activeElement;
const element = await this.evaluate(getter, root);
return new ElementHandle(element);
@@ -677,7 +677,7 @@ class PuppeteerController {
* @return {!Promise}
*/
switchToShadow(handle) {
- const getter = shadowHost => shadowHost.shadowRoot.body;
+ const getter = (shadowHost) => shadowHost.shadowRoot.body;
return this.switchToShadowInternal_(handle, getter);
}
@@ -687,7 +687,7 @@ class PuppeteerController {
* @return {!Promise}
*/
switchToShadowRoot(handle) {
- const getter = shadowHost => shadowHost.shadowRoot;
+ const getter = (shadowHost) => shadowHost.shadowRoot;
return this.switchToShadowInternal_(handle, getter);
}
diff --git a/build-system/tasks/e2e/repl.js b/build-system/tasks/e2e/repl.js
index 666d76642ea2..808ab56ba0ee 100644
--- a/build-system/tasks/e2e/repl.js
+++ b/build-system/tasks/e2e/repl.js
@@ -46,7 +46,7 @@ function installRepl(global, env) {
* @param {*} mochaThis
* @return {!Promise}
*/
- global.repl = function(mochaThis) {
+ global.repl = function (mochaThis) {
mochaThis.timeout(REPL_INFINITE_TIMEOUT);
const {controller} = env;
@@ -55,7 +55,7 @@ function installRepl(global, env) {
global.repl.continue = replContinue;
if (!replPromise) {
- replPromise = new Promise(resolve => {
+ replPromise = new Promise((resolve) => {
replResolve = resolve;
});
}
diff --git a/build-system/tasks/e2e/selenium-webdriver-controller.js b/build-system/tasks/e2e/selenium-webdriver-controller.js
index cff59c61c88f..894066a611e8 100644
--- a/build-system/tasks/e2e/selenium-webdriver-controller.js
+++ b/build-system/tasks/e2e/selenium-webdriver-controller.js
@@ -49,7 +49,7 @@ const KeyToSeleniumMap = {
* @template T
*/
function expectCondition(valueFn, condition, opt_mutate) {
- opt_mutate = opt_mutate || (x => x);
+ opt_mutate = opt_mutate || ((x) => x);
return new Condition('value matches condition', async () => {
const value = await valueFn();
const mutatedValue = await opt_mutate(value);
@@ -68,14 +68,14 @@ function expectCondition(valueFn, condition, opt_mutate) {
* @template T
*/
function waitFor(driver, valueFn, condition, opt_mutate) {
- const conditionValue = value => {
+ const conditionValue = (value) => {
// Box the value in an object, so values that are present but falsy
// (like "") do not cause driver.wait to continue waiting.
return condition(value) ? {value} : null;
};
return driver
.wait(expectCondition(valueFn, conditionValue, opt_mutate))
- .then(result => result.value); // Unbox the value.
+ .then((result) => result.value); // Unbox the value.
}
/** @implements {FunctionalTestController} */
@@ -169,7 +169,7 @@ class SeleniumWebDriverController {
}
});
const webElements = await this.driver.wait(condition, ELEMENT_WAIT_TIMEOUT);
- return webElements.map(webElement => new ElementHandle(webElement, this));
+ return webElements.map((webElement) => new ElementHandle(webElement, this));
}
/**
@@ -220,7 +220,7 @@ class SeleniumWebDriverController {
}),
ELEMENT_WAIT_TIMEOUT
);
- return webElements.map(webElement => new ElementHandle(webElement, this));
+ return webElements.map((webElement) => new ElementHandle(webElement, this));
}
/**
@@ -249,7 +249,7 @@ class SeleniumWebDriverController {
*/
async getActiveElement() {
const root = await this.getRoot_();
- const getter = root =>
+ const getter = (root) =>
root.activeElement || root.ownerDocument.activeElement;
const activeElement = await this.driver.executeScript(getter, root);
return new ElementHandle(activeElement);
@@ -261,7 +261,7 @@ class SeleniumWebDriverController {
*/
async getDocumentElement() {
const root = await this.getRoot_();
- const getter = root => root.ownerDocument.documentElement;
+ const getter = (root) => root.ownerDocument.documentElement;
const documentElement = await this.driver.executeScript(getter, root);
return new ElementHandle(documentElement);
}
@@ -370,7 +370,7 @@ class SeleniumWebDriverController {
*/
getElementRect(handle) {
const webElement = handle.getElement();
- const getter = element => {
+ const getter = (element) => {
// Extracting the values seems to perform better than returning
// the raw ClientRect from the element, in terms of flakiness.
// The raw ClientRect also has hundredths of a pixel. We round to int.
@@ -455,15 +455,12 @@ class SeleniumWebDriverController {
async setWindowRect(rect) {
const {width, height} = rect;
- await this.driver
- .manage()
- .window()
- .setRect({
- x: 0,
- y: 0,
- width,
- height,
- });
+ await this.driver.manage().window().setRect({
+ x: 0,
+ y: 0,
+ width,
+ height,
+ });
// Check to make sure we resized the content to the correct size.
const htmlElement = this.driver.findElement(By.tagName('html'));
@@ -586,7 +583,7 @@ class SeleniumWebDriverController {
*/
async takeScreenshot(path) {
const imageString = await this.driver.takeScreenshot();
- fs.writeFile(path, imageString, 'base64', function() {});
+ fs.writeFile(path, imageString, 'base64', function () {});
}
/**
@@ -611,7 +608,7 @@ class SeleniumWebDriverController {
// Could be https://crbug.com/chromedriver/2667
const webElement = handle.getElement();
const imageString = await webElement.takeScreenshot();
- fs.writeFile(path, imageString, 'base64', function() {});
+ fs.writeFile(path, imageString, 'base64', function () {});
}
/**
@@ -651,7 +648,7 @@ class SeleniumWebDriverController {
* @return {!Promise}
*/
async switchToShadow(handle) {
- const getter = shadowHost => shadowHost.shadowRoot.body;
+ const getter = (shadowHost) => shadowHost.shadowRoot.body;
return this.switchToShadowInternal_(handle, getter);
}
@@ -661,7 +658,7 @@ class SeleniumWebDriverController {
* @return {!Promise}
*/
async switchToShadowRoot(handle) {
- const getter = shadowHost => shadowHost.shadowRoot;
+ const getter = (shadowHost) => shadowHost.shadowRoot;
return this.switchToShadowInternal_(handle, getter);
}
diff --git a/build-system/tasks/extension-generator/index.js b/build-system/tasks/extension-generator/index.js
index ccb7ec9de1ee..c07ededb450f 100644
--- a/build-system/tasks/extension-generator/index.js
+++ b/build-system/tasks/extension-generator/index.js
@@ -27,7 +27,7 @@ const year = new Date().getFullYear();
function pascalCase(str) {
return (
str[0].toUpperCase() +
- str.slice(1).replace(/-([a-z])/g, function(g) {
+ str.slice(1).replace(/-([a-z])/g, function (g) {
return g[1].toUpperCase();
})
);
@@ -73,7 +73,7 @@ tags: { # <${name}>
`;
}
-const getMarkdownDocFile = async name =>
+const getMarkdownDocFile = async (name) =>
(await fs.readFile(`${__dirname}/extension-doc.template.md`))
.toString('utf-8')
.replace(/\\\$category/g, '$category')
@@ -231,7 +231,7 @@ async function makeExtension() {
const examplesFileValidatorOut = examplesFile
.trim()
.split('\n')
- .map(line => `| ${line}`)
+ .map((line) => `| ${line}`)
.join('\n');
fs.writeFileSync(
diff --git a/build-system/tasks/extension-helpers.js b/build-system/tasks/extension-helpers.js
index 447378cf7a97..ef123c6194f6 100644
--- a/build-system/tasks/extension-helpers.js
+++ b/build-system/tasks/extension-helpers.js
@@ -108,7 +108,7 @@ function declareExtension(
) {
const defaultOptions = {hasCss: false};
const versions = Array.isArray(version) ? version : [version];
- versions.forEach(v => {
+ versions.forEach((v) => {
extensionsObject[`${name}-${v}`] = {
name,
version: v,
@@ -140,7 +140,7 @@ function maybeInitializeExtensions(
) {
if (Object.keys(extensionsObject).length === 0) {
verifyExtensionBundles();
- extensionBundles.forEach(c => {
+ extensionBundles.forEach((c) => {
declareExtension(
c.name,
c.version,
@@ -282,7 +282,7 @@ function getExtensionsFromArg(examples) {
const extensions = [];
- examples.split(',').forEach(example => {
+ examples.split(',').forEach((example) => {
const html = fs.readFileSync(example, 'utf8');
const customElementTemplateRe = /custom-(element|template)="([^"]+)"/g;
const extensionNameMatchIndex = 2;
@@ -314,7 +314,7 @@ function getExtensionsFromArg(examples) {
*/
function dedupe(arr) {
const map = Object.create(null);
- arr.forEach(item => (map[item] = true));
+ arr.forEach((item) => (map[item] = true));
return Object.keys(map);
}
@@ -380,7 +380,7 @@ async function doBuildExtension(extensions, extension, options) {
* @param {?Object} options
*/
function watchExtension(path, name, version, latestVersion, hasCss, options) {
- watch(path + '/**/*', function() {
+ watch(path + '/**/*', function () {
const bundleComplete = buildExtension(
name,
version,
@@ -483,7 +483,7 @@ function buildExtensionCss(path, name, version, options) {
const promises = [];
const mainCssBinary = jsifyCssAsync(path + '/' + name + '.css').then(
- mainCss => {
+ (mainCss) => {
writeCssBinaries(`${name}-${version}.css`, mainCss);
if (isAliased) {
writeCssBinaries(`${name}-${aliasBundle.aliasedVersion}.css`, mainCss);
@@ -494,8 +494,8 @@ function buildExtensionCss(path, name, version, options) {
if (Array.isArray(options.cssBinaries)) {
promises.push.apply(
promises,
- options.cssBinaries.map(function(name) {
- return jsifyCssAsync(`${path}/${name}.css`).then(css => {
+ options.cssBinaries.map(function (name) {
+ return jsifyCssAsync(`${path}/${name}.css`).then((css) => {
writeCssBinaries(`${name}-${version}.css`, css);
if (isAliased) {
writeCssBinaries(`${name}-${aliasBundle.aliasedVersion}.css`, css);
diff --git a/build-system/tasks/firebase.js b/build-system/tasks/firebase.js
index 82db707e2329..e9b35052135f 100644
--- a/build-system/tasks/firebase.js
+++ b/build-system/tasks/firebase.js
@@ -43,8 +43,8 @@ async function copyAndReplaceUrls(src, dest) {
// Recursively gets all the files within the directory and its children.
const files = await walk(dest);
const promises = files
- .filter(fileName => path.extname(fileName) == '.html')
- .map(file => replaceUrls(file));
+ .filter((fileName) => path.extname(fileName) == '.html')
+ .map((file) => replaceUrls(file));
await Promise.all(promises);
}
diff --git a/build-system/tasks/get-zindex/index.js b/build-system/tasks/get-zindex/index.js
index 3ecb3c32fa45..10635943082b 100644
--- a/build-system/tasks/get-zindex/index.js
+++ b/build-system/tasks/get-zindex/index.js
@@ -37,13 +37,13 @@ const tableOptions = {
* @param {!Rules} css post css rules object
*/
function zIndexCollector(acc, css) {
- css.walkRules(rule => {
- rule.walkDecls(decl => {
+ css.walkRules((rule) => {
+ rule.walkDecls((decl) => {
// Split out multi selector rules
let selectorNames = rule.selector.replace('\n', '');
selectorNames = selectorNames.split(',');
if (decl.prop == 'z-index') {
- selectorNames.forEach(selector => {
+ selectorNames.forEach((selector) => {
// If multiple redeclaration of a selector and z index
// are done in a single file, this will get overridden.
acc[selector] = decl.value;
@@ -89,11 +89,11 @@ function createTable(filesData) {
const rows = [];
Object.keys(filesData)
.sort()
- .forEach(fileName => {
+ .forEach((fileName) => {
const selectors = filesData[fileName];
Object.keys(selectors)
.sort()
- .forEach(selectorName => {
+ .forEach((selectorName) => {
const zIndex = selectors[selectorName];
const row = [selectorName, zIndex, fileName];
rows.push(row);
@@ -122,7 +122,7 @@ function getZindex(cb) {
const filesData = Object.create(null);
// Don't return the stream here since we do a `writeFileSync`
getZindexStream('{css,src,extensions}/**/*.css')
- .on('data', chunk => {
+ .on('data', (chunk) => {
filesData[chunk.name] = chunk.selectors;
})
.on('end', () => {
diff --git a/build-system/tasks/get-zindex/test.js b/build-system/tasks/get-zindex/test.js
index 18453c35fa17..3b63946c1325 100644
--- a/build-system/tasks/get-zindex/test.js
+++ b/build-system/tasks/get-zindex/test.js
@@ -29,11 +29,11 @@ const result = {
},
};
-test.cb('collects selectors', t => {
+test.cb('collects selectors', (t) => {
const data = Object.create(null);
const testFiles = `${__dirname}/*.css`;
m.getZindexStream(testFiles)
- .on('data', chunk => {
+ .on('data', (chunk) => {
data[chunk.name] = chunk.selectors;
})
.on('end', () => {
@@ -42,7 +42,7 @@ test.cb('collects selectors', t => {
});
});
-test('sync - create array of arrays with z index order', t => {
+test('sync - create array of arrays with z index order', (t) => {
t.plan(1);
const table = m.createTable(result);
const expected = [
diff --git a/build-system/tasks/helpers.js b/build-system/tasks/helpers.js
index 414193c76bdd..7fc53194865d 100644
--- a/build-system/tasks/helpers.js
+++ b/build-system/tasks/helpers.js
@@ -104,7 +104,7 @@ const BABELIFY_GLOBAL_TRANSFORM = {
* running on SauceLabs since some older browsers need ES5.
*/
ignore: devDependencies().filter(
- dep => dep.indexOf('chai-as-promised') === -1
+ (dep) => dep.indexOf('chai-as-promised') === -1
),
};
@@ -150,14 +150,14 @@ function doBuildJs(jsBundles, name, extraOptions) {
async function bootstrapThirdPartyFrames(watch, minify) {
const startTime = Date.now();
const promises = [];
- thirdPartyFrames.forEach(frameObject => {
+ thirdPartyFrames.forEach((frameObject) => {
promises.push(
thirdPartyBootstrap(frameObject.max, frameObject.min, minify)
);
});
if (watch) {
- thirdPartyFrames.forEach(frameObject => {
- gulpWatch(frameObject.max, function() {
+ thirdPartyFrames.forEach((frameObject) => {
+ gulpWatch(frameObject.max, function () {
thirdPartyBootstrap(frameObject.max, frameObject.min, minify);
});
});
@@ -279,7 +279,7 @@ async function compileMinifiedJs(srcDir, srcFilename, destDir, options) {
const minifiedName = maybeToEsmName(options.minifiedName);
if (options.watch) {
- gulpWatch(entryPoint, async function() {
+ gulpWatch(entryPoint, async function () {
const compileComplete = await doCompileMinifiedJs(
/* continueOnError */ true
);
@@ -314,7 +314,7 @@ async function compileMinifiedJs(srcDir, srcFilename, destDir, options) {
name += ` → ${maybeToEsmName(options.latestName)}`;
}
if (options.singlePassCompilation) {
- altMainBundles.forEach(bundle => {
+ altMainBundles.forEach((bundle) => {
name += `, ${maybeToEsmName(`${bundle.name}.js`)}`;
});
name += ', and all extensions';
@@ -395,7 +395,7 @@ function devDependencies() {
const file = fs.readFileSync('package.json', 'utf8');
const packageJson = JSON.parse(file);
const devDependencies = Object.keys(packageJson['devDependencies']);
- return devDependencies.map(p => `./node_modules/${p}`);
+ return devDependencies.map((p) => `./node_modules/${p}`);
}
/**
@@ -448,7 +448,7 @@ function compileUnminifiedJs(srcDir, srcFilename, destDir, options) {
bundler
.bundle()
.once('readable', () => (startTime = Date.now()))
- .on('error', err =>
+ .on('error', (err) =>
handleBundleError(err, continueOnError, destFilename)
)
.pipe(source(srcFilename))
@@ -628,7 +628,7 @@ async function applyAmpConfig(targetFile, localDev) {
*/
function concatFilesToString(files) {
return files
- .map(function(filePath) {
+ .map(function (filePath) {
return fs.readFileSync(filePath, 'utf8');
})
.join(MODULE_SEPARATOR);
@@ -662,7 +662,7 @@ function thirdPartyBootstrap(input, outputName, minify) {
return toPromise(
file(outputName, html, {src: true})
.pipe(gulp.dest('dist.3p/' + internalRuntimeVersion))
- .on('end', function() {
+ .on('end', function () {
const aliasToLatestBuild = 'dist.3p/current-min';
if (fs.existsSync(aliasToLatestBuild)) {
fs.unlinkSync(aliasToLatestBuild);
@@ -698,7 +698,7 @@ function mkdirSync(path) {
* @return {Promise}
*/
function toPromise(readable) {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
readable.on('error', reject).on('end', resolve);
});
}
diff --git a/build-system/tasks/jsify-css.js b/build-system/tasks/jsify-css.js
index ca33c83828e7..a6b0ffe45496 100644
--- a/build-system/tasks/jsify-css.js
+++ b/build-system/tasks/jsify-css.js
@@ -88,8 +88,8 @@ function transformCss(filename, opt_cssnano) {
* processing
*/
function jsifyCssAsync(filename) {
- return transformCss(filename).then(function(result) {
- result.warnings().forEach(function(warn) {
+ return transformCss(filename).then(function (result) {
+ result.warnings().forEach(function (warn) {
log(colors.red(warn.toString()));
});
const {css} = result;
diff --git a/build-system/tasks/karma.conf.js b/build-system/tasks/karma.conf.js
index 9f7008f894c9..59fb7bbb387a 100644
--- a/build-system/tasks/karma.conf.js
+++ b/build-system/tasks/karma.conf.js
@@ -311,7 +311,7 @@ module.exports = {
{
'middleware:custom': [
'factory',
- function() {
+ function () {
return require(require.resolve('../server/app.js'));
},
],
diff --git a/build-system/tasks/lint.js b/build-system/tasks/lint.js
index 1a7e2e772312..2c21bc2171a8 100644
--- a/build-system/tasks/lint.js
+++ b/build-system/tasks/lint.js
@@ -68,13 +68,13 @@ function runLinter(stream, options) {
return stream
.pipe(eslint(options))
.pipe(
- eslint.formatEach('stylish', function(msg) {
+ eslint.formatEach('stylish', function (msg) {
logOnSameLine(msg.replace(`${rootDir}/`, '').trim() + '\n');
})
)
.pipe(eslintIfFixed(rootDir))
.pipe(
- eslint.result(function(result) {
+ eslint.result(function (result) {
const relativePath = path.relative(rootDir, result.filePath);
if (!isTravisBuild()) {
logOnSameLine(colors.green('Linted: ') + relativePath);
@@ -90,7 +90,7 @@ function runLinter(stream, options) {
})
)
.pipe(
- eslint.results(function(results) {
+ eslint.results(function (results) {
if (results.errorCount == 0 && results.warningCount == 0) {
if (!isTravisBuild()) {
logOnSameLine(
@@ -136,7 +136,7 @@ function runLinter(stream, options) {
}
if (options.fix && Object.keys(fixedFiles).length > 0) {
log(colors.green('INFO: ') + 'Summary of fixes:');
- Object.keys(fixedFiles).forEach(file => {
+ Object.keys(fixedFiles).forEach((file) => {
log(fixedFiles[file] + colors.cyan(file));
});
}
@@ -153,7 +153,7 @@ function runLinter(stream, options) {
*/
function eslintRulesChanged() {
return (
- gitDiffNameOnlyMaster().filter(function(file) {
+ gitDiffNameOnlyMaster().filter(function (file) {
return (
path.basename(file).includes('.eslintrc') ||
path.dirname(file) === 'build-system/eslint-rules'
@@ -172,7 +172,7 @@ function getFilesToLint(files) {
const filesToLint = globby.sync(files, {gitignore: true});
if (!isTravisBuild()) {
log(colors.green('INFO: ') + 'Running lint on the following files:');
- filesToLint.forEach(file => {
+ filesToLint.forEach((file) => {
log(colors.cyan(file));
});
}
diff --git a/build-system/tasks/mocha-ci-reporter.js b/build-system/tasks/mocha-ci-reporter.js
index fbb6b62ce96b..a67c32d44188 100644
--- a/build-system/tasks/mocha-ci-reporter.js
+++ b/build-system/tasks/mocha-ci-reporter.js
@@ -29,19 +29,19 @@ function ciReporter(runner) {
Base.call(this, runner);
const self = this;
- runner.on('pass', function() {
+ runner.on('pass', function () {
process.stdout.write(Base.color('green', symbols.success));
});
- runner.on('pending', function() {
+ runner.on('pending', function () {
process.stdout.write(Base.color('bright yellow', symbols.info));
});
- runner.on('fail', function() {
+ runner.on('fail', function () {
process.stdout.write(Base.color('fail', symbols.error));
});
- runner.on('end', function() {
+ runner.on('end', function () {
epilogue();
});
diff --git a/build-system/tasks/performance/cache-documents.js b/build-system/tasks/performance/cache-documents.js
index d3a0c416fc23..4ee94576809d 100644
--- a/build-system/tasks/performance/cache-documents.js
+++ b/build-system/tasks/performance/cache-documents.js
@@ -25,7 +25,7 @@ const {CONTROL, downloadToDisk, EXPERIMENT} = require('./helpers');
*/
function cacheDocuments(urls) {
return Promise.all(
- urls.flatMap(url => [
+ urls.flatMap((url) => [
downloadToDisk(url, CONTROL),
downloadToDisk(url, EXPERIMENT),
])
diff --git a/build-system/tasks/performance/compile-scripts.js b/build-system/tasks/performance/compile-scripts.js
index 580b28995b06..87f1debde72f 100644
--- a/build-system/tasks/performance/compile-scripts.js
+++ b/build-system/tasks/performance/compile-scripts.js
@@ -26,7 +26,7 @@ const {setExtensionsToBuildFromDocuments} = require('../extension-helpers.js');
*/
async function compileScripts(urls) {
if (!argv.nobuild) {
- const examples = urls.map(url => urlToCachePath(url, EXPERIMENT));
+ const examples = urls.map((url) => urlToCachePath(url, EXPERIMENT));
setExtensionsToBuildFromDocuments(examples);
await dist();
}
diff --git a/build-system/tasks/performance/helpers.js b/build-system/tasks/performance/helpers.js
index 8d20813544d8..bff60a968cbe 100644
--- a/build-system/tasks/performance/helpers.js
+++ b/build-system/tasks/performance/helpers.js
@@ -36,7 +36,7 @@ function touchDirs() {
path.join(CONTROL_CACHE_PATH, 'v0'),
EXPERIMENT_CACHE_PATH,
path.join(EXPERIMENT_CACHE_PATH, 'v0'),
- ].forEach(dirPath => {
+ ].forEach((dirPath) => {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath);
}
@@ -71,8 +71,8 @@ function downloadToDisk(url, version = CONTROL) {
touchDirs();
return fetch(url)
- .then(response => response.text())
- .then(document => {
+ .then((response) => response.text())
+ .then((document) => {
const filepath = urlToCachePath(url, version);
fs.writeFileSync(filepath, document);
return filepath.split(`performance/cache/${version}/`)[1];
diff --git a/build-system/tasks/performance/measure-documents.js b/build-system/tasks/performance/measure-documents.js
index c61188db0177..37228fb03a2d 100644
--- a/build-system/tasks/performance/measure-documents.js
+++ b/build-system/tasks/performance/measure-documents.js
@@ -38,28 +38,28 @@ function requirePuppeteer_() {
* @param {Puppeteer.page} page
* @return {Promise} Resolves when script is evaluated
*/
-const setupMeasurement = page =>
+const setupMeasurement = (page) =>
page.evaluateOnNewDocument(() => {
window.longTasks = [];
window.cumulativeLayoutShift = 0;
window.measureStarted = Date.now();
window.largestContentfulPaint = 0;
- const longTaskObserver = new PerformanceObserver(list =>
- list.getEntries().forEach(entry => window.longTasks.push(entry))
+ const longTaskObserver = new PerformanceObserver((list) =>
+ list.getEntries().forEach((entry) => window.longTasks.push(entry))
);
longTaskObserver.observe({entryTypes: ['longtask']});
- const layoutShiftObserver = new PerformanceObserver(list =>
+ const layoutShiftObserver = new PerformanceObserver((list) =>
list
.getEntries()
- .forEach(entry => (window.cumulativeLayoutShift += entry.value))
+ .forEach((entry) => (window.cumulativeLayoutShift += entry.value))
);
layoutShiftObserver.observe({entryTypes: ['layout-shift']});
- const largestContentfulPaintObserver = new PerformanceObserver(list => {
+ const largestContentfulPaintObserver = new PerformanceObserver((list) => {
const entries = list.getEntries();
const entry = entries[entries.length - 1];
window.largestContentfulPaint = entry.renderTime || entry.loadTime;
@@ -76,12 +76,12 @@ const setupMeasurement = page =>
* @param {Puppeteer.page} page
* @return {Promise