Skip to content

Commit

Permalink
Update ESLint to consume @mozilla-protocol/eslint-config (Fixes mozil…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed May 2, 2019
1 parent 70877c0 commit 6ff77e8
Show file tree
Hide file tree
Showing 64 changed files with 631 additions and 597 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -12,7 +12,7 @@ jobs:

test_js:
docker:
- image: "circleci/node:6.11.4-browsers"
- image: "circleci/node:6.14.0-browsers"
steps:
- checkout
- restore_cache:
Expand Down
78 changes: 31 additions & 47 deletions .eslintrc.js
@@ -1,52 +1,36 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"jquery": true,
"jasmine": true
env: {
'jquery': true,
'jasmine': true
},
"extends": "eslint:recommended",
"rules": {
"no-global-assign": 2,
"indent": [
2,
4
],
"linebreak-style": [
2,
"unix"
],
"quotes": [
2,
"single"
],
"semi": [
2,
"always"
],
"curly": [
2,
"all"
],
"camelcase": [
2,
{
"properties": "always"
}
],
"eqeqeq": [
2,
"smart"
],
"one-var-declaration-per-line": [
2,
"always"
],
"new-cap": 2
extends: '@mozilla-protocol/eslint-config',
rules: {
'no-useless-escape': 1,
},
"globals": {
"Mozilla": true,
"Mzp": true,
"site": true
/**
* Provide a set of overrides for `gulpfile.js` in the root directory.
* Ideally we want to extend @mozilla-protocol/eslint-config/index-node,
* however ESLint does not currently allow extends inside glob overrides.
* (see https://github.com/eslint/eslint/issues/8813)
* */
overrides: [
{
files: 'gulpfile.js',
env: {
'commonjs': true,
'node': true,
'es6': true
},
parserOptions: {
ecmaVersion: 8
},
rules: {
'strict': ['error', 'global'],
}
}
],
globals: {
'Mozilla': true,
'site': true
}
};
2 changes: 2 additions & 0 deletions media/js/base/base-page-init.js
Expand Up @@ -6,6 +6,8 @@
* General DOM ready handler applied to all pages in base template.
*/
(function($) {
'use strict';

// page must be loaded and ready before onWindowLoad fires
var loaded = false;
var ready = false;
Expand Down
2 changes: 1 addition & 1 deletion media/js/base/class-list-polyfill.js
Expand Up @@ -59,7 +59,7 @@
}

// replace() support for others
if (window.DOMTokenList && DOMTokenList.prototype.replace == null) {
if (window.DOMTokenList && DOMTokenList.prototype.replace === null) {
DOMTokenList.prototype.replace = ClassList.prototype.replace;
}
})();
2 changes: 2 additions & 0 deletions media/js/base/core-datalayer-init.js
Expand Up @@ -4,6 +4,8 @@

// init core dataLayer object and push into dataLayer
$(function() {
'use strict';

var analytics = Mozilla.Analytics;
var client = Mozilla.Client;
var dataLayer = window.dataLayer = window.dataLayer || [];
Expand Down
6 changes: 4 additions & 2 deletions media/js/base/core-datalayer-page-id.js
Expand Up @@ -2,11 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

if (typeof Mozilla == 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function(Mozilla) {
'use strict';

// init dataLayer object
var dataLayer = window.dataLayer = window.dataLayer || [];
var Analytics = {};
Expand Down
6 changes: 4 additions & 2 deletions media/js/base/core-datalayer.js
Expand Up @@ -6,11 +6,13 @@
* Utility class for core dataLayer object to track contextual user and page data
*/

if (typeof Mozilla.Analytics == 'undefined') {
Mozilla.Analytics = {};
if (typeof window.Mozilla.Analytics === 'undefined') {
window.Mozilla.Analytics = {};
}

(function() {
'use strict';

var analytics = Mozilla.Analytics;
var isModernBrowser = 'querySelector' in document && 'querySelectorAll' in document;

Expand Down
4 changes: 2 additions & 2 deletions media/js/base/dnt-helper.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

/**
Expand Down
6 changes: 4 additions & 2 deletions media/js/base/mozilla-accordion-gatrack.js
Expand Up @@ -3,13 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

// If accordion is present, set up global GA functions
if (typeof Mozilla.Accordion === 'function') {
Mozilla.Accordion.globalOnExpand = function(section) {
'use strict';
// Google Analytics event tracking

window.dataLayer.push({
Expand All @@ -21,6 +22,7 @@ if (typeof Mozilla.Accordion === 'function') {
};

Mozilla.Accordion.globalOnCollapse = function(section) {
'use strict';
// Google Analytics event tracking

window.dataLayer.push({
Expand Down
8 changes: 3 additions & 5 deletions media/js/base/mozilla-accordion.js
Expand Up @@ -35,8 +35,8 @@
*/

// Create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

// {{{ Mozilla.Accordion
Expand Down Expand Up @@ -104,9 +104,7 @@ Mozilla.Accordion = function Accordion($accordion, options) {
this.accordionId = accordionId;

// Use the parent node's ID or generate an unique ID
this.id = (!$parent.is($accordion) && $parent.prop('id'))
? $parent.attr('id')
: accordionId + '-' + (index + 1);
this.id = (!$parent.is($accordion) && $parent.prop('id')) ? $parent.attr('id') : accordionId + '-' + (index + 1);

if (!headerId) {
headerId = this.id + '-header';
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-client.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function() {
Expand Down
10 changes: 8 additions & 2 deletions media/js/base/mozilla-cookie-helper.js
Expand Up @@ -27,16 +27,18 @@
\*/

// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

Mozilla.Cookies = {
getItem: function (sKey) {
'use strict';
if (!sKey) { return null; }
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
'use strict';
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = '';
if (vEnd) {
Expand All @@ -56,20 +58,24 @@ Mozilla.Cookies = {
return true;
},
removeItem: function (sKey, sPath, sDomain) {
'use strict';
if (!this.hasItem(sKey)) { return false; }
document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');
return true;
},
hasItem: function (sKey) {
'use strict';
if (!sKey) { return false; }
return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=')).test(document.cookie);
},
keys: function () {
'use strict';
var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:\=[^;]*)?;\s*/);
for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
return aKeys;
},
enabled: function() {
'use strict';
/**
* Cookies feature detect lifted from Modernizr
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-firefox-default.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function() {
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-fxa-form.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

Mozilla.FxaForm = (function(Mozilla) {
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-fxa.js
Expand Up @@ -6,8 +6,8 @@
// adds classes to the body to indicate state of fxaccount

// Create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function(Mozilla) {
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-highlight-target.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

/**
Expand Down
22 changes: 15 additions & 7 deletions media/js/base/mozilla-image-helper.js
Expand Up @@ -9,21 +9,19 @@
* @author Nick Burka <nick@silverorange.com>
*/

$(document).ready(function() {
Mozilla.ImageHelper.initPlatformImages();
});

// create namespace
if (typeof Mozilla == 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

// {{{ Mozilla.ImageHelper

/**
* ImageHelper object
*/
Mozilla.ImageHelper = function() {};
Mozilla.ImageHelper = function() {
'use strict';
};

Mozilla.ImageHelper._isHighDpi = null;

Expand All @@ -33,6 +31,8 @@ Mozilla.ImageHelper._isHighDpi = null;
// {{{ initPlatformImages()

Mozilla.ImageHelper.initPlatformImages = function() {
'use strict';

$('.platform-img').each(function() {
var $img = $(this);
var dataAttribute = 'src-';
Expand Down Expand Up @@ -74,6 +74,8 @@ Mozilla.ImageHelper.initPlatformImages = function() {
// {{{ isHighDpi()

Mozilla.ImageHelper.isHighDpi = function() {
'use strict';

if (Mozilla.ImageHelper._isHighDpi === null) {
var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5),' +
'(-o-min-device-pixel-ratio: 3/2),' +
Expand All @@ -88,3 +90,9 @@ Mozilla.ImageHelper.isHighDpi = function() {
};

// }}}

$(document).ready(function() {
'use strict';

Mozilla.ImageHelper.initPlatformImages();
});
4 changes: 2 additions & 2 deletions media/js/base/mozilla-lazy-load.js
Expand Up @@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function() {
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-modal.js
@@ -1,6 +1,6 @@
// create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

Mozilla.Modal = (function(w, $) {
Expand Down
4 changes: 2 additions & 2 deletions media/js/base/mozilla-notification-banner.js
Expand Up @@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Create namespace
if (typeof Mozilla === 'undefined') {
var Mozilla = {};
if (typeof window.Mozilla === 'undefined') {
window.Mozilla = {};
}

(function() {
Expand Down

0 comments on commit 6ff77e8

Please sign in to comment.