From d8975db15abf745d5ce27b417ee1b230effaa994 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Wed, 18 Nov 2020 17:24:28 +0100 Subject: [PATCH] chore: eslint fixes for logic/ folder --- logic/tracks.js | 22 +++++++++++----------- logic/tracks.test.js | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/logic/tracks.js b/logic/tracks.js index f74a434..582ba97 100644 --- a/logic/tracks.js +++ b/logic/tracks.js @@ -1,5 +1,5 @@ function _parseFloat(token) { - var f = parseFloat(token); + let f = parseFloat(token); if (isNaN(f)) { f = parseFloat(token.substring(0, 10)); } @@ -10,32 +10,32 @@ function _parseFloat(token) { } module.exports.addPointsToTrack = function addPointsToTrack(track, body) { - var num = 0; - var start = 0; - var end = 0; + let num = 0; + let start = 0; + let end = 0; // reference to the array we will mutate - var points = track.trackData.points; - var currentPoint; + const points = track.trackData.points; + let currentPoint; while (end < body.length) { start = end; - while (body[end] != ';' && body[end] != '$' && end < body.length) { + while (body[end] !== ';' && body[end] !== '$' && end < body.length) { end++; } - if (body[end] == '$') { + if (body[end] === '$') { // $ is replacing \n as newlines are not allowed in json strings num = 0; } if (end < body.length) { - var token = body.substr(start, end - start); + const token = body.substr(start, end - start); end++; if (token.length > 0) { - if (num == 0 && token == 'Date') { + if (num === 0 && token === 'Date') { // we have a header line, ignore it for now, TODO parse it if (end < body.length) { - while (body[end] != ';' && body[end] != '$' && end < body.length) { + while (body[end] !== ';' && body[end] !== '$' && end < body.length) { end++; } start = end; diff --git a/logic/tracks.test.js b/logic/tracks.test.js index 34b9f95..2110e8d 100644 --- a/logic/tracks.test.js +++ b/logic/tracks.test.js @@ -1,7 +1,7 @@ -var { addPointsToTrack } = require('./tracks'); -var TrackInfo = require('./TrackInfo'); +const { addPointsToTrack } = require('./tracks'); +const TrackInfo = require('./TrackInfo'); -var { test1 } = require('./_tracks_testdata'); +const { test1 } = require('./_tracks_testdata'); describe('addPointsToTrack', () => { it('is a function', () => { @@ -11,7 +11,7 @@ describe('addPointsToTrack', () => { it('works on the sample data with an empty track', () => { const trackInfo = new TrackInfo({}, { points: [] }); addPointsToTrack(trackInfo, test1); - var points = trackInfo.trackData.points; + const points = trackInfo.trackData.points; expect(points).toHaveLength(324); expect(points[0]).toEqual({ date: '12.07.2020',