Skip to content

Commit

Permalink
Upgrade to Prettier 3.3 (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano authored Jul 27, 2024
1 parent df7c316 commit 5c28488
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 91 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Parking Lot Map - Parking Reform Network</title>
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"http-server": "^14.1.1",
"parcel": "^2.10.3",
"playwright": "^1.34.3",
"prettier": "^2.8.7",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
Expand Down
10 changes: 5 additions & 5 deletions scripts/add-city.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CityId } from "../src/js/types.ts";

const addScoreCard = async (
cityId: CityId,
cityName: string
cityName: string,
): Promise<results.Result<void, string>> => {
const newEntry = {
name: cityName,
Expand All @@ -27,7 +27,7 @@ const addScoreCard = async (
} catch (err: unknown) {
const { message } = err as Error;
return results.Err(
`Issue reading the score card file path ${originalFilePath}: ${message}`
`Issue reading the score card file path ${originalFilePath}: ${message}`,
);
}

Expand All @@ -54,7 +54,7 @@ const main = async () => {
cityId,
true,
"data/city-boundaries.geojson",
"city-update.geojson"
"city-update.geojson",
)
).unwrap();

Expand All @@ -63,7 +63,7 @@ const main = async () => {
cityId,
true,
"parking-lots-update.geojson",
`data/parking-lots/${cityId}.geojson`
`data/parking-lots/${cityId}.geojson`,
)
).unwrap();

