Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix eslint errors outside of /web and /e2e dirs

Jason Kent405a797b1b0a
diff --git a/rpm/buildRPM.js b/rpm/buildRPM.js
index 380cb2bd9..d94a37eb9 100755
--- a/rpm/buildRPM.js
+++ b/rpm/buildRPM.js
@@ -1,11 +1,11 @@
#!/usr/bin/env node
const shell = require('shelljs');
-const pkg = require('../package.json');
const moment = require('moment');
+const homedir = require('os').homedir();
+const pkg = require('../package.json');
const buildNumber = moment.utc().format('YYMMDDHHmmss');
-const homedir = require('os').homedir();
console.log('Preparing RPM build');
shell.rm('-rf', `${homedir}/rpmbuild`);
diff --git a/tasks/csv2colormap.js b/tasks/csv2colormap.js
index 45978831e..aa3c45736 100755
--- a/tasks/csv2colormap.js
+++ b/tasks/csv2colormap.js
@@ -22,12 +22,11 @@ const file = fs.readFileSync(csvFile, 'utf8');
const lines = file.split('\n');
const colors = [];
for (const line of lines) {
- if (line.trim().length === 0) {
- continue;
+ if (line.trim().length !== 0) {
+ const [r, g, b] = line.split(',');
+ const color = `${hex(r)}${hex(g)}${hex(b)}ff`;
+ colors.push(color);
}
- const [r, g, b] = line.split(',');
- const color = `${hex(r)}${hex(g)}${hex(b)}ff`;
- colors.push(color);
}
const colormap = {
@@ -41,7 +40,7 @@ fs.writeFileSync(jsonFile, JSON.stringify(colormap));
// decimal to hex for bytes, 10 => 0a
function hex(dec) {
- dec = Number.parseInt(dec);
+ dec = Number.parseInt(dec, 10);
let h = dec.toString(16);
if (h.length === 1) {
h = `0${h}`;
diff --git a/tasks/link-check/html-url-extract.js b/tasks/link-check/html-url-extract.js
index ced1326af..f4f4c087b 100644
--- a/tasks/link-check/html-url-extract.js
+++ b/tasks/link-check/html-url-extract.js
@@ -50,7 +50,7 @@ const getUrls = (htmlArray) => {
// get URLS from HTML files
// scraped URLs are saved in an array of objects with a key value pair of link text and href:
// 'Wildfire MB-CE042, Manitoba, Canada': 'https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_3518'
-const initExtractor = async () => {
+const initExtractor = async() => {
// any html file with a url will be scraped and added
const htmlFiles = await walk('./build/options');
const htmlUrls = await getUrls(htmlFiles);
diff --git a/tasks/link-check/natural-event-url-extract.js b/tasks/link-check/natural-event-url-extract.js
index 4c08c1329..0b6ecd47b 100644
--- a/tasks/link-check/natural-event-url-extract.js
+++ b/tasks/link-check/natural-event-url-extract.js
@@ -4,7 +4,7 @@ const fetch = require('node-fetch');
const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms));
// helper function to find target key in nested object
-const findProp = async (obj, keys, out) => {
+const findProp = async(obj, keys, out) => {
let i;
const proto = Object.prototype;
const ts = proto.toString;
@@ -29,15 +29,16 @@ const findProp = async (obj, keys, out) => {
return out;
};
-const scrapeLinks = async (htmlLinks) => {
+const scrapeLinks = async(htmlLinks) => {
// skip exact (rel and href) doubles of links
const trackDoubles = {};
const addedUrls = [];
for (let i = 0; i < htmlLinks.length; i++) {
const htmlLink = htmlLinks[i];
+ // eslint-disable-next-line no-await-in-loop
await fetch(htmlLink)
- .then(async (res) => {
+ .then(async(res) => {
const status = await res.json();
const urls = await findProp(status, ['url', 'link', 'source']);
for (let j = 0; j < urls.length; j++) {
@@ -61,7 +62,7 @@ const scrapeLinks = async (htmlLinks) => {
// get URLs from natural events EONET
// scraped URLs are saved in an array of objects with a key value pair of link text and href:
// 'Wildfire MB-CE042, Manitoba, Canada': 'https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_3518'
-const initExtractor = async () => {
+const initExtractor = async() => {
// target EONET sources from natural events
const links = ['https://eonet.sci.gsfc.nasa.gov/api/v2.1/sources',
'https://eonet.sci.gsfc.nasa.gov/api/v2.1/events',
diff --git a/tasks/link-check/url-check.js b/tasks/link-check/url-check.js
index f90d1c6aa..478fb676e 100644
--- a/tasks/link-check/url-check.js
+++ b/tasks/link-check/url-check.js
@@ -5,7 +5,7 @@ const fetch = require('node-fetch');
const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms));
// Checks status code of provided links and return object organized by errors / statuscodes
-const requestCheck = async (urls) => {
+const requestCheck = async(urls) => {
const parsedUrls = {
ERROR: [],
STATUSCODE: {},
@@ -16,20 +16,20 @@ const requestCheck = async (urls) => {
// Skip for mailto email links
if (url[0] !== 'h') {
- continue;
+ // eslint-disable-next-line no-await-in-loop
+ await fetch(url, { timeout: 10000 })
+ .then(async(res) => {
+ const statusCode = await res.status;
+ if (!parsedUrls.STATUSCODE[statusCode]) {
+ parsedUrls.STATUSCODE[statusCode] = [];
+ }
+ parsedUrls.STATUSCODE[statusCode].push({ [linkName]: url });
+ })
+ .then(sleeper(500))
+ .catch((err) => { // eslint-disable-line handle-callback-err
+ parsedUrls.ERROR.push({ [linkName]: url });
+ });
}
- await fetch(url, { timeout: 10000 })
- .then(async (res) => {
- const statusCode = await res.status;
- if (!parsedUrls.STATUSCODE[statusCode]) {
- parsedUrls.STATUSCODE[statusCode] = [];
- }
- parsedUrls.STATUSCODE[statusCode].push({ [linkName]: url });
- })
- .then(sleeper(500))
- .catch((err) => { // eslint-disable-line handle-callback-err
- parsedUrls.ERROR.push({ [linkName]: url });
- });
}
return parsedUrls;
};
@@ -43,7 +43,8 @@ URL STATUSCODE RESULTS:
${'-'.repeat(66)}
ERRORS: \x1b[31m${checkStatus.ERROR.length}\x1b[0m
STATUSCODE:`);
- for (const code in checkStatus.STATUSCODE) {
+ const codes = Object.keys(checkStatus.STATUSCODE);
+ codes.forEach((code) => {
let preColor = '\x1b[33m';
if (code === '200') {
preColor = '\x1b[32m';
@@ -51,7 +52,7 @@ ${'-'.repeat(66)}
preColor = '\x1b[31m';
}
console.log(` ${code}: ${preColor + checkStatus.STATUSCODE[code].length}\x1b[0m`);
- }
+ });
return checkStatus;
};
diff --git a/tasks/linkCheck.js b/tasks/linkCheck.js
index 30445463b..9eb628d5b 100755
--- a/tasks/linkCheck.js
+++ b/tasks/linkCheck.js
@@ -16,8 +16,8 @@ const makeLine = (msg) => console.log(`${'-'.repeat(66)}
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
// Make get requests with URLs with node-fetch to check status codes and organize by errors and codes
-const organizeURLStatus = async (scrapedUrls) => {
- const timeEstimate = (scrapedUrls.length * 1000 / 60000).toFixed(0);
+const organizeURLStatus = async(scrapedUrls) => {
+ const timeEstimate = ((scrapedUrls.length * 1000) / 60000).toFixed(0);
makeLine(`Checking url status codes will take approximately ${timeEstimate} minutes...`);
// Initiate status code check
const results = await getUrlStatusCodeCollection(scrapedUrls);
@@ -35,7 +35,7 @@ const organizeURLStatus = async (scrapedUrls) => {
});
};
-const main = async () => {
+const main = async() => {
makeLine('Starting by collecting urls to check...');
// get natural event urls
const naturalEventsUrls = await getNaturalEventsUrls();
diff --git a/test-env.js b/test-env.js
index 85b58e763..5d0defda6 100644
--- a/test-env.js
+++ b/test-env.js
@@ -1,3 +1,4 @@
+/* eslint-disable import/no-extraneous-dependencies */
import $ from 'jquery';
import fetchMock from 'fetch-mock';
import 'jest-canvas-mock';
diff --git a/webpack.config.js b/webpack.config.js
index 7087077d0..ad28ec68e 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -15,6 +15,7 @@ const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
// environment dev flag
const devMode = process.env.NODE_ENV !== 'production';
const isDevServer = process.argv[1].indexOf('webpack-dev-server') !== -1;
+const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const pluginSystem = [
new CleanWebpackPlugin(),
@@ -42,7 +43,6 @@ if (isDevServer) {
// conditionally required and add plugin bundle analzyer
if (process.env.ANALYZE_MODE === 'true') {
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
pluginSystem.push(new BundleAnalyzerPlugin());
}
if (process.env.DEBUG === 'true') {