Set Prettier default to tabs instead of spaces, run on all JS

I haven't been running Prettier consistently on things in this project.
Now, it's quick-runnable, and I've got it on everything!

Also, I just think tabs are the right default for this kind of thing,
and I'm glad to get to switch over to it! (In `package.json`.)
This commit is contained in:
Emi Matchu 2024-09-09 16:10:45 -07:00
parent 71ffb7f1be
commit 0e314482f7
57 changed files with 11694 additions and 11709 deletions

1
.prettierignore Normal file
View file

@ -0,0 +1 @@
/app/assets/javascripts/lib

View file

@ -1,7 +1,5 @@
document.addEventListener("change", ({ target }) => {
if (target.matches('select[name="closet_list[visibility]"]')) {
target
.closest("form")
.setAttribute("data-list-visibility", target.value);
target.closest("form").setAttribute("data-list-visibility", target.value);
}
});

View file

@ -1,6 +1,6 @@
(function() {
$('span.choose-outfit select').change(function(e) {
(function () {
$("span.choose-outfit select").change(function (e) {
var select = $(this);
select.closest('li').find('input[type=text]').val(select.val());
select.closest("li").find("input[type=text]").val(select.val());
});
})();

View file

@ -91,9 +91,7 @@ class MeasuredContent extends HTMLElement {
// as `var(--natural-width)` in the context of its CSS styles.
const container = this.closest("measured-container");
if (container == null) {
throw new Error(
`<measured-content> must be in a <measured-container>`,
);
throw new Error(`<measured-content> must be in a <measured-container>`);
}
container.style.setProperty("--natural-width", this.offsetWidth + "px");
}

View file

@ -108,9 +108,7 @@ class OutfitLayer extends HTMLElement {
this.#setStatus("loading");
this.#sendMessageToIframe({ type: "requestStatus" });
window.addEventListener("message", (m) => this.#onMessage(m));
this.iframe.addEventListener("error", () =>
this.#setStatus("error"),
);
this.iframe.addEventListener("error", () => this.#setStatus("error"));
} else {
console.warn(`<outfit-layer> contained no image or iframe: `, this);
}
@ -137,8 +135,7 @@ class OutfitLayer extends HTMLElement {
}
} else {
throw new Error(
`<outfit-layer> got unexpected message: ` +
JSON.stringify(data),
`<outfit-layer> got unexpected message: ` + JSON.stringify(data),
);
}
}

View file

@ -24,8 +24,8 @@ import {
import SupportOnly from "./support/SupportOnly";
import useSupport from "./support/useSupport";
const LoadableItemSupportDrawer = loadable(() =>
import("./support/ItemSupportDrawer"),
const LoadableItemSupportDrawer = loadable(
() => import("./support/ItemSupportDrawer"),
);
/**

View file

@ -346,14 +346,11 @@ let cachedResponseForAllValidPetPoses = null;
* data from GraphQL serves on the first render, without a loading state.
*/
export function useAllValidPetPoses() {
const networkResponse = useFetch(
buildImpress2020Url("/api/validPetPoses"),
{
const networkResponse = useFetch(buildImpress2020Url("/api/validPetPoses"), {
responseType: "arrayBuffer",
// If we already have globally-cached valids, skip the request.
skip: cachedResponseForAllValidPetPoses != null,
},
);
});
// Use the globally-cached response if we have one, or await the network
// response if not.

View file

@ -11,7 +11,7 @@ export function getSupportSecret() {
function readOrigin() {
const node = document.querySelector("meta[name=impress-2020-origin]");
return node?.content || "https://impress-2020.openneo.net"
return node?.content || "https://impress-2020.openneo.net";
}
function readSupportSecret() {

View file

@ -13,9 +13,7 @@ export function useItemAppearances(id, options = {}) {
}
async function loadItemAppearancesData(id) {
const res = await fetch(
`/items/${encodeURIComponent(id)}/appearances.json`,
);
const res = await fetch(`/items/${encodeURIComponent(id)}/appearances.json`);
if (!res.ok) {
throw new Error(

View file

@ -44,9 +44,7 @@ async function loadSavedOutfit(id) {
const res = await fetch(`/outfits/${encodeURIComponent(id)}.json`);
if (!res.ok) {
throw new Error(
`loading outfit failed: ${res.status} ${res.statusText}`,
);
throw new Error(`loading outfit failed: ${res.status} ${res.statusText}`);
}
return res.json().then(normalizeOutfit);
@ -99,9 +97,7 @@ async function saveOutfit({
}
if (!res.ok) {
throw new Error(
`saving outfit failed: ${res.status} ${res.statusText}`,
);
throw new Error(`saving outfit failed: ${res.status} ${res.statusText}`);
}
return res.json().then(normalizeOutfit);
@ -116,9 +112,7 @@ async function deleteOutfit(id) {
});
if (!res.ok) {
throw new Error(
`deleting outfit failed: ${res.status} ${res.statusText}`,
);
throw new Error(`deleting outfit failed: ${res.status} ${res.statusText}`);
}
}
@ -132,9 +126,7 @@ function normalizeOutfit(outfit) {
appearanceId: String(outfit.pet_state_id),
altStyleId: outfit.alt_style_id ? String(outfit.alt_style_id) : null,
wornItemIds: (outfit.item_ids?.worn || []).map((id) => String(id)),
closetedItemIds: (outfit.item_ids?.closeted || []).map((id) =>
String(id),
),
closetedItemIds: (outfit.item_ids?.closeted || []).map((id) => String(id)),
creator: outfit.user ? { id: String(outfit.user.id) } : null,
createdAt: outfit.created_at,
updatedAt: outfit.updated_at,

View file

@ -46,8 +46,12 @@
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets --asset-names='[name]-[hash].digested' --loader:.js=jsx --loader:.png=file --loader:.svg=file --loader:.min.js=text",
"build:dev": "yarn build --public-path=/dev-assets",
"dev": "yarn build:dev --watch",
"format": "prettier -w app/javascript app/assets/javascripts",
"lint": "eslint app/javascript",
"prepare": "husky install"
},
"prettier": {
"useTabs": true
},
"packageManager": "yarn@4.4.1"
}