Skip to content

Commit

Permalink
adds eslint config for client, fixes all linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benib committed Mar 18, 2017
1 parent f5e555b commit 30b807c
Show file tree
Hide file tree
Showing 50 changed files with 312 additions and 330 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# 2 space indentation
[**.*]
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions client/.eslintrc.json
@@ -0,0 +1,6 @@
{
"extends": "./node_modules/aurelia-tools/.eslintrc.json",
"rules": {
"indent": [2, 2, { "SwitchCase": 1 }]
}
}
36 changes: 16 additions & 20 deletions client/src/app.js
Expand Up @@ -22,7 +22,7 @@ export class App {
configureRouter(config, router) {
this.router = router;
config.title = 'NZZ Q';
config.addPreActivateStep(ConfigAvailableCheckStep)
config.addPreActivateStep(ConfigAvailableCheckStep);
config.addAuthorizeStep(AuthorizeStep); // Add a route filter to the authorize extensibility point.

let routerMap = [
Expand All @@ -45,25 +45,23 @@ export class App {
route: ['item/:id'],
name: 'item',
moduleId: 'pages/item-overview',
auth: true,
auth: true
},
{
route: ['editor/:tool/:id?'],
name: 'editor',
moduleId: 'pages/editor',
auth: true,
auth: true
},
{
route: ['server-unavailable'],
name: 'server-unavailable',
moduleId: 'pages/server-unavailable',
title: 'Error'
},
}
];

router.configure(config => {
config.map(routerMap);
})
config.map(routerMap);

config.fallbackRoute('index');

Expand All @@ -74,7 +72,7 @@ export class App {
}
config.options.pushState = true;
config.options.root = '/';
})
});
}

async attached() {
Expand All @@ -85,15 +83,15 @@ export class App {
stylesheets
.map(stylesheet => {
if (!stylesheet.url && stylesheet.path) {
stylesheet.url = `${QServerBaseUrl}${stylesheet.path}`
stylesheet.url = `${QServerBaseUrl}${stylesheet.path}`;
}
return stylesheet
return stylesheet;
})
.map(stylesheet => {
if (stylesheet.url) {
let link = document.createElement('link');
link.type = 'text/css';
link.rel = "stylesheet";
link.rel = 'stylesheet';
link.href = stylesheet.url;
document.head.appendChild(link);
} else if (stylesheet.content) {
Expand All @@ -102,7 +100,7 @@ export class App {
style.appendChild(document.createTextNode(stylesheet.content));
document.head.appendChild(style);
}
})
});
}
} catch (e) {
// nevermind
Expand All @@ -125,13 +123,12 @@ class AuthorizeStep {
.then(() => {
if (!this.user.isLoggedIn) {
return next.cancel(new Redirect('login'));
} else {
return next();
}
return next();
})
.catch((e) => {
return next.cancel(new Redirect('login'));
})
});
}

