From bd6d8d23b5d4c87fea8f978dcbccc2d551de4acb Mon Sep 17 00:00:00 2001 From: Robert-Frampton Date: Tue, 21 Nov 2017 11:00:02 -0800 Subject: [PATCH] Run format --- packages/metal-component/src/Component.js | 9 ++++-- .../src/ComponentDataManager.js | 6 +++- .../metal-component/src/ComponentRegistry.js | 4 ++- packages/metal-component/src/events/events.js | 6 +++- packages/metal-component/src/sync/sync.js | 4 ++- .../metal-dom/src/DomEventEmitterProxy.js | 11 ++++++-- packages/metal-dom/src/domNamed.js | 21 +++++++++++--- packages/metal-dom/src/events.js | 5 +++- packages/metal-dom/src/features.js | 5 ++-- packages/metal-dom/src/globalEval.js | 7 ++++- packages/metal-events/src/EventEmitter.js | 12 ++++++-- .../src/IncrementalDomRenderer.js | 4 ++- .../src/html/HTMLParser.js | 13 +++++++-- .../src/render/render.js | 12 ++++++-- packages/metal-jsx/src/JSXDataManager.js | 7 ++++- packages/metal-soy/src/Soy.js | 4 ++- packages/metal-soy/src/SoyAop.js | 3 +- packages/metal-state/src/State.js | 15 +++++++--- packages/metal-state/src/validators.js | 28 +++++++++++++++---- packages/metal/src/coreNamed.js | 4 ++- 20 files changed, 140 insertions(+), 40 deletions(-) diff --git a/packages/metal-component/src/Component.js b/packages/metal-component/src/Component.js index 2ec78249..9513a95b 100644 --- a/packages/metal-component/src/Component.js +++ b/packages/metal-component/src/Component.js @@ -238,7 +238,8 @@ class Component extends EventEmitter { attachElement(parentElement, siblingElement) { const element = this.element; if (element && (siblingElement || !element.parentNode)) { - const parent = toElement(parentElement) || this.DEFAULT_ELEMENT_PARENT; // eslint-disable-line + const parent = + toElement(parentElement) || this.DEFAULT_ELEMENT_PARENT; // eslint-disable-line parent.insertBefore(element, toElement(siblingElement)); } } @@ -648,7 +649,11 @@ class Component extends EventEmitter { this.dataManager_ = getStaticProperty(this.constructor, 'DATA_MANAGER'); this.dataManager_.setUp( this, - object.mixin({}, this.renderer_.getExtraDataConfig(this), Component.DATA) // eslint-disable-line + object.mixin( + {}, + this.renderer_.getExtraDataConfig(this), + Component.DATA + ) // eslint-disable-line ); } diff --git a/packages/metal-component/src/ComponentDataManager.js b/packages/metal-component/src/ComponentDataManager.js index afb91b5e..0bcb02b5 100644 --- a/packages/metal-component/src/ComponentDataManager.js +++ b/packages/metal-component/src/ComponentDataManager.js @@ -25,7 +25,11 @@ class ComponentDataManager { * @protected */ createState_(component, data) { - const state = new State(component.getInitialConfig(), component, component); // eslint-disable-line + const state = new State( + component.getInitialConfig(), + component, + component + ); // eslint-disable-line state.setKeysBlacklist(BLACKLIST); state.configState( object.mixin({}, data, State.getStateStatic(component.constructor)) diff --git a/packages/metal-component/src/ComponentRegistry.js b/packages/metal-component/src/ComponentRegistry.js index 959bed84..82cda90c 100644 --- a/packages/metal-component/src/ComponentRegistry.js +++ b/packages/metal-component/src/ComponentRegistry.js @@ -19,7 +19,9 @@ class ComponentRegistry { const constructorFn = ComponentRegistry.components_[name]; if (!constructorFn) { console.error( - `There's no constructor registered for the component named ${name}. + `There's no constructor registered for the component named ${ + name + }. Components need to be registered via ComponentRegistry.register.` ); } diff --git a/packages/metal-component/src/events/events.js b/packages/metal-component/src/events/events.js index 7c3b351b..61948f60 100644 --- a/packages/metal-component/src/events/events.js +++ b/packages/metal-component/src/events/events.js @@ -16,7 +16,11 @@ export function addListenersFromObj(component, events) { if (info.fn) { let handle; if (info.selector) { - handle = component.delegate(eventNames[i], info.selector, info.fn); // eslint-disable-line + handle = component.delegate( + eventNames[i], + info.selector, + info.fn + ); // eslint-disable-line } else { handle = component.on(eventNames[i], info.fn); } diff --git a/packages/metal-component/src/sync/sync.js b/packages/metal-component/src/sync/sync.js index f6fcccc6..cec45595 100644 --- a/packages/metal-component/src/sync/sync.js +++ b/packages/metal-component/src/sync/sync.js @@ -24,7 +24,9 @@ function getSyncFns_(component) { const keys = component.getDataManager().getSyncKeys(component); let canCache = true; for (let i = 0; i < keys.length; i++) { - const name = `sync${keys[i].charAt(0).toUpperCase()}${keys[i].slice(1)}`; + const name = `sync${keys[i].charAt(0).toUpperCase()}${keys[i].slice( + 1 + )}`; const fn = component[name]; if (fn) { fns[keys[i]] = fn; diff --git a/packages/metal-dom/src/DomEventEmitterProxy.js b/packages/metal-dom/src/DomEventEmitterProxy.js index 308cb8b5..ebdb4d8b 100644 --- a/packages/metal-dom/src/DomEventEmitterProxy.js +++ b/packages/metal-dom/src/DomEventEmitterProxy.js @@ -23,7 +23,12 @@ class DomEventEmitterProxy extends EventEmitterProxy { const index = event.indexOf(':', 9); const eventName = event.substring(9, index); const selector = event.substring(index + 1); - return delegate(this.originEmitter_, eventName, selector, listener); // eslint-disable-line + return delegate( + this.originEmitter_, + eventName, + selector, + listener + ); // eslint-disable-line } else { return on(this.originEmitter_, event, listener); } @@ -66,7 +71,9 @@ class DomEventEmitterProxy extends EventEmitterProxy { * @override */ shouldProxyEvent_(event) { - return super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event); // eslint-disable-line + return ( + super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event) + ); // eslint-disable-line } } diff --git a/packages/metal-dom/src/domNamed.js b/packages/metal-dom/src/domNamed.js index 4e10534b..a2c180b1 100644 --- a/packages/metal-dom/src/domNamed.js +++ b/packages/metal-dom/src/domNamed.js @@ -287,7 +287,13 @@ function isAbleToInteractWith_(node, eventName, eventObj) { return false; } - const matchesSelector = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'FIELDSET']; + const matchesSelector = [ + 'BUTTON', + 'INPUT', + 'SELECT', + 'TEXTAREA', + 'FIELDSET', + ]; if (eventName === 'click' && matchesSelector.indexOf(node.tagName) > -1) { return !(node.disabled || parent(node, 'fieldset[disabled]')); } @@ -370,7 +376,9 @@ export function hasClass(element, className) { * @private */ function hasClassWithNative_(element, className) { - return className.indexOf(' ') === -1 && element.classList.contains(className); + return ( + className.indexOf(' ') === -1 && element.classList.contains(className) + ); } /** @@ -723,7 +731,10 @@ export function toElement(selectorOrElement) { ) { return selectorOrElement; } else if (isString(selectorOrElement)) { - if (selectorOrElement[0] === '#' && selectorOrElement.indexOf(' ') === -1) { + if ( + selectorOrElement[0] === '#' && + selectorOrElement.indexOf(' ') === -1 + ) { return document.getElementById(selectorOrElement.substr(1)); } else { return document.querySelector(selectorOrElement); @@ -786,7 +797,9 @@ function toggleClassesWithoutNative_(element, classes) { elementClassName = `${elementClassName}${classes[i]} `; } else { const before = elementClassName.substring(0, classIndex); - const after = elementClassName.substring(classIndex + className.length); // eslint-disable-line + const after = elementClassName.substring( + classIndex + className.length + ); // eslint-disable-line elementClassName = `${before} ${after}`; } } diff --git a/packages/metal-dom/src/events.js b/packages/metal-dom/src/events.js index b3c97705..63756e32 100644 --- a/packages/metal-dom/src/events.js +++ b/packages/metal-dom/src/events.js @@ -21,7 +21,10 @@ function registerEvents() { const related = event.relatedTarget; const target = event.delegateTarget; // eslint-disable-next-line - if (!related || (related !== target && !contains(target, related))) { + if ( + !related || + (related !== target && !contains(target, related)) + ) { event.customType = eventName; return callback(event); } diff --git a/packages/metal-dom/src/features.js b/packages/metal-dom/src/features.js index 35781545..f90ca970 100644 --- a/packages/metal-dom/src/features.js +++ b/packages/metal-dom/src/features.js @@ -47,8 +47,9 @@ class features { } for (let i = 0; i < prefixes.length; i++) { if ( - features.animationElement_.style[prefixes[i] + typeTitleCase] !== // eslint-disable-line - undefined + features.animationElement_.style[ + prefixes[i] + typeTitleCase + ] !== undefined // eslint-disable-line ) { return prefixes[i].toLowerCase() + suffixes[i]; } diff --git a/packages/metal-dom/src/globalEval.js b/packages/metal-dom/src/globalEval.js index d186049f..954b5e62 100644 --- a/packages/metal-dom/src/globalEval.js +++ b/packages/metal-dom/src/globalEval.js @@ -112,7 +112,12 @@ class globalEval { scripts.item(index), function() { if (index < scripts.length - 1) { - globalEval.runScriptsInOrder(scripts, index + 1, defaultFn, appendFn); // eslint-disable-line + globalEval.runScriptsInOrder( + scripts, + index + 1, + defaultFn, + appendFn + ); // eslint-disable-line } else if (defaultFn) { async.nextTick(defaultFn); } diff --git a/packages/metal-events/src/EventEmitter.js b/packages/metal-events/src/EventEmitter.js index 2410e7c1..9902114c 100644 --- a/packages/metal-events/src/EventEmitter.js +++ b/packages/metal-events/src/EventEmitter.js @@ -157,7 +157,9 @@ class EventEmitter extends Disposable { */ getRawListeners_(event) { const directListeners = toArray(this.events_ && this.events_[event]); - return directListeners.concat(toArray(this.events_ && this.events_['*'])); + return directListeners.concat( + toArray(this.events_ && this.events_['*']) + ); } /** @@ -241,7 +243,8 @@ class EventEmitter extends Disposable { matchesListener_(listenerObj, listener) { const fn = listenerObj.fn || listenerObj; return ( - fn === listener || (listenerObj.origin && listenerObj.origin === listener) // eslint-disable-line + fn === listener || + (listenerObj.origin && listenerObj.origin === listener) // eslint-disable-line ); } @@ -285,7 +288,10 @@ class EventEmitter extends Disposable { * @param {!function()} handler */ onListener(handler) { - this.listenerHandlers_ = this.addHandler_(this.listenerHandlers_, handler); // eslint-disable-line + this.listenerHandlers_ = this.addHandler_( + this.listenerHandlers_, + handler + ); // eslint-disable-line } /** diff --git a/packages/metal-incremental-dom/src/IncrementalDomRenderer.js b/packages/metal-incremental-dom/src/IncrementalDomRenderer.js index 7f11b85a..8c64eaa0 100644 --- a/packages/metal-incremental-dom/src/IncrementalDomRenderer.js +++ b/packages/metal-incremental-dom/src/IncrementalDomRenderer.js @@ -193,7 +193,9 @@ class IncrementalDomRenderer extends ComponentRenderer.constructor { return false; } if (component.shouldUpdate) { - return component.shouldUpdate(...this.buildShouldUpdateArgs(changes)); // eslint-disable-line + return component.shouldUpdate( + ...this.buildShouldUpdateArgs(changes) + ); // eslint-disable-line } return true; } diff --git a/packages/metal-incremental-dom/src/html/HTMLParser.js b/packages/metal-incremental-dom/src/html/HTMLParser.js index bff74390..2b56d754 100644 --- a/packages/metal-incremental-dom/src/html/HTMLParser.js +++ b/packages/metal-incremental-dom/src/html/HTMLParser.js @@ -137,7 +137,8 @@ var HTMLParser = function(html, handler) { index = html.indexOf('-->'); if (index >= 0) { - if (handler.comment) handler.comment(html.substring(4, index)); + if (handler.comment) + handler.comment(html.substring(4, index)); html = html.substring(index + 3); chars = false; } @@ -203,7 +204,11 @@ var HTMLParser = function(html, handler) { // usually add anything they want to spans, and browsers allow it). // Note: this exception for "span" was added manually (i.e. it's not // present in the original code). - while (stack.last() && inline[stack.last()] && stack.last() !== 'span') { + while ( + stack.last() && + inline[stack.last()] && + stack.last() !== 'span' + ) { parseEndTag('', stack.last()); } } @@ -224,7 +229,9 @@ var HTMLParser = function(html, handler) { ? arguments[2] : arguments[3] ? arguments[3] - : arguments[4] ? arguments[4] : fillAttrs[name] ? name : ''; + : arguments[4] + ? arguments[4] + : fillAttrs[name] ? name : ''; attrs.push({ name: name, diff --git a/packages/metal-incremental-dom/src/render/render.js b/packages/metal-incremental-dom/src/render/render.js index 0fd3edec..2a1801cc 100644 --- a/packages/metal-incremental-dom/src/render/render.js +++ b/packages/metal-incremental-dom/src/render/render.js @@ -279,7 +279,9 @@ function handleRegularCall_(...args) { config.key = generateKey_(comp, config.key); if (!getData(comp).rootElementReached) { - const elementClasses = comp.getDataManager().get(comp, 'elementClasses'); + const elementClasses = comp + .getDataManager() + .get(comp, 'elementClasses'); if (elementClasses) { addElementClasses_(elementClasses, config); } @@ -343,7 +345,9 @@ function inheritElementClasses_(parent, config) { * @private */ export function isComponentTag_(tag) { - return isFunction(tag) || (isString(tag) && tag[0] === tag[0].toUpperCase()); // eslint-disable-line + return ( + isFunction(tag) || (isString(tag) && tag[0] === tag[0].toUpperCase()) + ); // eslint-disable-line } /** @@ -568,7 +572,9 @@ function resetNodeData_(node) { */ function updateContext_(comp, parent) { const context = comp.context; - const childContext = parent.getChildContext ? parent.getChildContext() : null; // eslint-disable-line + const childContext = parent.getChildContext + ? parent.getChildContext() + : null; // eslint-disable-line object.mixin(context, parent.context, childContext); comp.context = context; } diff --git a/packages/metal-jsx/src/JSXDataManager.js b/packages/metal-jsx/src/JSXDataManager.js index 087abdc7..0fc48703 100644 --- a/packages/metal-jsx/src/JSXDataManager.js +++ b/packages/metal-jsx/src/JSXDataManager.js @@ -109,7 +109,12 @@ class JSXDataManager extends ComponentDataManager.constructor { } const props = this.getManagerData(component).props_; - ComponentDataManager.replaceNonInternal.call(this, component, data, props); // eslint-disable-line + ComponentDataManager.replaceNonInternal.call( + this, + component, + data, + props + ); // eslint-disable-line this.addUnconfiguredProps_(component, props, data); if (component.propsChanged) { component.propsChanged(prevProps); diff --git a/packages/metal-soy/src/Soy.js b/packages/metal-soy/src/Soy.js index 866e9b63..70f39950 100644 --- a/packages/metal-soy/src/Soy.js +++ b/packages/metal-soy/src/Soy.js @@ -85,7 +85,9 @@ class Soy extends IncrementalDomRenderer.constructor { return function(data, ignored, ijData) { if (!goog.loadedModules_[namespace]) { throw new Error( - `No template with namespace "${namespace}" has been loaded yet.` + `No template with namespace "${ + namespace + }" has been loaded yet.` ); } return goog.loadedModules_[namespace][templateName]( diff --git a/packages/metal-soy/src/SoyAop.js b/packages/metal-soy/src/SoyAop.js index f3c516ec..dee929c2 100644 --- a/packages/metal-soy/src/SoyAop.js +++ b/packages/metal-soy/src/SoyAop.js @@ -32,7 +32,8 @@ const SoyAop = { * interception. */ handleTemplateCall_: function(originalFn, data, ignored, ijData) { - const interceptFn = SoyAop.interceptFns_[SoyAop.interceptFns_.length - 1]; // eslint-disable-line + const interceptFn = + SoyAop.interceptFns_[SoyAop.interceptFns_.length - 1]; // eslint-disable-line if (interceptFn) { return interceptFn.call(null, originalFn, data, ignored, ijData); } else { diff --git a/packages/metal-state/src/State.js b/packages/metal-state/src/State.js index 795b8ce4..0db18bc3 100644 --- a/packages/metal-state/src/State.js +++ b/packages/metal-state/src/State.js @@ -136,7 +136,9 @@ class State extends EventEmitter { assertValidStateKeyName_(name) { if (this.keysBlacklist_ && this.keysBlacklist_[name]) { throw new Error( - `It's not allowed to create a state key with the name "${name}".` + `It's not allowed to create a state key with the name "${ + name + }".` ); } } @@ -294,7 +296,9 @@ class State extends EventEmitter { ctor[staticKey] = ctor[staticKey] || {}; - defineContext = ctor[staticKey][ctor.name] ? false : ctor.prototype; // eslint-disable-line + defineContext = ctor[staticKey][ctor.name] + ? false + : ctor.prototype; // eslint-disable-line ctor[staticKey][ctor.name] = true; } this.configState(State.getStateStatic(ctor), defineContext); @@ -417,7 +421,8 @@ class State extends EventEmitter { hasBeenSet(name) { const info = this.getStateInfo(name); return ( - info.state === State.KeyStates.INITIALIZED || this.hasInitialValue_(name) // eslint-disable-line + info.state === State.KeyStates.INITIALIZED || + this.hasInitialValue_(name) // eslint-disable-line ); } @@ -697,7 +702,9 @@ class State extends EventEmitter { const disposed = this.isDisposed(); if (disposed) { console.warn( - `Error. Trying to access property "${name}" on disposed instance` + `Error. Trying to access property "${ + name + }" on disposed instance` ); } return disposed; diff --git a/packages/metal-state/src/validators.js b/packages/metal-state/src/validators.js index 677ea57a..6e7b8ef8 100644 --- a/packages/metal-state/src/validators.js +++ b/packages/metal-state/src/validators.js @@ -84,7 +84,11 @@ const validators = { return result; } return arrayOfValues.indexOf(value) === -1 - ? composeError(composeOneOfErrorMessage(arrayOfValues), name, context) // eslint-disable-line + ? composeError( + composeOneOfErrorMessage(arrayOfValues), + name, + context + ) // eslint-disable-line : true; }); }, @@ -98,14 +102,20 @@ const validators = { */ oneOfType: function(arrayOfTypeValidators) { return maybe((value, name, context) => { - const result = validators.array(arrayOfTypeValidators, name, context); // eslint-disable-line + const result = validators.array( + arrayOfTypeValidators, + name, + context + ); // eslint-disable-line if (isInvalid(result)) { return result; } for (let i = 0; i < arrayOfTypeValidators.length; i++) { // eslint-disable-next-line - if (!isInvalid(arrayOfTypeValidators[i](value, name, context))) { + if ( + !isInvalid(arrayOfTypeValidators[i](value, name, context)) + ) { return true; } } @@ -182,7 +192,9 @@ function composeError(error, name, context) { const renderer = context && context.getRenderer && context.getRenderer(); const parent = renderer && renderer.getParent && renderer.getParent(); const parentName = parent ? getFunctionName(parent.constructor) : null; - const location = parentName ? `Check render method of '${parentName}'.` : ''; + const location = parentName + ? `Check render method of '${parentName}'.` + : ''; return new Error( `Warning: Invalid state passed to '${name}'. ` + `${error} Passed to '${compName}'. ${location}` @@ -225,7 +237,9 @@ function isInvalid(result) { */ function maybe(typeValidator) { return (value, name, context) => { - return isDefAndNotNull(value) ? typeValidator(value, name, context) : true; // eslint-disable-line + return isDefAndNotNull(value) + ? typeValidator(value, name, context) + : true; // eslint-disable-line }; } @@ -257,7 +271,9 @@ function validateArrayItems(validator, value, name, context) { function validateType(expectedType, value, name, context) { const type = getType(value); if (type !== expectedType) { - const msg = `Expected type '${expectedType}', but received type '${type}'.`; + const msg = `Expected type '${expectedType}', but received type '${ + type + }'.`; return composeError(msg, name, context); } return true; diff --git a/packages/metal/src/coreNamed.js b/packages/metal/src/coreNamed.js index 0dbfd127..d829da0c 100644 --- a/packages/metal/src/coreNamed.js +++ b/packages/metal/src/coreNamed.js @@ -126,7 +126,9 @@ export function getStaticProperty( const mergedName = propertyName + '_MERGED'; if (!ctor.hasOwnProperty(mergedName)) { // eslint-disable-next-line - let merged = ctor.hasOwnProperty(propertyName) ? ctor[propertyName] : null; + let merged = ctor.hasOwnProperty(propertyName) + ? ctor[propertyName] + : null; if (ctor.__proto__ && !ctor.__proto__.isPrototypeOf(Function)) { merged = mergeFn( merged,