Skip to content

Commit

Permalink
Handle linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KristjanESPERANTO committed Sep 18, 2024
1 parent a657842 commit 502efef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
8 changes: 4 additions & 4 deletions BvgFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module.exports = class BvgFetcher {
}

async init() {
const { createClient } = await import("hafas-client");
const { profile } = await import(`hafas-client/p/bvg/index.js`);
const {createClient} = await import("hafas-client");
const {profile} = await import("hafas-client/p/bvg/index.js");
this.hafasClient = createClient(
profile,
`MMM-PublicTransportBerlin v${pjson.version}`
Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports = class BvgFetcher {
// TODO: Make real stop/station handling here
// Quick fix to work around missing station objects
if (!row.station) {
row.station = row.stop; // eslint-disable-line no-param-reassign
row.station = row.stop;
}

// If log level is set to debug print infos about departures
Expand Down Expand Up @@ -140,7 +140,7 @@ module.exports = class BvgFetcher {
// helper function to print departure for debugging
static printDeparture(row) {
const delayMinutes = Math.floor(
(((row.delay % 31536000) % 86400) % 3600) / 60
row.delay % 31536000 % 86400 % 3600 / 60
);

const time = new Date(row.when).toLocaleTimeString([], {
Expand Down
27 changes: 15 additions & 12 deletions MMM-PublicTransportBerlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ Module.register("MMM-PublicTransportBerlin", {
this.departuresArray.forEach((currentDeparture, i) => {
if (
i >=
reachableDeparturePos -
this.config.maxUnreachableDepartures &&
reachableDeparturePos -
this.config.maxUnreachableDepartures &&
i < reachableDeparturePos + this.config.maxReachableDepartures
) {
// Insert rule to separate reachable from unreachable departures
Expand Down Expand Up @@ -213,7 +213,7 @@ Module.register("MMM-PublicTransportBerlin", {

if (i >= reachableDeparturePos - steps && i < reachableDeparturePos) {
const currentStep = reachableDeparturePos - i;
opacity = 1 - ((1 / steps) * currentStep - 0.2);
opacity = 1 - (1 / steps * currentStep - 0.2);
}
}

Expand All @@ -234,7 +234,7 @@ Module.register("MMM-PublicTransportBerlin", {
const steps = this.config.maxReachableDepartures - startingPoint;
if (i >= startingPoint) {
const currentStep = i - reachableDeparturePos - startingPoint;
opacity = 1 - (1 / steps) * currentStep;
opacity = 1 - 1 / steps * currentStep;
}
}

Expand Down Expand Up @@ -420,9 +420,9 @@ Module.register("MMM-PublicTransportBerlin", {
if (depArray.length > 1 && i < depArray.length - 1) {
const nextWhen = moment(depArray[i + 1].when);
if (
(currentWhen.isBefore(nowWithDelay) &&
nextWhen.isSameOrAfter(nowWithDelay)) ||
(i === 0 && nextWhen.isSameOrAfter(nowWithDelay))
currentWhen.isBefore(nowWithDelay) &&
nextWhen.isSameOrAfter(nowWithDelay) ||
i === 0 && nextWhen.isSameOrAfter(nowWithDelay)
) {
resolve(i);
}
Expand All @@ -445,9 +445,9 @@ Module.register("MMM-PublicTransportBerlin", {
dirString = dirString.split(",")[0];
}

const viaIndex = dirString.search(/( via )/g);
const viaIndex = dirString.search(/( via )/gu);
if (viaIndex > -1) {
dirString = dirString.split(/( via )/g)[0];
dirString = dirString.split(/( via )/gu)[0];
}

return dirString;
Expand All @@ -457,8 +457,11 @@ Module.register("MMM-PublicTransportBerlin", {
const symbol = document.createElement("div");

if (product.type === "express") {
if (product.name === "LOCOMORE") symbol.innerHTML = "LOC";
else symbol.innerHTML = "ICE";
if (product.name === "LOCOMORE") {
symbol.innerHTML = "LOC";
} else {
symbol.innerHTML = "ICE";
}
} else {
symbol.innerHTML = product.name;
}
Expand All @@ -478,7 +481,7 @@ Module.register("MMM-PublicTransportBerlin", {
},

convertDelayToMinutes(delay) {
return Math.floor((((delay % 31536000) % 86400) % 3600) / 60);
return Math.floor(delay % 31536000 % 86400 % 3600 / 60);
},

getTranslations() {
Expand Down
10 changes: 7 additions & 3 deletions convenience/query_stations.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import { createClient } from "hafas-client";
import * as readline from "node:readline";
import {createClient} from "hafas-client";

let profileName = "";
const productMap = {};
Expand Down Expand Up @@ -92,8 +92,8 @@ if (process.argv.length === 3) {
profileName = "bvg";
}

try {
const { profile } = await import(`hafas-client/p/${profileName}/index.js`);
async function importProfile() {
const {profile} = await import(`hafas-client/p/${profileName}/index.js`);

Object.keys(profile.products).forEach((key) => {
const productMapKey = profile.products[key].id;
Expand All @@ -102,6 +102,10 @@ try {
});

query(profile);
}

try {
importProfile();
} catch (e) {
console.error(`${e.message}\n\n Did you choose the right profile name? \n`);
}
4 changes: 1 addition & 3 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ module.exports = NodeHelper.create({
this.pimpDeparturesArray(departuresData.departuresArray);
this.sendSocketNotification("DEPARTURES_FETCHED", departuresData);
} catch (error) {
Log.log(
`Error while fetching departures (for module instance ${fetcherId}): ${error}`
);
Log.log(`Error while fetching departures (for module instance ${fetcherId}): ${error}`);
// Add stationId to error for identification in the main instance
error.fetcherId = fetcherId;
error.message = error;
Expand Down

0 comments on commit 502efef

Please sign in to comment.