return next();
Expand All @@ -140,11 +137,11 @@ class AuthorizeStep {

@inject(QConfig)
class ConfigAvailableCheckStep {

constructor(qConfig) {
this.qConfig = qConfig;
}

async run(navigationInstruction, next) {
if (navigationInstruction.getAllInstructions().some(i => i.config.name === 'server-unavailable')) {
return next();
Expand All @@ -153,10 +150,9 @@ class ConfigAvailableCheckStep {
await this.qConfig.configLoaded;
if (!this.qConfig.config) {
return next.cancel(new Redirect('server-unavailable'));
} else {
return next();
}
} catch(e) {
return next();
} catch (e) {
return next.cancel(new Redirect('server-unavailable'));
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/binding-behaviors/index.js
@@ -1,4 +1,4 @@
export function configure(frameworkConfiguration) {
frameworkConfiguration
.globalResources('./TimeAgoBindingBehavior.js')
.globalResources('./TimeAgoBindingBehavior.js');
}
15 changes: 7 additions & 8 deletions client/src/dialogs/account-dialog.js
Expand Up @@ -5,7 +5,7 @@ import { Router } from 'aurelia-router';

import { I18N } from 'aurelia-i18n';

import QConfig from 'resources/QConfig.js'
import QConfig from 'resources/QConfig.js';
import User from 'resources/User.js';
import Auth from 'resources/Auth.js';

Expand All @@ -28,17 +28,16 @@ export class AccountDialog {
}

async loadDepartments() {
let departments = await this.qConfig.get('departments')
let departments = await this.qConfig.get('departments');
this.departments = departments.sort();
}

activate(config) {
async activate(config) {
this.config = config;
this.user.loaded.then(() => {
if (!this.user.isLoggedIn) {
this.router.navigateToRoute('login');
}
})
await this.user.loaded;
if (!this.user.isLoggedIn) {
this.router.navigateToRoute('login');
}
}

async logout() {
Expand Down
5 changes: 2 additions & 3 deletions client/src/dialogs/help-dialog.js
@@ -1,5 +1,4 @@
import { inject } from 'aurelia-framework';
import { Container } from 'aurelia-dependency-injection';
import { DialogController } from 'aurelia-dialog';
import QConfig from 'resources/QConfig.js';

Expand All @@ -22,8 +21,8 @@ export class HelpDialog {
let half = Math.ceil(faq.length / 2);
for (let i = 0; i < half; i++) {
newOrderFaq.push(faq[i]);
if (faq[i+half]) {
newOrderFaq.push(faq[i+half]);
if (faq[i + half]) {
newOrderFaq.push(faq[i + half]);
}
}
return newOrderFaq;
Expand Down
31 changes: 14 additions & 17 deletions client/src/eastereggs.js
@@ -1,8 +1,7 @@
var keypressSerie = undefined;
var runningEggs = {};
let keypressSerie = undefined;
let runningEggs = {};

export function registerEastereggs(eastereggConfig) {

if (!eastereggConfig || !eastereggConfig.hasOwnProperty('sounds')) {
return;
}
Expand All @@ -21,43 +20,41 @@ export function registerEastereggs(eastereggConfig) {
keypressSerie.push(event.keyCode);
}
if (eastereggConfig.sounds.hasOwnProperty('bondTheme')) {
if (keypressSerie.join('-') == '48-48-55') {
if (runningEggs['bond']) {
if (runningEggs['bond'].paused) {
runningEggs['bond'].play();
if (keypressSerie.join('-') === '48-48-55') {
if (runningEggs.bond) {
if (runningEggs.bond.paused) {
runningEggs.bond.play();
} else {
runningEggs['bond'].pause();
runningEggs.bond.pause();
}
} else {
let bond = new Audio(eastereggConfig.sounds.bondTheme);
runningEggs['bond'] = bond;
runningEggs.bond = bond;
bond.play();
}
}
}
if (eastereggConfig.sounds.hasOwnProperty('q')) {
if (keypressSerie.join('-') == '81') {
if (runningEggs['q']) {
if (runningEggs['q'].paused) {
runningEggs['q'].play();
if (keypressSerie.join('-') === '81') {
if (runningEggs.q) {
if (runningEggs.q.paused) {
runningEggs.q.play();
} else {
runningEggs['q'].pause();
runningEggs.q.pause();
}
} else {
let q = new Audio(eastereggConfig.sounds.q);
runningEggs['q'] = q;
runningEggs.q = q;
q.play();
}
}
}
}

});

document.addEventListener('keyup', (event) => {
if (event.keyCode === 16) {
keypressSerie = undefined;
}
});

}
4 changes: 2 additions & 2 deletions client/src/elements/atoms/icon-button.js
@@ -1,7 +1,7 @@
import { bindable, inject } from 'aurelia-framework';
import { bindable } from 'aurelia-framework';

export class IconButton {

@bindable icon
@bindable code
@bindable size
Expand Down
2 changes: 1 addition & 1 deletion client/src/elements/atoms/index.js
Expand Up @@ -7,5 +7,5 @@ export function configure(frameworkConfiguration) {
.globalResources('./button-tertiary.html')
.globalResources('./button-yes.html')
.globalResources('./icon-button.html')
.globalResources('./q-loader.html')
.globalResources('./q-loader.html');
}

0 comments on commit 30b807c

Please sign in to comment.