Commit 28b85157 authored by Peter Tönnies's avatar Peter Tönnies Committed by Peter Tönnies

updated eslint to v6, eslint-config-standard to v13, and eslint-plugin-html to v6

parent 414cc485
Pipeline #72321121 passed with stages
in 11 minutes and 50 seconds
......@@ -79,6 +79,7 @@
- remove verbose output of bounce mail processing and mail fetcher, add bounce mail stats to influx db @NerdyProjects
- remove progressbar from cron scripts !919 @NerdyProjects
- include rules from !511 in devdocs @flukx
- updated eslint to v6, eslint-config-standard to v13, and eslint-plugin-html to v6 @peter.toennies
# 2019-06-09 Hotfix
- InfluxDB Metrics via UDP !882 @alangecker
......
......@@ -21,11 +21,11 @@
"url": "^0.11.0"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.3",
"eslint": "^6.1.0",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"request": "^2.88.0",
"socket.io-client": "^2.2.0",
......
......@@ -26,14 +26,14 @@ let numConnections = 0
const sendToUser = (userId, channel, method, payload) => {
fetchSessionIdsForUser(userId, (err, sessionIds) => {
if (err) return console.error('could not get session ids for', userId, err)
for (let sessionId of sessionIds) {
for (const sessionId of sessionIds) {
sendToSession(sessionId, channel, method, payload)
}
})
}
const sendToSession = (sessionId, channel, method, payload) => {
for (let connection of connectionsForSession(sessionId)) {
for (const connection of connectionsForSession(sessionId)) {
connection.emit(channel, { m: method, o: payload })
}
}
......@@ -92,7 +92,7 @@ const parseRequestURL = (req) => {
}
const inputServer = http.createServer((req, res) => {
let url = parseRequestURL(req)
const url = parseRequestURL(req)
if (url.pathname === '/stats') {
res.writeHead(200)
res.end(JSON.stringify({
......@@ -119,7 +119,7 @@ const inputServer = http.createServer((req, res) => {
}
if (userIds) {
for (let userId of userIds.split(',')) {
for (const userId of userIds.split(',')) {
sendToUser(userId, app, method, options)
}
}
......@@ -137,7 +137,7 @@ const io = connectSocketIO(chatServer)
io.use((socket, next) => {
const cookieVal = socket.request.headers.cookie
if (cookieVal) {
let cookie = parseCookie(cookieVal)
const cookie = parseCookie(cookieVal)
socket.sid = cookie.PHPSESSID || cookie.sessionid
if (socket.sid) return next()
}
......
......@@ -228,11 +228,11 @@ test('can send and receive a message for multiple clients', t => {
test('can send to php users', t => {
t.timeoutAfter(10000)
t.plan(4)
let sessionId = randomString.generate()
let userId = 1
const sessionId = randomString.generate()
const userId = 1
addPHPSessionToRedis(userId, sessionId, err => {
t.error(err)
let socket = connect(t, sessionId)
const socket = connect(t, sessionId)
socket.on('someapp', data => {
t.equal(data.m, 'foo', 'passed m param')
t.equal(data.o, 'bar', 'passed o param')
......@@ -255,11 +255,11 @@ test('can send to php users', t => {
test('can send to api users', t => {
t.timeoutAfter(10000)
t.plan(4)
let sessionId = randomString.generate()
let userId = 2
const sessionId = randomString.generate()
const userId = 2
addAPISessionToRedis(userId, sessionId, err => {
t.error(err)
let socket = connect(t, sessionId, 'sessionid') // django session cookie name
const socket = connect(t, sessionId, 'sessionid') // django session cookie name
socket.on('someapp', (data) => {
t.equal(data.m, 'foo', 'passed m param')
t.equal(data.o, 'bar', 'passed o param')
......@@ -340,7 +340,7 @@ test('does not send to other users', t => {
})
function connect (t, sessionId, cookieName = 'PHPSESSID') {
let socket = io.connect(WS_URL, {
const socket = io.connect(WS_URL, {
transports: ['websocket'],
extraHeaders: {
cookie: serialize(cookieName, sessionId)
......
This diff is collapsed.
......@@ -57,13 +57,13 @@
"babel-polyfill": "^6.26.0",
"css-loader": "^2.1.1",
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-html": "^5.0.5",
"eslint-plugin-import": "^2.17.3",
"eslint": "^6.1.0",
"eslint-config-standard": "^13.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.2.3",
"exports-loader": "^0.7.0",
......
......@@ -9,7 +9,7 @@ const production = process.env.NODE_ENV === 'production'
Object.assign(module.exports, convert({
'leaflet': {
leaflet: {
dependencies: [
'leaflet/dist/leaflet.css'
]
......@@ -128,7 +128,7 @@ Object.assign(module.exports, convert({
}
},
'tablesorter': {
tablesorter: {
resolve: lib('tablesorter/jquery.tablesorter.js')
},
......
......@@ -185,7 +185,7 @@ const activity = {
$('#activity-option-form input[type=\'checkbox\']').each(function () {
if (!this.checked) {
let $el = $(this)
const $el = $(this)
activity.listOptions.push({ index: $el.attr('name'), id: $el.val() })
}
})
......
......@@ -4,7 +4,7 @@ import PhotonAddressEngine from 'typeahead-address-photon'
import L from 'leaflet'
import 'leaflet.awesome-markers'
let fsIcon = L.AwesomeMarkers.icon({
const fsIcon = L.AwesomeMarkers.icon({
icon: 'smile',
markerColor: 'orange',
prefix: 'fa'
......@@ -24,7 +24,7 @@ function showSelected (event, selected, map, engine) {
icon: fsIcon,
draggable: true
}).on('dragend', function (event) {
let pos = event.target.getLatLng()
const pos = event.target.getLatLng()
engine.reverseGeocode([pos.lat, pos.lng])
}).addTo(markers)
map.fitBounds(markers.getBounds())
......@@ -33,8 +33,8 @@ function showSelected (event, selected, map, engine) {
export function attachAddressPicker () {
const data = [$('#lat').val(), $('#lon').val()]
let center = [51, 12]
let initialZoom = 4
let map = L.map('map').setView(center, initialZoom)
const initialZoom = 4
const map = L.map('map').setView(center, initialZoom)
setTimeout(() => (map.invalidateSize()), 400)
L.tileLayer('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', {
......@@ -43,11 +43,11 @@ export function attachAddressPicker () {
attribution: 'Geocoding by <a href="https://photon.komoot.de">Komoot Photon</a>, Tiles by <a href="https://foundation.wikimedia.org/w/index.php?title=Maps_Terms_of_Use">Wikimedia</a>'
}).addTo(map)
let engine = new PhotonAddressEngine(
const engine = new PhotonAddressEngine(
{
url: 'https://photon.komoot.de',
formatResult: function (feature) {
let prop = feature.properties
const prop = feature.properties
return [prop.name || '', prop.street, prop.housenumber || '', prop.postcode, prop.city, prop.country].filter(Boolean).join(' ')
},
lang: 'de'
......@@ -72,8 +72,8 @@ export function attachAddressPicker () {
engine.bindDefaultTypeaheadEvent($('#addresspicker'))
$(engine).bind('addresspicker:selected', function (event, selectedPlace) {
showSelected(event, selectedPlace, map, engine)
let prop = selectedPlace.properties
let geo = selectedPlace.geometry.coordinates
const prop = selectedPlace.properties
const geo = selectedPlace.geometry.coordinates
$('#lat').val(geo[1])
$('#lon').val(geo[0])
if (prop.postcode) {
......
......@@ -19,8 +19,8 @@ import { get } from './base'
function mapOldResponseToNewFormat (data) {
const mapping = {
'Foodsaver': 'users',
'Bezirk': 'regions',
Foodsaver: 'users',
Bezirk: 'regions',
'Kooperationsbetrieb/e': 'stores',
'Deine Gruppen': 'myGroups',
'Deine Betriebe': 'myStores',
......@@ -28,7 +28,7 @@ function mapOldResponseToNewFormat (data) {
'Menschen die Du kennst': 'myBuddies'
}
return data.reduce((o, el) => {
let key = mapping[el.title]
const key = mapping[el.title]
o[key] = el.result.map(i => ({
id: i.id || parseInt(i.href.match(/id=(.*?)(&|$)/)[1]),
name: i.name,
......
......@@ -14,9 +14,9 @@ const HTTP_GET_VARS = []
const strGET = document.location.search.substr(1, document.location.search.length)
if (strGET !== '') {
let gArr = strGET.split('&')
const gArr = strGET.split('&')
for (let i = 0; i < gArr.length; ++i) {
let v = ''; let vArr = gArr[i].split('=')
let v = ''; const vArr = gArr[i].split('=')
if (vArr.length > 1) { v = vArr[1] }
HTTP_GET_VARS[unescape(vArr[0])] = unescape(v)
}
......
......@@ -10,7 +10,7 @@ import emojiList from '@/emojiList.json'
// TODO:
export default {
props: {
'name': {
name: {
type: String,
default: null
}
......
......@@ -96,10 +96,10 @@ export default {
}
this.isLoading = true
try {
let user = await login(this.email, this.password)
const user = await login(this.email, this.password)
pulseSuccess(`<b>Wunderschönen Tag Dir, ${user.name}!</b><br />Du hast Dich erfolgreich eingeloggt und wirst gleich weitergeleitet.`)
let urlParams = new URLSearchParams(window.location.search)
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has('ref')) {
window.location = decodeURIComponent(urlParams.get('ref'))
......
......@@ -39,7 +39,7 @@ export default {
computed: {
items () {
// TODO: replace hard coded links with $url()
let items = []
const items = []
if (this.isOrgaTeam) {
items.push(...[
{
......
......@@ -54,14 +54,14 @@ export default {
},
title () {
if (this.conversation.title) return this.conversation.title
let members = this.conversation.members
const members = this.conversation.members
// without ourselve
.filter(m => m.id !== this.loggedinUser.id)
return members.map(m => m.name).join(', ')
},
avatars () {
let lastId = this.conversation.lastMessage.authorId
const lastId = this.conversation.lastMessage.authorId
let members = this.conversation.members
// without ourselve
......
......@@ -132,9 +132,9 @@ export default {
this.isOpen = false
},
async fetch () {
let curQuery = this.query
const curQuery = this.query
this.isLoading = true
let res = await instantSearch(curQuery)
const res = await instantSearch(curQuery)
if (curQuery !== this.query) {
// query has changed, throw away this response
return false
......
......@@ -125,7 +125,7 @@
import SearchResultEntry from './SearchResultEntry'
function arrayFilterDuplicate (list, ignore) {
let ids = ignore.map(e => e.id)
const ids = ignore.map(e => e.id)
return list.filter(e => ids.indexOf(e.id) === -1)
}
......@@ -187,12 +187,12 @@ export default {
// filter elements, whether all of the query words are contained somewhere in name or teaser
const filterFunction = (e) => {
if (!words.length) return false
for (let word of words) {
for (const word of words) {
if (!match(word, e)) return false
}
return true
}
let res = {
const res = {
stores: this.stores.filter(filterFunction),
regions: this.regions.filter(filterFunction),
users: this.users.filter(filterFunction),
......
......@@ -11,10 +11,9 @@ export default function (key, variables = {}) {
console.error(new Error(`Missing translation for [${key}]`))
return key
}
return message.replace(/\{([^}]+)\}/g, (match, name) => {
if (variables.hasOwnProperty(name)) {
const value = variables[name]
return value
return message.replace(/{([^}]+)}/g, (match, name) => {
if (Object.prototype.hasOwnProperty.call(variables, name)) {
return variables[name]
} else {
throw new Error(`Variable [${name}] was not provided for [${key}]`)
}
......
......@@ -40,8 +40,8 @@ var join = {
const mapEL = document.getElementById('map')
if (mapEL) {
initializeMap(mapEL, (result) => {
let prop = result.properties
let geo = result.geometry.coordinates
const prop = result.properties
const geo = result.geometry.coordinates
$('#join_lat').val(geo[1])
$('#join_lon').val(geo[0])
$('#join_plz').val(prop.postcode)
......@@ -131,8 +131,8 @@ var join = {
$('#login_email').trigger('select')
return false
}
let birthdate = new Date($('#birthdate').val())
let now = new Date()
const birthdate = new Date($('#birthdate').val())
const now = new Date()
let diff = now.getFullYear() - birthdate.getFullYear()
if (birthdate.getMonth() > now.getMonth()) {
diff--
......
......@@ -205,7 +205,7 @@ const msg = {
* Method will be called if there arrived something new from the server
*/
pushArrived: function (data) {
let ret = data.msg_heartbeat
const ret = data.msg_heartbeat
console.log(ret._duration)
......@@ -246,9 +246,9 @@ const msg = {
$('#compose_submit').on('click', function (ev) {
ev.preventDefault()
let recip = msg.getRecipients()
const recip = msg.getRecipients()
if (recip != false) {
let body = $('#compose_body').val()
const body = $('#compose_body').val()
if (body != '') {
ajax.req('msg', 'newconversation', {
data: {
......@@ -276,7 +276,7 @@ const msg = {
},
prependMsg: function (message) {
let $el = msg.msgTpl(message)
const $el = msg.msgTpl(message)
if (msg.$conversation == undefined) {
msg.$conversation = $('#msg-conversation')
......@@ -288,7 +288,7 @@ const msg = {
},
appendMsg: function (message) {
let $el = msg.msgTpl(message)
const $el = msg.msgTpl(message)
if (msg.$conversation == undefined) {
msg.$conversation = $('#msg-conversation')
......@@ -311,7 +311,7 @@ const msg = {
},
getRecipients: function () {
let out = []
const out = []
$('#compose_recipients li.tagedit-listelement-old input').each(function () {
let id = $(this).attr('name').replace('compose_recipients[', '').split('-')[0]
id = parseInt(id)
......@@ -393,7 +393,7 @@ const msg = {
},
loadMore: function () {
let lmid = parseInt($('#msg-conversation li:first').attr('id').replace('msg-', ''))
const lmid = parseInt($('#msg-conversation li:first').attr('id').replace('msg-', ''))
if (!msg.moreIsLoading) {
msg.moreIsLoading = true
......@@ -410,7 +410,7 @@ const msg = {
msg.prependMsg(ret.messages[i])
}
let position = $(`#msg-${lmid}`).position()
const position = $(`#msg-${lmid}`).position()
if (!position) return
......@@ -430,7 +430,7 @@ const msg = {
if (!msg.isMob()) {
msg.$conversation.off('scroll')
msg.$conversation.on('scroll', function () {
let $conv = $(this)
const $conv = $(this)
if ($conv.scrollTop() == 0) {
msg.loadMore()
}
......@@ -438,7 +438,7 @@ const msg = {
} else {
$(window).off('scroll')
$(window).on('scroll', function () {
let $conv = $(this)
const $conv = $(this)
if ($conv.scrollTop() == 0) {
msg.loadMore()
......
......@@ -32,8 +32,8 @@ export const dialogs = {
}
export function collapse_wrapper (id) {
let $content = $(`#${id}-wrapper .element-wrapper`)
let $label = $(`#${id}-wrapper .wrapper-label i`)
const $content = $(`#${id}-wrapper .element-wrapper`)
const $label = $(`#${id}-wrapper .wrapper-label i`)
if ($content.is(':visible')) {
$content.hide()
$label.removeClass('fa-caret-down').addClass('fa-caret-right')
......@@ -44,10 +44,10 @@ export function collapse_wrapper (id) {
}
export function closeAllDialogs () {
let $activeDialogs = $('.ui-dialog').find('.ui-dialog-content')
const $activeDialogs = $('.ui-dialog').find('.ui-dialog-content')
$activeDialogs.each(function () {
let $dia = $(this)
const $dia = $(this)
$dia.dialog()
if ($dia.dialog('isOpen')) {
$dia.dialog().dialog('close')
......@@ -80,10 +80,10 @@ export function initialize () {
$('.moreswap').each(function () {
var height = 100
let $this = $(this)
const $this = $(this)
$this.after('<a class="moreswaplink" href="#" data-show="0">Mehr anzeigen</a>')
let cheight = $this.attr('class').split('moreswap-height-')
const cheight = $this.attr('class').split('moreswap-height-')
if (cheight.length > 1) {
height = parseInt(cheight[1])
......@@ -93,31 +93,31 @@ export function initialize () {
if ($this.height() > 100) {
$this.css({
'height': `${height}px`,
'overflow': 'hidden'
height: `${height}px`,
overflow: 'hidden'
})
}
})
$('.moreswaplink').each(function () {
let $this = $(this)
const $this = $(this)
$this.prev().css({
'height': `${g_moreswapheight}px`,
'overflow': 'hidden'
height: `${g_moreswapheight}px`,
overflow: 'hidden'
})
$this.on('click', function (ev) {
ev.preventDefault()
if ($this.attr('data-show') == 0) {
$this.prev().css({
'height': 'auto',
'overflow': 'visible'
height: 'auto',
overflow: 'visible'
})
$this.text('einklappen')
$this.attr('data-show', 1)
} else {
$this.prev().css({
'height': `${g_moreswapheight}px`,
'overflow': 'hidden'
height: `${g_moreswapheight}px`,
overflow: 'hidden'
})
$this.text('Mehr anzeigen')
$this.attr('data-show', 0)
......@@ -181,7 +181,7 @@ export function initialize () {
goTo($('#dialog-confirm-url').val())
$(this).dialog('close')
},
'Abbrechen': function () {
Abbrechen: function () {
$(this).dialog('close')
}
}
......@@ -209,7 +209,7 @@ export function initialize () {
)
$('.value').on('blur', function () {
let el = $(this)
const el = $(this)
if (el.val() != '') {
el.removeClass('input-error')
}
......@@ -220,7 +220,7 @@ export function initialize () {
modal: true,
buttons:
{
'Upload': function () {
Upload: function () {
uploadPhoto()
}
}
......@@ -248,8 +248,8 @@ export function addbanana (fsid) {
$('#fsprofileratemsg-wrapper label').html($('.vouch-banana-title').html())
$('#fsprofileratemsg-wrapper div.desc').html($('.vouch-banana-desc').html())
$('#fsprofileratemsg').css({
'height': '137px',
'width': '558px'
height: '137px',
width: '558px'
})
$('#fs-profile-rate-comment').dialog('option', {
width: 600,
......@@ -516,8 +516,8 @@ export function ifconfirm (url, question, title) {
export function picFinish (img, id) {
$(`#${id}-action`).val('upload')
$.fancybox.close()
let d = new Date()
let imgp = `${img}?${d.getTime()}`
const d = new Date()
const imgp = `${img}?${d.getTime()}`
$(`#${id}-open`).html(`<img src="images/${imgp}" /><input type="hidden" name="photo" value="${img}" />`)
hideLoader()
reload()
......@@ -529,12 +529,12 @@ export function pic_error (msg, id) {
}
export function fotoupload (file, id) {
$(`#${id}-file`).val(file)
let d = new Date()
let img = `${file}?${d.getTime()}`
const d = new Date()
const img = `${file}?${d.getTime()}`
$(`#${id}-placeholder`).html(`<img src="./tmp/${img}" />`)
$(`#${id}-placeholder img`).Jcrop({
setSelect: [ 100, 0, 400, 400 ],
setSelect: [100, 0, 400, 400],
aspectRatio: 35 / 45,
onSelect: function (c) {
$(`#${id}-x`).val(c.x)
......@@ -573,16 +573,16 @@ export function pictureReady (id, img) {
}
export function pictureCrop (id, img) {
let ratio = $.parseJSON($(`#${id}-ratio`).val())
let ratio_val = $.parseJSON($(`#${id}-ratio-val`).val())
const ratio = $.parseJSON($(`#${id}-ratio`).val())
const ratio_val = $.parseJSON($(`#${id}-ratio-val`).val())
let ratio_i = parseInt($(`#${id}-ratio-i`).val())
const ratio_i = parseInt($(`#${id}-ratio-i`).val())
if (ratio[ratio_i] != undefined) {
$(`#${id}-ratio-i`).val((ratio_i + 1))
$(`#${id}-crop`).html(`<img src="images/${id}/${img}" /><br /><span id="${id}-crop-save">Speichern</span>`)
$(`#${id}-crop img`).Jcrop({
setSelect: [ 100, 0, 400, 400 ],
setSelect: [100, 0, 400, 400],
aspectRatio: ratio[ratio_i],
onSelect: function (c) {
$(`#${id}-x`).val(c.x)
......@@ -625,12 +625,12 @@ export function u_loadCoords (addressdata, func) {
if (addressdata.str != undefined) {
anschrift = `${addressdata.str} ${addressdata.hsnr}`
} else {
let tmp = addressdata.anschrift.split('/')
const tmp = addressdata.anschrift.split('/')
anschrift = tmp[0]
}
let address = encodeURIComponent(`${anschrift}, ${addressdata.plz}, ${addressdata.stadt}, Germany`)
const address = encodeURIComponent(`${anschrift}, ${addressdata.plz}, ${addressdata.stadt}, Germany`)
let url = `https://search.mapzen.com/v1/search?text=${address}`
const url = `https://search.mapzen.com/v1/search?text=${address}`
showLoader()
$(function () {
......@@ -665,7 +665,7 @@ export function betriebRequest (id) {
showLoader()
$.ajax({
url: '/xhr.php?f=betriebRequest',
data: { 'id': id },
data: { id: id },
dataType: 'json',
success: function (data) {
if (data.status == 1) {
......
......@@ -15,7 +15,7 @@ export default new Vue({
this.bells = await getBellList()
},
async delete (id) {
let bell = this.bells.find(b => b.id === id)
const bell = this.bells.find(b => b.id === id)
this.$set(bell, 'isDeleting', true)
try {
await deleteBell(id)
......@@ -26,10 +26,10 @@ export default new Vue({
}
},
async markAsRead (bell) {
let bellsToMarkAsRead = this.allBellsWithSameHref(bell)
const bellsToMarkAsRead = this.allBellsWithSameHref(bell)
let ids = []
for (let b of bellsToMarkAsRead) {
const ids = []
for (const b of bellsToMarkAsRead) {
b.isRead = true
ids.push(b.id)
}
......
......@@ -36,7 +36,7 @@ const ui = new Vue({
},
methods: {
updateWindowWidth (event) {
let w = document.documentElement.clientWidth
const w = document.documentElement.clientWidth
this.windowWidth = w
this.wXS = w <= mediaQuery.xs.max
this.wSM = w >= mediaQuery.sm.min && w <= mediaQuery.sm.max
......
......@@ -16,7 +16,7 @@ const timeformat = {
const date = parts[0]
parts = date.split('-')
let out = `${parts[2]}.${parts[1]}.${parts[0]} `
const out = `${parts[2]}.${parts[1]}.${parts[0]} `
parts = time.split(':')
return `${out + parts[0]}.${parts[1]} Uhr`
......
......@@ -39,7 +39,7 @@ export default {
},
methods: {
getWindowWidth (event) {
let w = document.documentElement.clientWidth
const w = document.documentElement.clientWidth
this.windowWidth = w
this.wXS = w <= mediaQuery.xs.max
this.wSM = w >= mediaQuery.sm.min && w <= mediaQuery.sm.max
......