mirror of
https://github.com/Luzifer/mapshare.git
synced 2024-12-20 22:51:19 +00:00
Lint: Let eslint do its job
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
d65dc6ede7
commit
ff3b426712
2 changed files with 96 additions and 10 deletions
84
frontend/.eslintrc.js
Normal file
84
frontend/.eslintrc.js
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
// https://eslint.org/docs/user-guide/configuring
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
'root': true,
|
||||||
|
'parserOptions': {
|
||||||
|
parser: 'babel-eslint',
|
||||||
|
ecmaVersion: 2018,
|
||||||
|
},
|
||||||
|
'env': {
|
||||||
|
browser: true,
|
||||||
|
},
|
||||||
|
'extends': [
|
||||||
|
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
|
||||||
|
'eslint:recommended',
|
||||||
|
],
|
||||||
|
'globals': {
|
||||||
|
axios: true,
|
||||||
|
L: true,
|
||||||
|
moment: true,
|
||||||
|
process: true,
|
||||||
|
Vue: true,
|
||||||
|
},
|
||||||
|
// add your custom rules here
|
||||||
|
'rules': {
|
||||||
|
'array-bracket-newline': ['error', { multiline: true }],
|
||||||
|
'array-bracket-spacing': ['error'],
|
||||||
|
'arrow-body-style': ['error', 'as-needed'],
|
||||||
|
'arrow-parens': ['error', 'as-needed'],
|
||||||
|
'arrow-spacing': ['error', { before: true, after: true }],
|
||||||
|
'block-spacing': ['error'],
|
||||||
|
'brace-style': ['error', '1tbs'],
|
||||||
|
'comma-dangle': ['error', 'always-multiline'], // Apply Contentflow rules
|
||||||
|
'comma-spacing': ['error'],
|
||||||
|
'comma-style': ['error', 'last'],
|
||||||
|
'curly': ['error'],
|
||||||
|
'dot-location': ['error', 'property'],
|
||||||
|
'dot-notation': ['error'],
|
||||||
|
'eol-last': ['error', 'always'],
|
||||||
|
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
|
||||||
|
'func-call-spacing': ['error', 'never'],
|
||||||
|
'function-paren-newline': ['error', 'multiline'],
|
||||||
|
'generator-star-spacing': ['off'], // allow async-await
|
||||||
|
'implicit-arrow-linebreak': ['error'],
|
||||||
|
'indent': ['error', 2],
|
||||||
|
'key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'strict' }],
|
||||||
|
'keyword-spacing': ['error'],
|
||||||
|
'linebreak-style': ['error', 'unix'],
|
||||||
|
'lines-between-class-members': ['error'],
|
||||||
|
'multiline-comment-style': ['warn'],
|
||||||
|
'newline-per-chained-call': ['error'],
|
||||||
|
'no-console': ['off'],
|
||||||
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // allow debugger during development
|
||||||
|
'no-else-return': ['error'],
|
||||||
|
'no-extra-parens': ['error'],
|
||||||
|
'no-implicit-coercion': ['error'],
|
||||||
|
'no-lonely-if': ['error'],
|
||||||
|
'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 0, maxBOF: 0 }],
|
||||||
|
'no-multi-spaces': ['error'],
|
||||||
|
'no-trailing-spaces': ['error'],
|
||||||
|
'no-unneeded-ternary': ['error'],
|
||||||
|
'no-useless-return': ['error'],
|
||||||
|
'no-whitespace-before-property': ['error'],
|
||||||
|
'object-curly-newline': ['error', { consistent: true }],
|
||||||
|
'object-curly-spacing': ['error', 'always'],
|
||||||
|
'object-shorthand': ['error'],
|
||||||
|
'padded-blocks': ['error', 'never'],
|
||||||
|
'prefer-arrow-callback': ['error'],
|
||||||
|
'prefer-const': ['error'],
|
||||||
|
'prefer-object-spread': ['error'],
|
||||||
|
'prefer-template': ['error'],
|
||||||
|
'quote-props': ['error', 'consistent-as-needed', { keywords: true }],
|
||||||
|
'quotes': ['error', 'single', { allowTemplateLiterals: true }],
|
||||||
|
'semi': ['error', 'never'],
|
||||||
|
'space-before-blocks': ['error', 'always'],
|
||||||
|
'spaced-comment': ['warn', 'always'],
|
||||||
|
'space-infix-ops': ['error'],
|
||||||
|
'space-in-parens': ['error', 'never'],
|
||||||
|
'space-unary-ops': ['error', { words: true, nonwords: false }],
|
||||||
|
'switch-colon-spacing': ['error'],
|
||||||
|
'unicode-bom': ['error', 'never'],
|
||||||
|
'wrap-iife': ['error'],
|
||||||
|
'yoda': ['error'],
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
const app = new Vue({
|
window.app = new Vue({
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
// Use defaults with custom icon paths
|
// Use defaults with custom icon paths
|
||||||
|
@ -9,11 +9,14 @@ const app = new Vue({
|
||||||
shadowUrl: '/asset/leaflet/marker-shadow.png',
|
shadowUrl: '/asset/leaflet/marker-shadow.png',
|
||||||
})
|
})
|
||||||
|
|
||||||
// This is only to detect another user updated the location
|
/*
|
||||||
// therefore this is NOT cryptographically safe!
|
* This is only to detect another user updated the location
|
||||||
|
* therefore this is NOT cryptographically safe!
|
||||||
|
*/
|
||||||
this.browserID = localStorage.getItem('browserID')
|
this.browserID = localStorage.getItem('browserID')
|
||||||
if (!this.browserID) {
|
if (!this.browserID) {
|
||||||
this.browserID = Math.random().toString(16).substr(2)
|
this.browserID = Math.random().toString(16)
|
||||||
|
.substr(2)
|
||||||
localStorage.setItem('browserID', this.browserID)
|
localStorage.setItem('browserID', this.browserID)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -38,12 +41,11 @@ const app = new Vue({
|
||||||
methods: {
|
methods: {
|
||||||
initMap() {
|
initMap() {
|
||||||
this.map = L.map('map')
|
this.map = L.map('map')
|
||||||
.setView([0,0], 13)
|
.setView([0, 0], 13)
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
}).addTo(this.map)
|
}).addTo(this.map)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
shareLocation() {
|
shareLocation() {
|
||||||
|
@ -73,9 +75,9 @@ const app = new Vue({
|
||||||
this.socket = new WebSocket(`${window.location.href.split('#')[0].replace(/^http/, 'ws')}/ws`)
|
this.socket = new WebSocket(`${window.location.href.split('#')[0].replace(/^http/, 'ws')}/ws`)
|
||||||
this.socket.onclose = () => window.setTimeout(this.subscribe, 1000) // Restart socket
|
this.socket.onclose = () => window.setTimeout(this.subscribe, 1000) // Restart socket
|
||||||
this.socket.onmessage = evt => {
|
this.socket.onmessage = evt => {
|
||||||
let loc= JSON.parse(evt.data)
|
const loc = JSON.parse(evt.data)
|
||||||
loc.time = new Date(loc.time)
|
loc.time = new Date(loc.time)
|
||||||
this.loc= loc
|
this.loc = loc
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -95,7 +97,7 @@ const app = new Vue({
|
||||||
const center = [this.loc.lat, this.loc.lon]
|
const center = [this.loc.lat, this.loc.lon]
|
||||||
|
|
||||||
if (!this.marker) {
|
if (!this.marker) {
|
||||||
this.marker = L.marker(center, {icon:this.icon})
|
this.marker = L.marker(center, { icon: this.icon })
|
||||||
.addTo(this.map)
|
.addTo(this.map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue