diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index f4ab9d0c3c7ed..b44b0e403cc90 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -239,7 +239,6 @@ define([ switch (optionType) { case 'radio': - case 'select-one': if (optionType === 'radio' && !element.is(':checked')) { diff --git a/app/code/Magento/Catalog/view/base/web/js/price-box.js b/app/code/Magento/Catalog/view/base/web/js/price-box.js index 20f42758bbbd0..cd72f5454b174 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-box.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-box.js @@ -38,9 +38,9 @@ define([ * Widget creating. */ _create: function createPriceBox() { - this.cache = {}; var box = this.element; + this.cache = {}; this._setDefaultsFromPriceConfig(); this._setDefaultsFromDataSet(); diff --git a/app/code/Magento/Catalog/view/base/web/js/price-options.js b/app/code/Magento/Catalog/view/base/web/js/price-options.js index bde03db76e089..ceeea4c878622 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-options.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-options.js @@ -43,7 +43,6 @@ define([ switch (optionType) { case 'text': - case 'textarea': changes[optionHash] = optionValue ? optionConfig.prices : {}; break; diff --git a/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js index 803a3879313c1..08b57f93841b4 100644 --- a/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js @@ -32,7 +32,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js index e06e10dc40c07..7178c2c4fc9dc 100644 --- a/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js @@ -32,7 +32,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js index 7036daa54e4f6..67a0d0aa2661e 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js index 6a06043607d87..627c729a9d17d 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js index a3a9ccaf5dbb3..d78f7be4d1500 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js @@ -38,7 +38,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js index fa58150e3e830..fccc8510ffc70 100644 --- a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js +++ b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js @@ -41,9 +41,11 @@ define([ * @param {jQuery} element - Comment holder */ (function lookup(element) { + var iframeHostName; + // prevent cross origin iframe content reading if ($(element).prop('tagName') === 'IFRAME') { - var iframeHostName = $('').prop('href', $(element).prop('src')) + iframeHostName = $('').prop('href', $(element).prop('src')) .prop('hostname'); if (window.location.hostname !== iframeHostName) { diff --git a/app/code/Magento/Theme/view/frontend/web/menu.js b/app/code/Magento/Theme/view/frontend/web/menu.js index aa13826bb6e87..677de6a241c7e 100644 --- a/app/code/Magento/Theme/view/frontend/web/menu.js +++ b/app/code/Magento/Theme/view/frontend/web/menu.js @@ -157,7 +157,7 @@ define([ //mainNav(); //run navigation with delays - mainNav('nav', { + window.mainNav('nav', { 'show_delay': '100', 'hide_delay': '100' }); diff --git a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js index a5a74e2fa2861..fe312738469e7 100644 --- a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js +++ b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js @@ -118,7 +118,7 @@ define([ component: node.component }); loaded.resolve(node, constr); - }, function (err) { + }, function () { consoleLogger.error('componentLoadingFail', { component: node.component }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/button.js b/app/code/Magento/Ui/view/base/web/js/form/components/button.js index e66a60e89492f..df85af5824d92 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/button.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/button.js @@ -10,8 +10,9 @@ define([ 'uiElement', 'uiRegistry', 'uiLayout', - 'mageUtils' -], function (Element, registry, layout, utils) { + 'mageUtils', + 'underscore' +], function (Element, registry, layout, utils, _) { 'use strict'; return Element.extend({ diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js index 0874a9d32c8e9..8bbe5971490a7 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js @@ -3,8 +3,9 @@ * See COPYING.txt for license details. */ define([ - './column' -], function (Column) { + './column', + 'underscore' +], function (Column, _) { 'use strict'; return Column.extend({ @@ -78,14 +79,14 @@ define([ flatOptions: function (options) { var self = this; - return options.reduce(function (options, option) { + return options.reduce(function (opts, option) { if (_.isArray(option.value)) { - options = options.concat(self.flatOptions(option.value)); + opts = opts.concat(self.flatOptions(option.value)); } else { - options.push(option); + opts.push(option); } - return options; + return opts; }, []); }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js index 162acef3b033b..20c885ba964f9 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js @@ -13,8 +13,6 @@ define([ 'use strict'; return Column.extend({ - - /*eslint-disable eqeqeq*/ /** * Retrieves label associated with a provided value. * @@ -57,17 +55,15 @@ define([ flatOptions: function (options) { var self = this; - return options.reduce(function (options, option) { + return options.reduce(function (opts, option) { if (_.isArray(option.value)) { - options = options.concat(self.flatOptions(option.value)); + opts = opts.concat(self.flatOptions(option.value)); } else { - options.push(option); + opts.push(option); } - return options; + return opts; }, []); } - - /*eslint-enable eqeqeq*/ }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/core/events.js b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js index 097cf1552439a..fdb11cd89f361 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/core/events.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js @@ -2,6 +2,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +/* global WeakMap, Map*/ define([ 'ko', 'underscore', @@ -34,7 +36,7 @@ define([ * * @param {Object} obj - Key in the events weakmap. * @param {String} ns - Callback namespace. - * @param {Fucntion} callback - Event callback. + * @param {Function} callback - Event callback. * @param {String} name - Name of the event. */ function addHandler(obj, ns, callback, name) { @@ -96,6 +98,7 @@ define([ * Calls callback when name event is triggered. * @param {String} events * @param {Function} callback + * @param {Function} ns * @return {Object} reference to this */ on: function (events, callback, ns) { diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js index 5ecb1930dcaed..a332b595bdf3c 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* global WeakMap */ define([ 'ko', 'underscore', @@ -87,6 +88,7 @@ define([ * Returns node's first sibling of 'element' type within the common component scope * * @param {HTMLElement} node + * @param {*} data * @returns {HTMLElement} */ function getElement(node, data) { @@ -111,6 +113,8 @@ define([ * to track nodes associated with model. * * @param {Function} orig - Original 'applyBindings' method. + * @param {Object} ctx + * @param {HTMLElement} node - Original 'applyBindings' method. */ applyBindings: function (orig, ctx, node) { var result = orig(), @@ -136,6 +140,7 @@ define([ * to track nodes associated with model. * * @param {Function} orig - Original 'cleanNode' method. + * @param {HTMLElement} node - Original 'cleanNode' method. */ cleanNode: function (orig, node) { var result = orig(), diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js index 546c6c913707f..b1f5eeff6fb63 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js @@ -66,7 +66,7 @@ define([ component: bindingContext.$data.name }); source.nodes(rendered); - }).fail(function (err) { + }).fail(function () { consoleLogger.error('templateLoadingFail', { template: templateId, component: bindingContext.$data.name diff --git a/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js b/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js index 194fc9501ed60..a6c7590ded663 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js @@ -34,11 +34,11 @@ define([], function () { promise.state() === 'pending' ? this.logger[levels.failed](messages.failed, config.data) : this.logger[levels.loaded](messages.loaded, config.data); - }.bind(this), wait) + }.bind(this), wait); }; /** - * Method that creats object of messages + * Method that creates object of messages * @param {String} requested - log message that showing that request for class is started * @param {String} loaded - log message that show when requested class is loaded * @param {String} failded - log message that show when requested class is failed @@ -49,11 +49,11 @@ define([], function () { requested: requested || '', loaded: loaded || '', failed: failded || '' - } + }; }; /** - * Method that creats object of log levels + * Method that creates object of log levels * @param {String} requested - log message that showing that request for class is started * @param {String} loaded - log message that show when requested class is loaded * @param {String} failded - log message that show when requested class is failed @@ -64,7 +64,7 @@ define([], function () { requested: requested || 'info', loaded: loaded || 'info', failed: failded || 'warn' - } + }; }; return LogUtils; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js index 5d97c50c3ff72..5c3c71e31823d 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js @@ -6,6 +6,7 @@ /** * @api */ +/* global WeakMap */ define([ 'jquery', 'underscore', diff --git a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js index 2156def5048d5..1cbbfb3ecee48 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* global WeakMap */ define([ 'es6-collections' ], function () { diff --git a/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js index 8eb74492fc98e..f3029b4f6c37e 100644 --- a/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js index 2365127e62a7a..6be63e5e5c2a1 100644 --- a/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js @@ -33,7 +33,7 @@ define([ } }); - if (!Boolean(this.validationErrors.length)) { + if (!this.validationErrors.length) { if (address['country_id'] == checkoutConfig.originCountryCode) { //eslint-disable-line eqeqeq return !utils.isEmpty(address.postcode); } diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js index 2683d624ae6e7..1c3b51919f5f3 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* eslint-disable max-nested-callbacks */ define([ 'Magento_Ui/js/grid/columns/expandable' ], function (Expandable) { diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js index 65051c4c72600..5028c254e49b0 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js @@ -138,7 +138,7 @@ define([ it('removes previously applied filter criteria', function () { var logger = createLogger(), criteria = function () { - return false + return false; }; spyOn(entryHandler, 'show'); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js index 204e79c8451cd..df125fbb45b9e 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* eslint-disable max-nested-callbacks */ define([ 'Magento_Ui/js/timeline/timeline' ], function (Timeline) { diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento index 6dd7d08063121..3e9844189a942 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento @@ -8,7 +8,6 @@ "node": true }, "rules": { - "consistent-return": 2, "eqeqeq": [2, "smart"], "guard-for-in": 2, "lines-around-comment": [ @@ -74,7 +73,7 @@ "radix": 2, "semi": [2, "always"], "semi-spacing": 2, - "strict": 2, + "strict": ["error", "function"], "use-isnan": 2, "valid-typeof": 2, "vars-on-top": 2 diff --git a/dev/tools/grunt/tasks/static.js b/dev/tools/grunt/tasks/static.js index 7d54c199ecd3a..22ae25673d214 100644 --- a/dev/tools/grunt/tasks/static.js +++ b/dev/tools/grunt/tasks/static.js @@ -20,13 +20,15 @@ module.exports = function (grunt) { var currentTarget = target || 'test', file = grunt.option('file'), tasks = [ + 'continue:on', 'eslint:' + currentTarget, - 'jscs:' + currentTarget + 'jscs:' + currentTarget, + 'continue:off', + 'continue:fail-on-warning' ]; setConfig('eslint', currentTarget, cvf.getFiles(file)); setConfig('jscs', currentTarget, cvf.getFiles(file)); - grunt.option('force', true); grunt.task.run(tasks); if (!grunt.option('file')) { diff --git a/lib/web/mage/adminhtml/grid.js b/lib/web/mage/adminhtml/grid.js index 8ffb5550726fa..c9af869d79161 100644 --- a/lib/web/mage/adminhtml/grid.js +++ b/lib/web/mage/adminhtml/grid.js @@ -841,7 +841,7 @@ define([ if (element.isMassactionCheckbox) { checkbox = element; //eslint-disable-line no-undef } - }.bind(this)); + }); return checkbox; //eslint-disable-line no-undef }, @@ -852,7 +852,7 @@ define([ initCheckboxes: function () { this.getCheckboxes().each(function (checkbox) { //eslint-disable-line no-extra-bind checkbox.isMassactionCheckbox = true; //eslint-disable-line no-undef - }.bind(this)); + }); }, /** @@ -954,7 +954,7 @@ define([ this.getCheckboxes().each(function (checkbox) { //eslint-disable-line no-extra-bind result.push(checkbox.value); - }.bind(this)); + }); return result; }, diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js index d4b0cddd0f708..aa0b19f5f11a2 100755 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js @@ -467,7 +467,7 @@ define([ return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind return Base64.mageDecode(match[1]); - }.bind(this)); + }); }, /** diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index 5947e1e25fde1..81bde35f9e12a 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -349,17 +349,17 @@ $.each(this._control.eventsMap, $.proxy(function (suggestEvent, controlEvents) { $.each(controlEvents, $.proxy(function (i, handlerName) { switch (suggestEvent) { - case 'select': - events[handlerName] = this._onSelectItem; - break; + case 'select': + events[handlerName] = this._onSelectItem; + break; - case 'focus': - events[handlerName] = this._focusItem; - break; + case 'focus': + events[handlerName] = this._focusItem; + break; - case 'blur': - events[handlerName] = this._blurItem; - break; + case 'blur': + events[handlerName] = this._blurItem; + break; } }, this)); }, this)); diff --git a/lib/web/mage/backend/tabs.js b/lib/web/mage/backend/tabs.js index 9dd362370948c..849b73c20b5b2 100644 --- a/lib/web/mage/backend/tabs.js +++ b/lib/web/mage/backend/tabs.js @@ -370,7 +370,7 @@ * @param {Object} data - event data object * @protected */ - _onBeforeSubmit: function (e, data) { + _onBeforeSubmit: function (e, data) { //eslint-disable-line no-unused-vars var activeAnchor = this.activeAnchor(), activeTabId = activeAnchor.prop('id'), options; diff --git a/lib/web/mage/backend/tree-suggest.js b/lib/web/mage/backend/tree-suggest.js index 4c6ba4e6c882c..47f034b0b2431 100644 --- a/lib/web/mage/backend/tree-suggest.js +++ b/lib/web/mage/backend/tree-suggest.js @@ -178,7 +178,6 @@ switch (event.keyCode) { case keyCode.LEFT: - case keyCode.RIGHT: if (this.isDropdownShown()) { diff --git a/lib/web/mage/requirejs/baseUrlResolver.js b/lib/web/mage/requirejs/baseUrlResolver.js index 1eef12f861faf..693006bf5f692 100644 --- a/lib/web/mage/requirejs/baseUrlResolver.js +++ b/lib/web/mage/requirejs/baseUrlResolver.js @@ -14,6 +14,9 @@ } }); */ + +/* global jsSuffixRegExp */ +/* eslint-disable max-depth */ define('baseUrlInterceptor', [ 'module' ], function (module) { @@ -23,6 +26,7 @@ define('baseUrlInterceptor', [ * RequireJS Context object */ var ctx = require.s.contexts._, + /** * Original function * @@ -37,6 +41,37 @@ define('baseUrlInterceptor', [ */ newContextConstr = require.s.newContext; + /** + * Remove dots from URL + * + * @param {Array} ary + */ + function trimDots(ary) { + var i, part, length = ary.length; + + for (i = 0; i < length; i++) { + part = ary[i]; + + if (part === '.') { + ary.splice(i, 1); + i -= 1; + } else if (part === '..') { + if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for a path starting with '..'. + //This can still fail, but catches the most reasonable + //uses of .. + break; + } else if (i > 0) { + ary.splice(i - 1, 2); + i -= 2; + } + } + } + } + /** * Normalize URL string (remove '/../') * @@ -47,8 +82,7 @@ define('baseUrlInterceptor', [ * @returns {*} */ function normalize(name, baseName, applyMap, localContext) { - var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, - foundMap, foundI, foundStarMap, starI, + var lastIndex, baseParts = baseName && baseName.split('/'), normalizedBaseParts = baseParts; @@ -88,47 +122,16 @@ define('baseUrlInterceptor', [ return name; } - /** - * Remove dots from URL - * - * @param {Array} ary - */ - function trimDots(ary) { - var i, part, length = ary.length; - - for (i = 0; i < length; i++) { - part = ary[i]; - - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - /** * Get full url. * - * @param {Object} ctx + * @param {Object} context * @param {String} url * @return {String} */ - function getUrl(ctx, url) { - var baseUrl = ctx.config.baseUrl, - newConfig = ctx.config, + function getUrl(context, url) { + var baseUrl = context.config.baseUrl, + newConfig = context.config, modulePath = url.replace(baseUrl, ''), newBaseUrl, rewrite = module.config()[modulePath]; @@ -166,11 +169,11 @@ define('baseUrlInterceptor', [ * @returns {String} */ newCtx.nameToUrl = function () { - return getUrl(newCtx, newOrigNameToUrl.apply(newCtx, arguments)) + return getUrl(newCtx, newOrigNameToUrl.apply(newCtx, arguments)); }; return newCtx; - } + }; }); require(['baseUrlInterceptor'], function () { diff --git a/lib/web/mage/requirejs/text.js b/lib/web/mage/requirejs/text.js index 1eb8d0fb1660d..74bc896890e74 100644 --- a/lib/web/mage/requirejs/text.js +++ b/lib/web/mage/requirejs/text.js @@ -86,8 +86,7 @@ define(['module'], function (module) { */ function getContent(url, callback, fail, headers) { var xhr = createRequest(url), - header, - errorHandler = fail || Function(); + header; xhr.open('GET', url); @@ -101,12 +100,11 @@ define(['module'], function (module) { } /** - * @override - * - * @param {Event} evt + * @inheritdoc */ - xhr.onreadystatechange = function (evt) { + xhr.onreadystatechange = function () { var status, err; + //Do not explicitly handle errors, those should be //visible via console output in the browser. if (xhr.readyState === 4) { diff --git a/lib/web/mage/view/composite.js b/lib/web/mage/view/composite.js index a9ee731075c78..245bfa1507c6a 100644 --- a/lib/web/mage/view/composite.js +++ b/lib/web/mage/view/composite.js @@ -5,12 +5,10 @@ /* eslint-disable strict */ define(['jquery'], function ($) { - return function (wrapperTag) { + return function () { var renderedChildren = {}, children = {}; - wrapperTag = wrapperTag || 'div'; - return { /** * @param {*} child diff --git a/lib/web/mage/zoom.js b/lib/web/mage/zoom.js index 4008c089d5313..d0d90df3eb2e5 100644 --- a/lib/web/mage/zoom.js +++ b/lib/web/mage/zoom.js @@ -181,34 +181,35 @@ }; switch (control) { - case 'display': - position = { - my: 'left+' + this.options.controls.display.left + ' top+' + this.options.controls.display.top + '', - at: 'left+' + $(this.image).outerWidth() + ' top', - of: $(this.image) - }; - break; + case 'display': + position = { + my: 'left+' + this.options.controls.display.left + ' top+' + + this.options.controls.display.top + '', + at: 'left+' + $(this.image).outerWidth() + ' top', + of: $(this.image) + }; + break; - case 'track': - $.extend(css, { - height: $(this.image).height(), - width: $(this.image).width() - }); - position = { - my: 'left top', - at: 'left top', - of: $(this.image) - }; - break; + case 'track': + $.extend(css, { + height: $(this.image).height(), + width: $(this.image).width() + }); + position = { + my: 'left top', + at: 'left top', + of: $(this.image) + }; + break; - case 'lens': - $.extend(css, this._calculateLensSize(), { - background: controlData.background, - opacity: controlData.opacity, - left: 0, - top: 0 - }); - break; + case 'lens': + $.extend(css, this._calculateLensSize(), { + background: controlData.background, + opacity: controlData.opacity, + left: 0, + top: 0 + }); + break; } this[control].css(css); diff --git a/package.json.sample b/package.json.sample index 2b657ac172b93..9cc2f8a770dd9 100644 --- a/package.json.sample +++ b/package.json.sample @@ -13,6 +13,7 @@ "grunt": "~1.0.1", "grunt-autoprefixer": "~3.0.4", "grunt-banner": "~0.6.0", + "grunt-continue": "~0.1.0", "grunt-contrib-clean": "~1.0.0", "grunt-contrib-connect": "~1.0.2", "grunt-contrib-cssmin": "~2.0.0", @@ -38,4 +39,4 @@ "time-grunt": "~1.0.0", "underscore": "~1.7.0" } -} +} \ No newline at end of file