additional eslint rules

This commit is contained in:
Matt Walsh
2023-01-06 14:39:39 -06:00
parent b890b4e53d
commit 3743c45de6
26 changed files with 1079 additions and 184 deletions

View File

@@ -21,7 +21,7 @@ const fetchAsync = async (_url, responseType, _params = {}) => {
if (params.cors === true) corsUrl = rewriteUrl(_url);
const url = new URL(corsUrl, `${window.location.origin}/`);
// match the security protocol when not on localhost
url.protocol = window.location.hostname !== 'localhost' ? window.location.protocol : url.protocol;
url.protocol = window.location.hostname === 'localhost' ? url.protocol : window.location.protocol;
// add parameters if necessary
if (params.data) {
Object.keys(params.data).forEach((key) => {
@@ -73,7 +73,7 @@ const doFetch = (url, params) => new Promise((resolve, reject) => {
// out of retries
return resolve(response);
})
.catch((e) => reject(e));
.catch((error) => reject(error));
});
const delay = (time, func, ...args) => new Promise((resolve) => {
@@ -87,8 +87,8 @@ const retryDelay = (retryNumber) => {
case 1: return 1000;
case 2: return 2000;
case 3: return 5000;
case 4: return 10000;
default: return 30000;
case 4: return 10_000;
default: return 30_000;
}
};

View File

@@ -2,11 +2,11 @@ const locationCleanup = (input) => {
// regexes to run
const regexes = [
// "Chicago / West Chicago", removes before slash
/^[A-Za-z ]+ \/ /,
/^[ A-Za-z]+ \/ /,
// "Chicago/Waukegan" removes before slash
/^[A-Za-z ]+\//,
/^[ A-Za-z]+\//,
// "Chicago, Chicago O'hare" removes before comma
/^[A-Za-z ]+, /,
/^[ A-Za-z]+, /,
];
// run all regexes

View File

@@ -2,11 +2,11 @@
const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals;
const kphToMph = (Kph) => Math.round(Kph / 1.60934);
const kphToMph = (Kph) => Math.round(Kph / 1.609_34);
const celsiusToFahrenheit = (Celsius) => Math.round((Celsius * 9) / 5 + 32);
const kilometersToMiles = (Kilometers) => Math.round(Kilometers / 1.60934);
const kilometersToMiles = (Kilometers) => Math.round(Kilometers / 1.609_34);
const metersToFeet = (Meters) => Math.round(Meters / 0.3048);
const pascalToInHg = (Pascal) => round2(Pascal * 0.0002953, 2);
const pascalToInHg = (Pascal) => round2(Pascal * 0.000_295_3, 2);
export {
kphToMph,

View File

@@ -3,9 +3,9 @@ import { json } from './fetch.mjs';
const getPoint = async (lat, lon) => {
try {
return await json(`https://api.weather.gov/points/${lat},${lon}`);
} catch (e) {
} catch (error) {
console.log(`Unable to get point ${lat}, ${lon}`);
console.error(e);
console.error(error);
return false;
}
};