Skip to content

Commit 09b1486

Browse files
committed
use eslint package of standradjs
1 parent 4ab116f commit 09b1486

File tree

7 files changed

+24
-32
lines changed

7 files changed

+24
-32
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": ["standard"],
33
"rules": {
44
"max-len": ["error", 120],
5-
"no-console": "error"
5+
"no-console": "error",
6+
"import/no-webpack-loader-syntax": "off"
67
}
78
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"concurrently": "^3.6.0",
3838
"esdoc": "^1.1.0",
3939
"esdoc-standard-plugin": "^1.0.0",
40+
"eslint": "^5.1.0",
4041
"guide4you-builder": "3.2.1",
4142
"guide4you-proxy": "github:KlausBenndorf/guide4you-proxy#v1.1.0",
4243
"http-server": "^0.11.1",
@@ -45,7 +46,7 @@
4546
"openlayers": "github:KlausBenndorf/ol3#g4u3_v5.0.2",
4647
"phantomjs-prebuilt": "2.1.14",
4748
"selenium-webdriver": "3.6.0",
48-
"standard": "^11.0.1",
49+
"eslint-config-standard": "^11.0.0",
4950
"wait-on": "^2.1.0"
5051
},
5152
"scripts": {

src/API.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class API extends ol.Object {
321321
}
322322
let loadErrorHandler = () => {
323323
source.un('vectorloaderror', loadEndHandler)
324-
reject('vector load error')
324+
reject(new Error('vector load error'))
325325
}
326326
source.once('vectorloadend', loadEndHandler)
327327
source.once('vectorloaderror', loadErrorHandler)

src/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import '../images/g4u-logo.png'
55

66
import 'polyfill!requestAnimationFrame,cancelAnimationFrame,Element.prototype.classList,URL'
77

8-
window.jQuery = window.jQuery || $
9-
108
import {G4UMap} from './G4UMap'
119
import {Debug} from './Debug'
1210

11+
window.jQuery = window.jQuery || $
12+
1313
export function createMapInternal (element, clientConfPath, layerConfPath, options) {
1414
if (Array.isArray(options)) { // backwards compatibility
1515
options = { modules: options }
@@ -18,7 +18,7 @@ export function createMapInternal (element, clientConfPath, layerConfPath, optio
1818
return new Promise((resolve, reject) => {
1919
$(document).ready(() => {
2020
if (!$) {
21-
reject('jQuery not available.')
21+
reject(new Error('jQuery not available.'))
2222
} else {
2323
let v = $().jquery.split('.')
2424
if (+v[0] < 2 && +v[1] < 9) {
@@ -27,7 +27,7 @@ export function createMapInternal (element, clientConfPath, layerConfPath, optio
2727
}
2828

2929
if (!ol) {
30-
reject('OpenLayers not available.')
30+
reject(new Error('OpenLayers not available.'))
3131
}
3232

3333
$(element).empty()

src/utilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function asyncImageLoad (image, origUrl, finalUrl) {
8888
}
8989
return new Promise((resolve, reject) => {
9090
function onError () {
91-
reject(`Error loading url ${finalUrl}`)
91+
reject(new Error(`Error loading url ${finalUrl}`))
9292
}
9393
image.addEventListener('load', resolve)
9494
image.addEventListener('error', onError)

tests/layerSelector_spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import webdriver from 'selenium-webdriver'
1+
import {By, until} from 'selenium-webdriver'
22
import phantomDriver from './customPhantomDriver'
3-
import test from 'selenium-webdriver/testing/'
3+
import {describe, before, after, it} from 'selenium-webdriver/testing/'
44
import assert from 'selenium-webdriver/testing/assert.js'
55
import config from './config.js'
6-
import until from 'selenium-webdriver/lib/until'
7-
8-
let By = webdriver.By
9-
106
import {executeFunctionInPage, waitUntilMapReady} from './testUtils'
117

128
// globals in browser
@@ -24,22 +20,22 @@ function waitUntilSetFeatureLayers (driver, featureLayers) {
2420
.then(waitUntilMapReady(driver))
2521
}
2622

27-
test.describe('LayerSelector', function () {
23+
describe('LayerSelector', function () {
2824
this.timeout(config.mochaTimeout)
2925
let driver
3026

31-
test.before(function () {
27+
before(function () {
3228
driver = phantomDriver()
3329
driver.manage().window().setSize(1200, 800)
3430
driver.manage().timeouts().implicitlyWait(config.seleniumTimeout)
3531
driver.manage().timeouts().pageLoadTimeout(config.seleniumTimeout)
3632
})
3733

38-
test.after(function () {
34+
after(function () {
3935
driver.quit()
4036
})
4137

42-
test.it('should show a layerSelector', function (done) {
38+
it('should show a layerSelector', function (done) {
4339
driver.get(config.testClient).then(
4440
waitUntilMapReady(driver)
4541
).then(
@@ -62,7 +58,7 @@ test.describe('LayerSelector', function () {
6258
)
6359
})
6460

65-
test.it('should show a category button', function (done) {
61+
it('should show a category button', function (done) {
6662
driver.get(config.testClient).then(
6763
waitUntilMapReady(driver)
6864
).then(

tests/testUtils.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ export function waitUntilMapReady (driver) {
1414
driver.executeAsyncScript(function (callback) {
1515
setTimeout(function () {
1616
if (window.test) {
17-
callback('READY')
17+
callback(null)
1818
}
1919
if (!window.map) {
20-
callback('NOEXIST')
20+
callback(new Error('Map does not exist after 20 ms'))
2121
}
2222
const t = setTimeout(function () {
23-
callback('NOREADY')
23+
callback(new Error('Map not ready after 2000 ms'))
2424
}, 2000)
2525
window.map.asSoonAs('ready', true, function () {
2626
clearTimeout(t)
27-
callback('READY')
27+
callback(null)
2828
})
2929
}, 20)
30-
}).then(function (val) {
31-
if (val === 'READY') {
30+
}).then(function (err) {
31+
if (err === null) {
3232
fulfill()
3333
} else {
3434
driver.manage().logs().get('browser').then(function (logs) {
@@ -38,13 +38,7 @@ export function waitUntilMapReady (driver) {
3838
})
3939
}
4040
})
41-
if (val === 'NOEXIST') {
42-
reject('Map does not exist after 20 ms')
43-
} else if (val === 'NOREADY') {
44-
reject('Map not ready after 2000 ms')
45-
} else {
46-
reject('Unknown value')
47-
}
41+
reject(err)
4842
}
4943
})
5044
})

0 commit comments

Comments
 (0)