Skip to content

Commit 207b4e0

Browse files
committed
some linting
1 parent aabc3ad commit 207b4e0

File tree

3 files changed

+64
-66
lines changed

3 files changed

+64
-66
lines changed

site/assets/js/details.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef */
1+
22
const openDetailsOnLoad = function openDetailsOnLoad() {
33
const target = window.location.hash;
44
let qTarget = null;

site/assets/js/map.js

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ const CONST_LODES_JOB_SEGMENTS_LABELS = {
5656
};
5757

5858
const
59-
URL_TILES = `https://data.lodesmap.com/tiles`,
60-
URL_LODES = `https://data.lodesmap.com/lodes`;
59+
URL_TILES = "https://data.lodesmap.com/tiles",
60+
URL_LODES = "https://data.lodesmap.com/lodes";
6161

6262
const FIPS_TO_TIGER_GEO_STATE_ABBR = {
6363
"02": "ak",
@@ -111,7 +111,7 @@ const FIPS_TO_TIGER_GEO_STATE_ABBR = {
111111
"55": "wi",
112112
"54": "wv",
113113
"56": "wy"
114-
}
114+
};
115115

116116
const
117117
MAP_CENTER = [-87.967, 43.064],
@@ -134,7 +134,6 @@ let validOrigin = true,
134134
validCountySubdivisionId= true;
135135

136136
const getTilesUrl = function getTilesUrl({
137-
year = LODES_YEAR,
138137
geography = LODES_GEOGRAPHY
139138
} = {}) {
140139
// We always use 2020 tiles as all years of LODES data for Version 8
@@ -149,13 +148,10 @@ const getLodesUrl = function getLodesUrl({
149148
origin = LODES_ORIGIN,
150149
state = null
151150
} = {}) {
152-
153-
if(state !== null) {
154-
state = FIPS_TO_TIGER_GEO_STATE_ABBR[state]
155-
}
151+
const stateParam = state === null ? state : FIPS_TO_TIGER_GEO_STATE_ABBR[state];
156152

157153
return `${URL_LODES}/year=${year}/geography=${geography}/origin=${origin}/` +
158-
`state=${state}/lodes-${year}-${geography}-${origin}-${state}.parquet`;
154+
`state=${stateParam}/lodes-${year}-${geography}-${origin}-${stateParam}.parquet`;
159155
};
160156

161157
const setUrlParam = function setUrlParam(name, value) {
@@ -231,7 +227,7 @@ class ColorScale {
231227
option.value = opt;
232228

233229
if(paramLabels[opt]) {
234-
option.textContent = paramLabels[opt]
230+
option.textContent = paramLabels[opt];
235231
} else {
236232
option.textContent = opt.split("_").
237233
map(word => word.charAt(0).toUpperCase() +
@@ -318,23 +314,23 @@ class ColorScale {
318314

319315
getLabelsForGeography(geography) {
320316
switch (geography) {
321-
case "county":
322-
return ["1", "2-100", "101-1,000", "1,001-9,999", "10,000+"];
323-
case "county_subdivision":
324-
return ["1", "2-50", "51-150", "150-499", "500+"];
325-
default:
326-
return ["1", "2-10", "11-20", "21-29", "30+"];
317+
case "county":
318+
return ["1", "2-100", "101-1,000", "1,001-9,999", "10,000+"];
319+
case "county_subdivision":
320+
return ["1", "2-50", "51-150", "150-499", "500+"];
321+
default:
322+
return ["1", "2-10", "11-20", "21-29", "30+"];
327323
}
328324
}
329325

330326
getThresholdsForGeography(geography) {
331327
switch (geography) {
332-
case "county":
333-
return [1, 2, 101, 1001, 10000];
334-
case "county_subdivision":
335-
return [1, 2, 51, 151, 500];
336-
default:
337-
return [1, 2, 11, 21, 30];
328+
case "county":
329+
return [1, 2, 101, 1001, 10000];
330+
case "county_subdivision":
331+
return [1, 2, 51, 151, 500];
332+
default:
333+
return [1, 2, 11, 21, 30];
338334
}
339335
}
340336

@@ -506,8 +502,8 @@ class Map {
506502
},
507503
{ hover: true }
508504
);
509-
const displayId = feature.properties.name ? feature.properties.name : feature.properties.id
510-
this.updateGeoIdDisplay(displayId, this.processor.previousResults[geographyParam][feature.properties.id]?.count)
505+
const displayId = feature.properties.name ? feature.properties.name : feature.properties.id;
506+
this.updateGeoIdDisplay(displayId, this.processor.previousResults[geographyParam][feature.properties.id]?.count);
511507
} else {
512508
this.map.getCanvas().style.cursor = "";
513509
this.geoIdDisplay.style.display = "none";
@@ -549,17 +545,18 @@ class Map {
549545

550546
const [couSubFeature] = this.map.queryRenderedFeatures(
551547
feat.point,
552-
{ layers: [`geo_fill_county_subdivision`] }
548+
{ layers: ["geo_fill_county_subdivision"] }
553549
);
554550

551+
555552
if(couSubFeature) {
556-
countySubdivisionIdParam = couSubFeature?.properties.id
553+
countySubdivisionIdParam = couSubFeature?.properties.id;
557554
validCountySubdivisionId = validIdInput(countySubdivisionIdParam);
558555
setUrlParam("countySubdivisionId", countySubdivisionIdParam);
559556
}
560557

561558
if(geometryFeature) {
562-
this.updateSelectedFeature(geometryFeature.properties.id)
559+
this.updateSelectedFeature(geometryFeature.properties.id);
563560
}
564561

565562
if (geometryFeature && feature) {
@@ -573,8 +570,8 @@ class Map {
573570
idParam.substring(0, 2), geometryFeature.properties.id
574571
);
575572

576-
const displayId = geometryFeature.properties.name ? geometryFeature.properties.name : geometryFeature.properties.id
577-
this.updateGeoIdDisplay(displayId, this.processor.previousResults[geographyParam][geometryFeature.properties.id]?.count)
573+
const displayId = geometryFeature.properties.name ? geometryFeature.properties.name : geometryFeature.properties.id;
574+
this.updateGeoIdDisplay(displayId, this.processor.previousResults[geographyParam][geometryFeature.properties.id]?.count);
578575
}
579576
}
580577
});
@@ -653,30 +650,30 @@ class Map {
653650
}
654651
// getThresholdsForGeography(geography)
655652
for (const geography of LODES_GEOGRAPHIES) {
656-
const thresholds = this.colorScale.getThresholdsForGeography(geography)
653+
const thresholds = this.colorScale.getThresholdsForGeography(geography);
657654
const colors = [
658655
"rgb(253, 231, 37)",
659656
"rgb(122, 209, 81)",
660657
"rgb(34, 168, 132)",
661658
"rgb(42, 120, 142)",
662659
"rgb(65, 68, 135)"
663-
]
660+
];
664661

665-
const thresholds_colors = thresholds.map((k, i) => [k, colors[i]]).flat();
662+
const thresholdsColors = thresholds.map((k, i) => [k, colors[i]]).flat();
666663

667664
this.map.addLayer({
668665
filter: ["==", ["geometry-type"], "Polygon"],
669666
id: `geo_fill_${geography}`,
670667
layout: { visibility: "none" },
671668
paint: {
672669
"fill-color": [
673-
'interpolate',
674-
['linear'],
675-
['feature-state', 'geoValue'],
676-
...thresholds_colors
670+
"interpolate",
671+
["linear"],
672+
["feature-state", "geoValue"],
673+
...thresholdsColors
677674
],
678675
"fill-opacity": [
679-
'case',
676+
"case",
680677
["==", ["feature-state", "geoValue"], null], 0.0,
681678
0.4,
682679
],
@@ -831,8 +828,8 @@ class ParquetProcessor {
831828
processParquetRowGroup(map, id, geography, data, results, origin) {
832829
data.forEach(row => {
833830
// w_tract, h_tract
834-
const source = origin == "w_geo" ? 0 : 1
835-
const destination = origin == "w_geo" ? 1 : 0
831+
const source = origin === "w_geo" ? 0 : 1;
832+
const destination = origin === "w_geo" ? 1 : 0;
836833

837834
if (row[source] === id) {
838835
map.map.setFeatureState(
@@ -849,30 +846,30 @@ class ParquetProcessor {
849846
}
850847

851848
saveResultState(map, results, geography) {
852-
const filteredPreviousResults = this.previousResults[geography]
849+
const filteredPreviousResults = this.previousResults[geography];
853850
Object.keys(results).forEach(key => delete(filteredPreviousResults[key]));
854851
map.wipeMapPreviousState(Object.keys(filteredPreviousResults), geography);
855852
this.previousResults[geography] = results;
856853
}
857854

858-
async runQuery(map, origin, job_segment, year, geography, state, id) {
855+
async runQuery(map, origin, jobSegment, year, geography, state, id) {
859856
map.isProcessing = true;
860857
map.spinner.show();
861858
const queryUrl = getLodesUrl({ year, geography, origin, state }),
862859
truncId = map.truncateId(geography, id);
863860

864861
// Get the count of files given the geography, origin, and state
865-
const results = await this.updateMapOnQuery(map, queryUrl, truncId, geography, job_segment, origin);
862+
const results = await this.updateMapOnQuery(map, queryUrl, truncId, geography, jobSegment, origin);
866863
this.saveResultState(map, results, geography);
867-
map.updateSelectedFeature(truncId)
864+
map.updateSelectedFeature(truncId);
868865
map.isProcessing = false;
869866
map.spinner.hide();
870867
}
871868

872-
async readAndUpdateMap(map, id, geography, file, metadata, rowGroup, results, job_segment, origin) {
869+
async readAndUpdateMap(map, id, geography, file, metadata, rowGroup, results, jobSegment, origin) {
873870
await parquetRead(
874871
{
875-
columns: ["w_geo", "h_geo", job_segment],
872+
columns: ["w_geo", "h_geo", jobSegment],
876873
compressors,
877874
file,
878875
metadata,
@@ -883,8 +880,8 @@ class ParquetProcessor {
883880
);
884881
}
885882

886-
async updateMapOnQuery(map, url, id, geography, job_segment, origin) {
887-
const urls = [url]
883+
async updateMapOnQuery(map, queryUrl, id, geography, jobSegment, origin) {
884+
const urls = [queryUrl];
888885
const results = {};
889886
let totalGroups = 0;
890887

@@ -936,7 +933,7 @@ class ParquetProcessor {
936933
let processedGroups = 0,
937934
progress = 10;
938935
await Promise.all(rowGroupItems.map(async (rg) => {
939-
await this.readAndUpdateMap(map, rg.id, geography, rg.file, rg.metadata, rg.rowGroup, results, job_segment, origin);
936+
await this.readAndUpdateMap(map, rg.id, geography, rg.file, rg.metadata, rg.rowGroup, results, jobSegment, origin);
940937
processedGroups += 1;
941938
progress = Math.ceil((processedGroups / totalGroups) * 100);
942939
map.spinner.updateProgress(progress);
@@ -969,17 +966,17 @@ class ParquetProcessor {
969966
validId = validIdInput(idParam);
970967
validCountySubdivisionId = validIdInput(countySubdivisionIdParam);
971968

972-
const valid = geographyParam == "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId
969+
const valid = geographyParam === "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId;
973970

974971
if (valid) {
975-
const id = geographyParam == "county_subdivision" ? countySubdivisionIdParam : idParam
972+
const id = geographyParam === "county_subdivision" ? countySubdivisionIdParam : idParam;
976973
await processor.runQuery(
977974
map, originParam, jobSegmentParam, yearParam, geographyParam,
978975
idParam.substring(0, 2), id
979976
);
980977

981978
if(map.hoveredPolygonId[geographyParam]) {
982-
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count)
979+
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count);
983980
}
984981
}
985982
}
@@ -999,17 +996,17 @@ class ParquetProcessor {
999996
validId = validIdInput(idParam);
1000997
validCountySubdivisionId = validIdInput(countySubdivisionIdParam);
1001998

1002-
const valid = geographyParam == "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId
999+
const valid = geographyParam === "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId;
10031000

10041001
if (valid) {
1005-
const id = geographyParam == "county_subdivision" ? countySubdivisionIdParam : idParam;
1002+
const id = geographyParam === "county_subdivision" ? countySubdivisionIdParam : idParam;
10061003
await processor.runQuery(
10071004
map, originParam, jobSegmentParam, yearParam, geographyParam,
10081005
idParam.substring(0, 2), id
10091006
);
10101007

10111008
if(map.hoveredPolygonId[geographyParam]) {
1012-
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count)
1009+
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count);
10131010
}
10141011
}
10151012
}
@@ -1031,17 +1028,17 @@ class ParquetProcessor {
10311028
validId = validIdInput(idParam);
10321029
validCountySubdivisionId = validIdInput(countySubdivisionIdParam);
10331030

1034-
const valid = geographyParam == "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId
1031+
const valid = geographyParam === "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId;
10351032

10361033
if (valid) {
1037-
const id = geographyParam == "county_subdivision" ? countySubdivisionIdParam : idParam;
1034+
const id = geographyParam === "county_subdivision" ? countySubdivisionIdParam : idParam;
10381035
await processor.runQuery(
10391036
map, originParam, jobSegmentParam, yearParam, geographyParam,
10401037
idParam.substring(0, 2), id
10411038
);
10421039

10431040
if(map.hoveredPolygonId[geographyParam]) {
1044-
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count)
1041+
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count);
10451042
}
10461043
}
10471044
}
@@ -1061,17 +1058,17 @@ class ParquetProcessor {
10611058
validId = validIdInput(idParam);
10621059
validCountySubdivisionId = validIdInput(countySubdivisionIdParam);
10631060

1064-
const valid = geographyParam == "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId
1061+
const valid = geographyParam === "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId;
10651062

10661063
if (valid) {
1067-
const id = geographyParam == "county_subdivision" ? countySubdivisionIdParam : idParam;
1064+
const id = geographyParam === "county_subdivision" ? countySubdivisionIdParam : idParam;
10681065
await processor.runQuery(
10691066
map, originParam, jobSegmentParam, yearParam, geographyParam,
10701067
idParam.substring(0, 2), id
10711068
);
10721069

10731070
if(map.hoveredPolygonId[geographyParam]) {
1074-
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count)
1071+
map.updateGeoIdDisplay(map.hoveredPolygonId[geographyParam], map.processor.previousResults[geographyParam][map.hoveredPolygonId[geographyParam]]?.count);
10751072
}
10761073
}
10771074
}
@@ -1108,17 +1105,17 @@ class ParquetProcessor {
11081105

11091106
document.getElementById("year").value = yearParam;
11101107

1111-
const valid = geographyParam == "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId
1108+
const valid = geographyParam === "county_subdivision" ? countySubdivisionIdParam && validCountySubdivisionId : idParam && validId;
11121109

11131110
if (valid) {
1114-
const id = geographyParam == "county_subdivision" ? countySubdivisionIdParam : idParam
1111+
const id = geographyParam === "county_subdivision" ? countySubdivisionIdParam : idParam;
11151112
await processor.runQuery(
11161113
map, originParam, jobSegmentParam, yearParam, geographyParam,
11171114
idParam.substring(0, 2), id
11181115
);
11191116

1120-
const truncId = map.truncateId(geographyParam, id)
1121-
map.updateGeoIdDisplay(idParam, map.processor.previousResults[geographyParam][truncId]?.count)
1117+
const truncId = map.truncateId(geographyParam, id);
1118+
map.updateGeoIdDisplay(idParam, map.processor.previousResults[geographyParam][truncId]?.count);
11221119
}
11231120
}
11241121
});

site/eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default [
2323
"one-var": "off",
2424
"quotes": ["error", "double"],
2525
"semi": ["error", "always"],
26-
"sort-vars": "off"
26+
"sort-vars": "off",
27+
"sort-keys": "off"
2728
}
2829
}
2930
];

0 commit comments

Comments
 (0)