Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

📦 Update dependency prettier to v2 #27350

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions 3p/3d-gltf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {user} from '../../src/log';

import GltfViewer from './viewer';

const seq = (taskA, taskB) => cb => taskA(() => taskB(cb));
const parallel = (taskA, taskB) => cb => {
const seq = (taskA, taskB) => (cb) => taskA(() => taskB(cb));
const parallel = (taskA, taskB) => (cb) => {
let n = 0;
const finish = () => {
n++;
Expand All @@ -36,8 +36,8 @@ const parallel = (taskA, taskB) => cb => {
};

const loadThree = (global, cb) => {
const loadScriptCb = url => cb => loadScript(global, url, cb);
const loadThreeExample = examplePath =>
const loadScriptCb = (url) => (cb) => loadScript(global, url, cb);
const loadThreeExample = (examplePath) =>
loadScriptCb(
'https://cdn.jsdelivr.net/npm/three@0.91/examples/js/' + examplePath
);
Expand All @@ -62,7 +62,7 @@ export function gltfViewer(global) {
onload: () => {
nonSensitiveDataPostMessage('loaded');
},
onprogress: e => {
onprogress: (e) => {
if (!e.lengthComputable) {
return;
}
Expand All @@ -74,7 +74,7 @@ export function gltfViewer(global) {
})
);
},
onerror: err => {
onerror: (err) => {
user().error('3DGLTF', err);
nonSensitiveDataPostMessage(
'error',
Expand All @@ -84,7 +84,7 @@ export function gltfViewer(global) {
);
},
});
listenParent(global, 'action', msg => {
listenParent(global, 'action', (msg) => {
viewer.actions[msg['action']](msg['args']);
});
nonSensitiveDataPostMessage('ready');
Expand Down
6 changes: 3 additions & 3 deletions 3p/3d-gltf/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class GltfViewer {
let oldW = null;
let oldH = null;
/** @param {JsonObject} box */
const setSize = box => {
const setSize = (box) => {
const w = box['width'];
const h = box['height'];
if (oldW === w && oldH === h) {
Expand Down Expand Up @@ -250,9 +250,9 @@ export default class GltfViewer {
loader.load(
this.options_['src'],
/** @param {{scene: !THREE.Scene}} gltfData */
gltfData => {
(gltfData) => {
this.setupCameraForObject_(gltfData.scene);
gltfData.scene.children.slice().forEach(child => {
gltfData.scene.children.slice().forEach((child) => {
this.model_.add(child);
});

Expand Down
4 changes: 2 additions & 2 deletions 3p/3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function computeInMasterFrame(global, taskId, work, cb) {
if (!global.context.isMaster) {
return; // Only do work in master.
}
work(result => {
work((result) => {
for (let i = 0; i < cbs.length; i++) {
cbs[i].call(null, result);
}
Expand Down Expand Up @@ -254,7 +254,7 @@ export function validateData(data, mandatoryFields, opt_optionalFields) {
*/
function validateExactlyOne(data, alternativeFields) {
userAssert(
alternativeFields.filter(field => data[field]).length === 1,
alternativeFields.filter((field) => data[field]).length === 1,
'%s must contain exactly one of attributes: %s.',
data.type,
alternativeFields.join(', ')
Expand Down
10 changes: 5 additions & 5 deletions 3p/ampcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class AbstractAmpContext {
this.client_.makeRequest(
MessageType.SEND_EMBED_STATE,
MessageType.EMBED_STATE,
data => {
(data) => {
this.hidden = data['pageHidden'];
this.dispatchVisibilityChangeEvent_();
}
Expand All @@ -155,7 +155,7 @@ export class AbstractAmpContext {
* every time we receive a page visibility message.
*/
onPageVisibilityChange(callback) {
return this.client_.registerCallback(MessageType.EMBED_STATE, data => {
return this.client_.registerCallback(MessageType.EMBED_STATE, (data) => {
callback({hidden: data['pageHidden']});
});
}
Expand All @@ -171,7 +171,7 @@ export class AbstractAmpContext {
return this.client_.makeRequest(
MessageType.SEND_INTERSECTIONS,
MessageType.INTERSECTION,
intersection => {
(intersection) => {
callback(intersection['changes']);
}
);
Expand Down Expand Up @@ -230,7 +230,7 @@ export class AbstractAmpContext {
* request succeeds.
*/
onResizeSuccess(callback) {
this.client_.registerCallback(MessageType.EMBED_SIZE_CHANGED, obj => {
this.client_.registerCallback(MessageType.EMBED_SIZE_CHANGED, (obj) => {
callback(obj['requestedHeight'], obj['requestedWidth']);
});
}
Expand All @@ -243,7 +243,7 @@ export class AbstractAmpContext {
* request is denied.
*/
onResizeDenied(callback) {
this.client_.registerCallback(MessageType.EMBED_SIZE_DENIED, obj => {
this.client_.registerCallback(MessageType.EMBED_SIZE_DENIED, (obj) => {
callback(obj['requestedHeight'], obj['requestedWidth']);
});
}
Expand Down
10 changes: 5 additions & 5 deletions 3p/beopinion.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {setStyles} from '../src/style';
* @param {!Window} global
*/
function getBeOpinion(global) {
loadScript(global, 'https://widget.beopinion.com/sdk.js', function() {});
loadScript(global, 'https://widget.beopinion.com/sdk.js', function () {});
}

/**
Expand Down Expand Up @@ -87,20 +87,20 @@ function createContainer(global, data) {
*/
function getBeOpinionAsyncInit(global, accountId) {
const {context} = global;
return function() {
context.onResizeDenied(function(requestedHeight, requestedWidth) {
return function () {
context.onResizeDenied(function (requestedHeight, requestedWidth) {
context.requestResize(requestedWidth, requestedHeight);
});
global.BeOpinionSDK.init({
account: accountId,
onContentReceive: function(hasContent) {
onContentReceive: function (hasContent) {
if (hasContent) {
context.renderStart();
} else {
context.noContentAvailable();
}
},
onHeightChange: function(newHeight) {
onHeightChange: function (newHeight) {
const c = global.document.getElementById('c');
const boundingClientRect = c./*REVIEW*/ getBoundingClientRect();
context.requestResize(boundingClientRect.width, newHeight);
Expand Down
4 changes: 2 additions & 2 deletions 3p/bodymovinanimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getBodymovinAnimationSdk(global, renderer, cb) {
renderer === 'svg'
? 'https://cdnjs.cloudflare.com/ajax/libs/bodymovin/4.13.0/bodymovin_light.min.js'
: 'https://cdnjs.cloudflare.com/ajax/libs/bodymovin/4.13.0/bodymovin.min.js';
loadScript(global, scriptToLoad, function() {
loadScript(global, scriptToLoad, function () {
cb(global.bodymovin);
});
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export function bodymovinanimation(global) {
const shouldLoop = dataLoop != 'false';
const loop = !isNaN(dataLoop) ? dataLoop : shouldLoop;
const renderer = dataReceived['renderer'];
getBodymovinAnimationSdk(global, renderer, function(bodymovin) {
getBodymovinAnimationSdk(global, renderer, function (bodymovin) {
animationHandler = bodymovin.loadAnimation({
container: animatingContainer,
renderer,
Expand Down
6 changes: 3 additions & 3 deletions 3p/embedly.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const CardOptions = {
* @visibleForTesting
*/
function getEmbedly(global, callback) {
loadScript(global, EMBEDLY_SDK_URL, function() {
loadScript(global, EMBEDLY_SDK_URL, function () {
callback();
});
}
Expand Down Expand Up @@ -98,15 +98,15 @@ export function embedly(global, data) {

container.appendChild(card);

getEmbedly(global, function() {
getEmbedly(global, function () {
rsimha marked this conversation as resolved.
Show resolved Hide resolved
// Given by the parent frame.
delete data.width;
delete data.height;

global.window['embedly']('card', card);

// Use embedly SDK to listen to resize event from loaded card
global.window['embedly']('on', RESIZE_EVENT_NAME, function(iframe) {
global.window['embedly']('on', RESIZE_EVENT_NAME, function (iframe) {
context.requestResize(
iframe./*OK*/ width,
parseInt(iframe./*OK*/ height, 10) + /* margin */ 5
Expand Down
23 changes: 12 additions & 11 deletions 3p/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function manageWin_(win) {
function instrumentDocWrite(parent, win) {
const doc = win.document;
const {close} = doc;
doc.close = function() {
parent.ampManageWin = function(win) {
doc.close = function () {
parent.ampManageWin = function (win) {
manageWin(win);
};
if (!parent.ampSeen) {
Expand All @@ -93,7 +93,7 @@ function instrumentDocWrite(parent, win) {
*/
function instrumentSrcdoc(parent, iframe) {
let srcdoc = iframe.getAttribute('srcdoc');
parent.ampManageWin = function(win) {
parent.ampManageWin = function (win) {
manageWin(win);
};
srcdoc += '<script>window.parent.ampManageWin(window)</script>';
Expand Down Expand Up @@ -159,7 +159,7 @@ function installObserver(win) {
if (!window.MutationObserver) {
return;
}
const observer = new MutationObserver(function(mutations) {
const observer = new MutationObserver(function (mutations) {
for (let i = 0; i < mutations.length; i++) {
maybeInstrumentsNodes(win, mutations[i].addedNodes);
}
Expand All @@ -177,14 +177,14 @@ function installObserver(win) {
function instrumentEntryPoints(win) {
// Change setTimeout to respect a minimum timeout.
const {setTimeout} = win;
win.setTimeout = function(fn, time) {
win.setTimeout = function (fn, time) {
time = minTime(time);
arguments[1] = time;
return setTimeout.apply(this, arguments);
};
// Implement setInterval in terms of setTimeout to make
// it respect the same rules
win.setInterval = function(fn) {
win.setInterval = function (fn) {
const id = intervalId++;
const args = Array.prototype.slice.call(arguments);
/**
Expand All @@ -195,7 +195,8 @@ function instrumentEntryPoints(win) {
next();
if (typeof fn == 'string') {
// Handle rare and dangerous string arg case.
return (0, win.eval /*NOT OK but whatcha gonna do.*/).call(win, fn); // lgtm [js/useless-expression]
return (0, win.eval) /*NOT OK but whatcha gonna do.*/
.call(win, fn); // lgtm [js/useless-expression]
} else {
return fn.apply(this, arguments);
}
Expand All @@ -211,7 +212,7 @@ function instrumentEntryPoints(win) {
return id;
};
const {clearInterval} = win;
win.clearInterval = function(id) {
win.clearInterval = function (id) {
clearInterval(id);
win.clearTimeout(intervals[id]);
delete intervals[id];
Expand All @@ -235,11 +236,11 @@ function blockSyncPopups(win) {
}
try {
win.alert = maybeThrow;
win.prompt = function() {
win.prompt = function () {
maybeThrow();
return '';
};
win.confirm = function() {
win.confirm = function () {
maybeThrow();
return false;
};
Expand Down Expand Up @@ -269,7 +270,7 @@ function minTime(time) {
* Installs embed state listener.
*/
export function installEmbedStateListener() {
listenParent(window, 'embed-state', function(data) {
listenParent(window, 'embed-state', function (data) {
inViewport = data['inViewport'];
});
}
4 changes: 2 additions & 2 deletions 3p/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ export function facebook(global, data) {

getFacebookSdk(
global,
FB => {
(FB) => {
// Dimensions are given by the parent frame.
delete data.width;
delete data.height;

FB.Event.subscribe('xfbml.resize', event => {
FB.Event.subscribe('xfbml.resize', (event) => {
context.updateDimensions(
parseInt(event.width, 10),
parseInt(event.height, 10) + /* margins */ 20
Expand Down
4 changes: 2 additions & 2 deletions 3p/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {writeScript} from './3p';
* @param {function()} cb
*/
function getGistJs(global, scriptSource, cb) {
writeScript(global, scriptSource, function() {
writeScript(global, scriptSource, function () {
cb();
});
}
Expand All @@ -52,7 +52,7 @@ export function github(global, data) {
gistUrl += '?file=' + encodeURIComponent(data.file);
}

getGistJs(global, gistUrl, function() {
getGistJs(global, gistUrl, function () {
// Dimensions are given by the parent frame.
delete data.width;
delete data.height;
Expand Down
6 changes: 3 additions & 3 deletions 3p/iframe-messaging-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class IframeMessagingClient {
getData(requestType, payload, callback) {
const responseType = requestType + CONSTANTS.responseTypeSuffix;
const messageId = this.nextMessageId_++;
const unlisten = this.registerCallback(responseType, result => {
const unlisten = this.registerCallback(responseType, (result) => {
if (result[CONSTANTS.messageIdFieldName] === messageId) {
unlisten();
callback(result[CONSTANTS.contentFieldName]);
Expand Down Expand Up @@ -100,7 +100,7 @@ export class IframeMessagingClient {
* @return {*} TODO(#23582): Specify return type
*/
requestOnce(requestType, responseType, callback) {
const unlisten = this.registerCallback(responseType, event => {
const unlisten = this.registerCallback(responseType, (event) => {
unlisten();
callback(event);
});
Expand Down Expand Up @@ -191,7 +191,7 @@ export class IframeMessagingClient {
* @private
*/
setupEventListener_() {
listen(this.win_, 'message', event => {
listen(this.win_, 'message', (event) => {
// If we have set a host window, strictly check that it's from it.
if (this.hostWindow_ && event.source != this.hostWindow_) {
return;
Expand Down
4 changes: 2 additions & 2 deletions 3p/iframe-transport-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class IframeTransportClient {
this.iframeMessagingClient_.makeRequest(
MessageType.SEND_IFRAME_TRANSPORT_EVENTS,
MessageType.IFRAME_TRANSPORT_EVENTS,
eventData => {
(eventData) => {
const events =
/**
* @type
Expand All @@ -77,7 +77,7 @@ export class IframeTransportClient {
events.length,
'Received empty events list in ' + this.win_.location.href
);
events.forEach(event => {
events.forEach((event) => {
try {
devAssert(
event.creativeId,
Expand Down
4 changes: 2 additions & 2 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ export function draw3p(win, data, configCallback) {
win.context.tagName
);
if (configCallback) {
configCallback(data, data => {
configCallback(data, (data) => {
userAssert(data, 'Expected configuration to be passed as first argument');
run(type, win, data);
});
Expand All @@ -659,7 +659,7 @@ export function draw3p(win, data, configCallback) {
* @param {!Array<string>=} opt_allowedEmbeddingOrigins List of domain suffixes
* that are allowed to embed this frame.
*/
window.draw3p = function(
window.draw3p = function (
opt_configCallback,
opt_allowed3pTypes,
opt_allowedEmbeddingOrigins
Expand Down
Loading