From d303416dba49f0a824ed94cd7b85e3e57cc24dd6 Mon Sep 17 00:00:00 2001 From: zneix Date: Fri, 28 Aug 2020 23:57:50 +0200 Subject: [PATCH] fixed eslint formatting --- .gitignore | 1 + server.js | 10 +++++----- static/application.js | 14 +++++++------- test/key_generators/phonetic_spec.js | 26 +++++++++++++------------- test/key_generators/random_spec.js | 20 ++++++++++---------- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 847fd1c..016abe9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules .vscode data +data-test *.swp *.swo diff --git a/server.js b/server.js index 7ce4164..91319ed 100644 --- a/server.js +++ b/server.js @@ -10,6 +10,11 @@ const HasteUtils = require('./lib/util'); const utils = new HasteUtils(); +//load config and set some defaults +const config = require('./config'); +config.port = config.port || 7777; +config.host = config.host || '127.0.0.1'; + //set up logger winston.add(new winston.transports.Console({ level: config.logging.level, @@ -19,11 +24,6 @@ winston.add(new winston.transports.Console({ ), })); -//load config and set some defaults -const config = require('./config'); -config.port = config.port || 7777; -config.host = config.host || '127.0.0.1'; - //defaulting storage type to file if (!config.storage){ config.storage = { diff --git a/static/application.js b/static/application.js index 0467461..006a73b 100644 --- a/static/application.js +++ b/static/application.js @@ -28,13 +28,13 @@ haste_document.prototype.load = function(key, callback, lang){ let high; try { if (lang == 'txt'){ - high = { value: _this.htmlEscape(res.data) }; + high = { value: _this.htmlEscape(res.data) }; } else if (lang){ - high = hljs.highlight(lang, res.data); + high = hljs.highlight(lang, res.data); } else { - high = hljs.highlightAuto(res.data); + high = hljs.highlightAuto(res.data); } } catch(err){ @@ -68,7 +68,7 @@ haste_document.prototype.save = function(data, callback){ _this.locked = true; _this.key = res.key; let high = hljs.highlightAuto(data); - callback(null, { + callback(null, { value: high.value, key: res.key, language: high.language, @@ -130,7 +130,7 @@ haste.prototype.configureKey = enable => { let $this; $('#box2 .function').each(function(){ $this = $(this); - for (el of enable){ + for (const el of enable){ if ($this.hasClass(el)){ $this.addClass('enabled'); return true; @@ -315,7 +315,7 @@ haste.prototype.configureButtons = function(){ } } ]; - for (button of this.buttons){ + for (const button of this.buttons){ this.configureButton(button); } }; @@ -346,7 +346,7 @@ haste.prototype.configureButton = function(options){ haste.prototype.configureShortcuts = function(){ let _this = this; $(document.body).keydown(function(evt){ - for (button of _this.buttons){ + for (const button of _this.buttons){ if (button.shortcut && button.shortcut(evt)){ evt.preventDefault(); button.action(); diff --git a/test/key_generators/phonetic_spec.js b/test/key_generators/phonetic_spec.js index 14ad9e8..cf8acef 100644 --- a/test/key_generators/phonetic_spec.js +++ b/test/key_generators/phonetic_spec.js @@ -8,20 +8,20 @@ const vowels = 'aeiou'; const consonants = 'bcdfghjklmnpqrstvwxyz'; describe('RandomKeyGenerator', () => { - describe('randomKey', () => { - it('should return a key of the proper length', () => { - const gen = new Generator(); - assert.equal(6, gen.createKey(6).length); - }); + describe('randomKey', () => { + it('should return a key of the proper length', () => { + const gen = new Generator(); + assert.equal(6, gen.createKey(6).length); + }); - it('should alternate consonants and vowels', () => { - const gen = new Generator(); + it('should alternate consonants and vowels', () => { + const gen = new Generator(); - const key = gen.createKey(3); + const key = gen.createKey(3); - assert.ok(consonants.includes(key[0])); - assert.ok(consonants.includes(key[2])); - assert.ok(vowels.includes(key[1])); - }); - }); + assert.ok(consonants.includes(key[0])); + assert.ok(consonants.includes(key[2])); + assert.ok(vowels.includes(key[1])); + }); + }); }); diff --git a/test/key_generators/random_spec.js b/test/key_generators/random_spec.js index 537a809..aace497 100644 --- a/test/key_generators/random_spec.js +++ b/test/key_generators/random_spec.js @@ -5,15 +5,15 @@ const assert = require('assert'); const Generator = require('../../lib/key_generators/random'); describe('RandomKeyGenerator', () => { - describe('randomKey', () => { - it('should return a key of the proper length', () => { - const gen = new Generator(); - assert.equal(6, gen.createKey(6).length); - }); + describe('randomKey', () => { + it('should return a key of the proper length', () => { + const gen = new Generator(); + assert.equal(6, gen.createKey(6).length); + }); - it('should use a key from the given keyset if given', () => { - const gen = new Generator({keyspace: 'A'}); - assert.equal('AAAAAA', gen.createKey(6)); - }); - }); + it('should use a key from the given keyset if given', () => { + const gen = new Generator({keyspace: 'A'}); + assert.equal('AAAAAA', gen.createKey(6)); + }); + }); });