Expand All @@ -73,7 +73,7 @@ const main = async () => {
console.log(
`Almost done! Now, fill in the score card values in data/score-cards.json. Then,
run 'npm run fmt'. Then, 'npm start' and see if the site is what you expect.
`
`,
);
};

Expand Down
24 changes: 12 additions & 12 deletions scripts/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { CityId } from "../src/js/types";

const determineArgs = (
scriptCommand: string,
processArgv: string[]
processArgv: string[],
): results.Result<{ cityName: string; cityId: CityId }, string> => {
if (processArgv.length !== 1) {
return new results.Err(
`Must provide exactly one argument (the city/state name). For example,
npm run ${scriptCommand} -- 'Columbus, OH'
`
`,
);
}
const cityName = processArgv[0];
Expand All @@ -30,7 +30,7 @@ const updateCoordinates = async (
cityId: CityId,
addCity: boolean,
originalFilePath: string,
updateFilePath: string
updateFilePath: string,
): Promise<results.Result<string, string>> => {
let newData: FeatureCollection<Polygon, GeoJsonProperties>;
try {
Expand All @@ -39,13 +39,13 @@ const updateCoordinates = async (
} catch (err: unknown) {
const { message } = err as Error;
return results.Err(
`Issue reading the update file path ${updateFilePath}: ${message}`
`Issue reading the update file path ${updateFilePath}: ${message}`,
);
}

if (!Array.isArray(newData.features) || newData.features.length !== 1) {
return results.Err(
"The script expects exactly one entry in `features` because you can only update one city at a time."
"The script expects exactly one entry in `features` because you can only update one city at a time.",
);
}

Expand All @@ -60,7 +60,7 @@ const updateCoordinates = async (
} catch (err: unknown) {
const { message } = err as Error;
return results.Err(
`Issue reading the original data file path ${originalFilePath}: ${message}`
`Issue reading the original data file path ${originalFilePath}: ${message}`,
);
}

Expand All @@ -73,11 +73,11 @@ const updateCoordinates = async (
originalData.features.push(newEntry);
} else {
const cityOriginalData = originalData.features.find(
(feature) => feature?.properties?.id === cityId
(feature) => feature?.properties?.id === cityId,
);
if (!cityOriginalData) {
return results.Err(
`City not found in ${originalFilePath}. To add a new city, run again with the '--add' flag, e.g. npm run ${scriptCommand} -- 'My City, AZ' --add`
`City not found in ${originalFilePath}. To add a new city, run again with the '--add' flag, e.g. npm run ${scriptCommand} -- 'My City, AZ' --add`,
);
}
cityOriginalData.geometry.coordinates = newCoordinates;
Expand All @@ -102,7 +102,7 @@ const updateParkingLots = async (
cityId: CityId,
addCity: boolean,
originalFilePath: string,
updateFilePath: string
updateFilePath: string,
): Promise<results.Result<string, string>> => {
let newData;
try {
Expand All @@ -111,13 +111,13 @@ const updateParkingLots = async (
} catch (err: unknown) {
const { message } = err as Error;
return results.Err(
`Issue reading the update file path parking-lots-update.geojson: ${message}`
`Issue reading the update file path parking-lots-update.geojson: ${message}`,
);
}

if (!Array.isArray(newData.features) || newData.features.length !== 1) {
return results.Err(
"The script expects exactly one entry in `features` because you can only update one city at a time."
"The script expects exactly one entry in `features` because you can only update one city at a time.",
);
}

Expand All @@ -132,7 +132,7 @@ const updateParkingLots = async (
} catch (err: unknown) {
const { message } = err as Error;
return results.Err(
`Issue reading the original data file path ${updateFilePath}: ${message}`
`Issue reading the original data file path ${updateFilePath}: ${message}`,
);
}
originalData.geometry.coordinates = newCoordinates;
Expand Down
6 changes: 3 additions & 3 deletions scripts/update-city-boundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { determineArgs, updateCoordinates } from "./base.js";
const main = async (): Promise<void> => {
const { cityId } = determineArgs(
"update-city-boundaries",
process.argv.slice(2)
process.argv.slice(2),
)
.mapErr((err) => new Error(`Argument error: ${err}`))
.unwrap();
Expand All @@ -13,15 +13,15 @@ const main = async (): Promise<void> => {
cityId,
false,
"data/city-boundaries.geojson",
"city-update.geojson"
"city-update.geojson",
)
).unwrap();

/* eslint-disable-next-line no-console */
console.log(
`${value} Now, run 'npm run fmt'. Then, 'npm start' and
see if the site is what you expect.
`
`,
);
};

Expand Down
4 changes: 2 additions & 2 deletions scripts/update-lots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const main = async (): Promise<void> => {
cityId,
false,
"parking-lots-update.geojson",
`data/parking-lots/${cityId}.geojson`
`data/parking-lots/${cityId}.geojson`,
)
).unwrap();

/* eslint-disable-next-line no-console */
console.log(
`${value} Now, run 'npm run fmt'. Then, 'npm start' and
see if the site is what you expect.
`
`,
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/CitySelectionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type CitySelectionObservable = Observable<CitySelectionState>;

function initCitySelectionState(
initialCityId: CityId | null,
fallBackCityId: CityId
fallBackCityId: CityId,
): CitySelectionObservable {
const startingCity =
initialCityId && Object.keys(scoreCardsData).includes(initialCityId)
Expand Down
2 changes: 1 addition & 1 deletion src/js/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function setUpAbout(): void {
const closeIcon = document.querySelector(".about-popup-close-icon-container");

headerIcon?.addEventListener("click", () =>
isVisible.setValue(!isVisible.getValue())
isVisible.setValue(!isVisible.getValue()),
);
closeIcon?.addEventListener("click", () => isVisible.setValue(false));

Expand Down
2 changes: 1 addition & 1 deletion src/js/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createDropdown(): Choices {
} else {
officialCities.push(entry);
}
}
},
);

dropdown.setChoices([
Expand Down
2 changes: 1 addition & 1 deletion src/js/fontAwesome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function setUpIcons(): void {
faLink,
faUpRightFromSquare,
faCheck,
faTriangleExclamation
faTriangleExclamation,
);
dom.watch();
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function isIFrame(): boolean {
function maybeDisableFullScreenIcon(): void {
if (isIFrame()) return;
const iconContainer = document.querySelector<HTMLAnchorElement>(
".header-full-screen-icon-container"
".header-full-screen-icon-container",
);
if (!iconContainer) return;
iconContainer.style.display = "none";
Expand Down
6 changes: 3 additions & 3 deletions src/js/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const BASE_LAYERS = {
subdomains: "abcd",
minZoom: 0,
maxZoom: MAX_ZOOM,
}
},
),
"Google Maps": new TileLayer(
"https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
{
attribution: `&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; Google Maps`,
maxZoom: MAX_ZOOM,
}
},
),
};

Expand Down Expand Up @@ -49,7 +49,7 @@ export function createMap(): Map {
layers: [BASE_LAYERS["High contrast"]],
});
map.attributionControl.setPrefix(
'<a href="https://parkingreform.org/support/">Parking Reform Network</a>'
'<a href="https://parkingreform.org/support/">Parking Reform Network</a>',
);

new Control.Layers(BASE_LAYERS).addTo(map);
Expand Down
10 changes: 5 additions & 5 deletions src/js/scorecard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ function generateScorecard(entry: ScoreCardDetails): string {
const listEntries = [];
if (entry.parkingScore) {
listEntries.push(
`${entry.parkingScore}/100 parking score (lower is better)`
`${entry.parkingScore}/100 parking score (lower is better)`,
);
}
listEntries.push(`City type: ${entry.cityType}`);
listEntries.push(`${entry.population} residents - city proper`);
listEntries.push(
`${entry.urbanizedAreaPopulation} residents - urbanized area`
`${entry.urbanizedAreaPopulation} residents - urbanized area`,
);

let reformsLine = `Parking reforms ${entry.reforms}`;
Expand All @@ -35,7 +35,7 @@ function generateScorecard(entry: ScoreCardDetails): string {

if ("contribution" in entry) {
listEntries.push(
`<a href="mailto:${entry.contribution}">Email data maintainer</a>`
`<a href="mailto:${entry.contribution}">Email data maintainer</a>`,
);
}

Expand Down Expand Up @@ -70,7 +70,7 @@ function generateScorecard(entry: ScoreCardDetails): string {
function updateScorecardAccordionUI(expanded: boolean): void {
const toggle = document.querySelector(".scorecard-accordion-toggle");
const content = document.querySelector<HTMLElement>(
"#scorecard-accordion-content"
"#scorecard-accordion-content",
);
const upIcon = toggle?.querySelector<SVGElement>(".fa-chevron-up");
const downIcon = toggle?.querySelector<SVGElement>(".fa-chevron-down");
Expand Down Expand Up @@ -104,7 +104,7 @@ function setUpScorecardAccordion(): void {

export default function addScorecardSubscriber(
observable: CitySelectionObservable,
cities: ScoreCards
cities: ScoreCards,
): void {
observable.subscribe(({ cityId }) => {
const scorecardContainer = document.querySelector(".scorecard-container");
Expand Down
8 changes: 4 additions & 4 deletions src/js/setUpSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function snapToCity(map: Map, layer: ImageOverlay): void {
function addSnapToCitySubscriber(
observable: CitySelectionObservable,
map: Map,
cities: ScoreCards
cities: ScoreCards,
): void {
observable.subscribe((state) => {
if (!state.shouldSnapMap) return;
Expand All @@ -53,7 +53,7 @@ function setCityByMapPosition(
observable: CitySelectionObservable,
map: Map,
cities: ScoreCards,
parkingLotLoader: ParkingLotLoader
parkingLotLoader: ParkingLotLoader,
): void {
map.on("moveend", () => {
let centralCityDistance: number | null = null;
Expand Down Expand Up @@ -106,7 +106,7 @@ function createCitiesLayer(map: Map): [GeoJSON, ScoreCards] {
function setCityOnBoundaryClick(
observable: CitySelectionObservable,
map: Map,
cityBoundaries: GeoJSON
cityBoundaries: GeoJSON,
): void {
cityBoundaries.addEventListener("click", (e) => {
const currentZoom = map.getZoom();
Expand All @@ -130,7 +130,7 @@ async function setUpSite(): Promise<void> {
const initialCityId = extractCityIdFromUrl(window.location.href);
const citySelectionObservable = initCitySelectionState(
initialCityId,
"atlanta-ga"
"atlanta-ga",
);

setUpDropdown(citySelectionObservable);
Expand Down
Loading

0 comments on commit 5c28488

Please sign in to comment.