Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 6bc01a1

Browse files
author
Matt Gaunt
committed
Adding linting to all JS and fixing up the resulting errors - whoop whoop
1 parent 39c5525 commit 6bc01a1

File tree

15 files changed

+214
-287
lines changed

15 files changed

+214
-287
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/third_party

gulp-tasks/scripts.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ function generateES6Bundles(srcPath) {
9292
}
9393

9494
gulp.task('scripts:eslint', function() {
95-
return gulp.src([GLOBAL.config.src + '/**/*.es6.js'])
95+
return gulp.src([GLOBAL.config.src + '/**/*.js'])
9696

97-
// eslint() attaches the lint output to the eslint property
97+
// eslint() attaches the lint output to the eslint property,
9898
// of the file object so it can be used by other modules.
9999
.pipe(eslint())
100100

@@ -107,14 +107,13 @@ gulp.task('scripts:eslint', function() {
107107
.pipe(eslint.failOnError());
108108
});
109109

110-
gulp.task('scripts:es6', ['scripts:eslint'], function(cb) {
110+
gulp.task('scripts:es6', function(cb) {
111111
generateES6Bundles(GLOBAL.config.src);
112112

113113
cb();
114114
});
115115

116-
// TODO: Add linting for es5 JS
117-
gulp.task('scripts:es5', [], function() {
116+
gulp.task('scripts:es5', function() {
118117
return gulp.src([GLOBAL.config.src + '/**/*.es5.js'])
119118
.pipe(gulpif(GLOBAL.config.env !== 'prod', sourcemaps.init()))
120119

@@ -142,7 +141,10 @@ gulp.task('scripts:clean', function(cb) {
142141

143142
gulp.task('scripts', function(cb) {
144143
runSequence(
145-
'scripts:clean',
144+
[
145+
'scripts:clean',
146+
'scripts:eslint'
147+
],
146148
[
147149
'scripts:es6',
148150
'scripts:es5'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "app-shell",
3-
"version": "0.1.141",
3+
"version": "0.1.148",
44
"private": true,
55
"license": "Apache",
66
"engines": {

src/scripts/controller/AppController.js

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,25 @@
1717

1818
import Controller from './Controller';
1919
import AppModel from '../model/AppModel';
20-
import PubSubInstance from '../libs/PubSub';
21-
import ToasterInstance from '../libs/Toaster';
22-
import DialogInstance from '../libs/Dialog';
23-
import RouterInstance from '../libs/Router';
20+
import pubSubInstance from '../libs/PubSub';
21+
import toasterInstance from '../libs/Toaster';
22+
import routerInstance from '../libs/Router';
2423

2524
export default class AppController extends Controller {
2625

27-
constructor () {
28-
26+
constructor() {
2927
super();
3028

3129
this.appModel = null;
3230
this.sideNavToggleButton = document.querySelector('.js-toggle-menu');
3331
this.sideNav = document.querySelector('.js-side-nav');
3432
this.sideNavContent = this.sideNav.querySelector('.js-side-nav-content');
35-
this.loadScript('/scripts/list.js')
36-
this.newappshellingButton = document.querySelector('.js-new-appshelling-btn');
33+
this.loadScript('/scripts/list.js');
34+
this.newappshellingButton =
35+
document.querySelector('.js-new-appshelling-btn');
3736

3837
AppModel.get(1).then (appModel => {
39-
40-
RouterInstance().then(router => {
38+
routerInstance().then(router => {
4139
router.add('_root',
4240
(data) => this.show(data),
4341
() => this.hide());
@@ -58,26 +56,25 @@ export default class AppController extends Controller {
5856
var sideNavTransform;
5957
var onSideNavTouchStart = (e) => {
6058
touchStartX = e.touches[0].pageX;
61-
}
59+
};
6260

6361
var onSideNavTouchMove = (e) => {
64-
6562
var newTouchX = e.touches[0].pageX;
6663
sideNavTransform = Math.min(0, newTouchX - touchStartX);
6764

68-
if (sideNavTransform < 0)
65+
if (sideNavTransform < 0) {
6966
e.preventDefault();
67+
}
7068

7169
this.sideNavContent.style.transform =
7270
'translateX(' + sideNavTransform + 'px)';
73-
}
71+
};
7472

7573
var onSideNavTouchEnd = (e) => {
76-
77-
if (sideNavTransform < -1)
74+
if (sideNavTransform < -1) {
7875
this.closeSideNav();
79-
80-
}
76+
}
77+
};
8178

8279
this.sideNav.addEventListener('click', () => {
8380
this.closeSideNav();
@@ -92,8 +89,7 @@ export default class AppController extends Controller {
9289
// Wait for the first frame because sometimes
9390
// window.onload fires too quickly.
9491
requestAnimationFrame(() => {
95-
96-
function showWaitAnimation (e) {
92+
function showWaitAnimation(e) {
9793
e.target.classList.add('pending');
9894
}
9995

@@ -105,44 +101,39 @@ export default class AppController extends Controller {
105101
});
106102

107103
if ('serviceWorker' in navigator) {
108-
109104
navigator.serviceWorker.register('/sw.js', {
110105
scope: '/'
111106
}).then(function(registration) {
112-
113107
var isUpdate = false;
114108

115109
// If this fires we should check if there's a new Service Worker
116110
// waiting to be activated. If so, ask the user to force refresh.
117-
if (registration.active)
111+
if (registration.active) {
118112
isUpdate = true;
113+
}
119114

120115
registration.onupdatefound = function(event) {
121-
122-
console.log("A new Service Worker version has been found...");
116+
console.log('A new Service Worker version has been found...');
123117

124118
// If an update is found the spec says that there is a new Service
125119
// Worker installing, so we should wait for that to complete then
126120
// show a notification to the user.
127-
registration.installing.onstatechange = function(event) {
128-
121+
registration.installing.onstatechange = function(stateChangEvent) {
129122
if (this.state === 'installed') {
130-
131-
console.log("Service Worker Installed.");
123+
console.log('Service Worker Installed.');
132124

133125
if (isUpdate) {
134-
ToasterInstance().then(toaster => {
126+
toasterInstance().then(toaster => {
135127
toaster.toast(
136128
'App updated. Restart for the new version.');
137129
});
138130
} else {
139-
ToasterInstance().then(toaster => {
131+
toasterInstance().then(toaster => {
140132
toaster.toast('App ready for offline use.');
141133
});
142134
}
143-
144135
} else {
145-
console.log("New Service Worker state: ", this.state);
136+
console.log('New Service Worker state: ', this.state);
146137
}
147138
};
148139
};
@@ -154,35 +145,33 @@ export default class AppController extends Controller {
154145
}
155146

156147

157-
show () {
148+
show() {
158149
this.sideNavToggleButton.tabIndex = 1;
159150
this.newappshellingButton.tabIndex = 2;
160151
}
161152

162-
hide () {
153+
hide() {
163154
this.sideNavToggleButton.tabIndex = -1;
164155
this.newappshellingButton.tabIndex = -1;
165156

166-
PubSubInstance().then(ps => {
157+
pubSubInstance().then(ps => {
167158
ps.pub('list-covered');
168159
});
169160
}
170161

171-
toggleSideNav () {
172-
173-
if (this.sideNav.classList.contains('side-nav--visible'))
162+
toggleSideNav() {
163+
if (this.sideNav.classList.contains('side-nav--visible')) {
174164
this.closeSideNav();
175-
else
165+
} else {
176166
this.openSideNav();
167+
}
177168
}
178169

179170
openSideNav() {
180-
181171
this.sideNav.classList.add('side-nav--visible');
182172
this.sideNavToggleButton.focus();
183173

184174
var onSideNavTransitionEnd = (e) => {
185-
186175
// Force the focus, otherwise touch doesn't always work.
187176
this.sideNavContent.tabIndex = 0;
188177
this.sideNavContent.focus();
@@ -191,16 +180,14 @@ export default class AppController extends Controller {
191180
this.sideNavContent.classList.remove('side-nav__content--animatable');
192181
this.sideNavContent.removeEventListener('transitionend',
193182
onSideNavTransitionEnd);
194-
}
183+
};
195184

196185
this.sideNavContent.classList.add('side-nav__content--animatable');
197186
this.sideNavContent.addEventListener('transitionend',
198187
onSideNavTransitionEnd);
199188

200189
requestAnimationFrame( () => {
201-
202190
this.sideNavContent.style.transform = 'translateX(0px)';
203-
204191
});
205192
}
206193

@@ -209,6 +196,4 @@ export default class AppController extends Controller {
209196
this.sideNavContent.classList.add('side-nav__content--animatable');
210197
this.sideNavContent.style.transform = 'translateX(-102%)';
211198
}
212-
213-
214199
}

src/scripts/controller/ListController.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
*/
1717

1818
import Controller from './Controller';
19-
import RouterInstance from '../libs/Router';
20-
import PubSubInstance from '../libs/PubSub';
2119

2220
export default class ListController extends Controller {
2321

24-
constructor () {
22+
constructor() {
2523
super();
2624

2725
this.ctaView = document.querySelector('.js-cta');
@@ -35,7 +33,7 @@ export default class ListController extends Controller {
3533
});
3634
}
3735

38-
getContentAndPopulate () {
36+
getContentAndPopulate() {
3937
console.log('Get content and populate');
4038
this.ctaView.classList.add('empty-set-cta--visible');
4139
}

src/scripts/controller/StaticPageController.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import NavDrawerView from './../view/NavDrawerView';
2121
export default class StaticPageController extends Controller {
2222

2323
constructor() {
24-
2524
super();
2625

2726
this.navDrawer = new NavDrawerView();

src/scripts/libs/ConfigManager.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import Config from '../config/Config';
1919

20-
export default function ConfigManagerInstance () {
21-
22-
if (typeof window.ConfigManagerInstance_ !== 'undefined')
20+
export default function ConfigManagerInstance() {
21+
if (typeof window.ConfigManagerInstance_ !== 'undefined') {
2322
return Promise.resolve(window.ConfigManagerInstance_);
23+
}
2424

2525
window.ConfigManagerInstance_ = new ConfigManager();
2626

@@ -29,19 +29,19 @@ export default function ConfigManagerInstance () {
2929

3030
class ConfigManager {
3131

32-
constructor () {
32+
constructor() {
3333
this.config = Config;
3434
}
3535

36-
set config (c) {
36+
set config(c) {
3737
this.config_ = c;
3838
}
3939

40-
get config () {
40+
get config() {
4141
return this.config_;
4242
}
4343

44-
getStore (storeName) {
44+
getStore(storeName) {
4545
return this.config_.stores[storeName];
4646
}
4747

0 commit comments

Comments
 (0)