use spaces for indentation

This commit is contained in:
imperosol 2024-10-08 13:54:44 +02:00
parent 24925f7726
commit 20bea62542
24 changed files with 5167 additions and 5207 deletions

View File

@ -7,25 +7,20 @@
},
"files": {
"ignoreUnknown": false,
"ignore": ["core/static/vendored", "*.min.js", "staticfiles/generated"]
"ignore": ["core/static/vendored", "*.min.*", "staticfiles/generated"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
"indentStyle": "space",
"lineWidth": 88
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"ignore": ["core/static/vendored", "*.min.js", "staticfiles/generated"],
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}

View File

@ -43,10 +43,7 @@ $(document).ready(() => {
function start_progress_bar(display_time) {
$("#slideshow #progress_bar").removeClass("init");
$("#slideshow #progress_bar").addClass("progress");
$("#slideshow #progress_bar").css(
"transition",
`width ${display_time}s linear`,
);
$("#slideshow #progress_bar").css("transition", `width ${display_time}s linear`);
}
function next() {

View File

@ -3,8 +3,8 @@
"pk": 1,
"fields": {
"permissions": [
1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12, 19, 20, 21, 22, 25, 23, 24, 16,
17, 18, 13, 14, 15
1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12, 19, 20, 21, 22, 25, 23, 24, 16, 17, 18,
13, 14, 15
]
},
"model": "core.group"

View File

@ -142,9 +142,7 @@ async function fetch_paginated(url) {
for (let i = 2; i <= nb_pages; i++) {
paginated_url.searchParams.set("page", i.toString());
promises.push(
fetch(paginated_url).then((res) =>
res.json().then((json) => json.results),
),
fetch(paginated_url).then((res) => res.json().then((json) => json.results)),
);
}
results.push(...(await Promise.all(promises)).flat());

View File

@ -243,8 +243,7 @@ function item_formatter(user) {
*/
function select_item_builder(picture_getter) {
return (item) => {
const picture =
typeof picture_getter === "function" ? picture_getter(item) : null;
const picture = typeof picture_getter === "function" ? picture_getter(item) : null;
const img_html = picture
? `<img
src="${picture_getter(item)}"

View File

@ -83,9 +83,7 @@ function create_graph(container, data, active_user_id) {
},
},
});
const active_user = cy
.getElementById(active_user_id)
.style("shape", "rectangle");
const active_user = cy.getElementById(active_user_id).style("shape", "rectangle");
/* Reset graph */
const reset_graph = () => {
cy.elements((element) => {
@ -124,9 +122,7 @@ function create_graph(container, data, active_user_id) {
/* Add context menu */
if (cy.cxtmenu === undefined) {
console.error(
"ctxmenu isn't loaded, context menu won't be available on graphs",
);
console.error("ctxmenu isn't loaded, context menu won't be available on graphs");
return cy;
}
cy.cxtmenu({
@ -261,11 +257,7 @@ document.addEventListener("alpine:init", () => {
async generate_graph() {
this.loading = true;
this.graph = create_graph(
$(this.$refs.graph),
this.graph_data,
active_user,
);
this.graph = create_graph($(this.$refs.graph), this.graph_data, active_user);
this.loading = false;
},
}));

View File

@ -1,8 +1,4 @@
function alpine_webcam_builder(
default_picture,
delete_url,
can_delete_picture,
) {
function alpine_webcam_builder(default_picture, delete_url, can_delete_picture) {
return () => ({
can_edit_picture: false,

View File

@ -155,9 +155,7 @@ function easymdeFactory(textarea, markdownApiURL) {
],
});
const submits = textarea
.closest("form")
.querySelectorAll('input[type="submit"]');
const submits = textarea.closest("form").querySelectorAll('input[type="submit"]');
const parentDiv = textarea.parentElement;
let submitPressed = false;

View File

@ -21,9 +21,7 @@ function getCookie(name) {
.map((c) => c.trim())
.find((c) => c.startsWith(`${name}=`));
return found === undefined
? undefined
: decodeURIComponent(found.split("=")[1]);
return found === undefined ? undefined : decodeURIComponent(found.split("=")[1]);
}
/**
@ -54,10 +52,7 @@ document.addEventListener("alpine:init", () => {
* @returns {number} The total price of the basket
*/
get_total() {
return this.items.reduce(
(acc, item) => acc + item.quantity * item.unit_price,
0,
);
return this.items.reduce((acc, item) => acc + item.quantity * item.unit_price, 0);
},
/**

View File

@ -44,8 +44,8 @@ document.addEventListener("alpine:init", () => {
: BillingInfoReqState.FAILURE;
if (res.status === 422) {
const errors = (await res.json()).detail.flatMap((err) => err.loc);
for (const elem of Array.from(form.querySelectorAll("input")).filter(
(elem) => errors.includes(elem.name),
for (const elem of Array.from(form.querySelectorAll("input")).filter((elem) =>
errors.includes(elem.name),
)) {
elem.setCustomValidity(gettext("Incorrect value"));
elem.reportValidity();

View File

@ -6,7 +6,8 @@
"scripts": {
"compile": "webpack --mode production",
"compile-dev": "webpack --mode development",
"serve": "webpack --mode development --watch"
"serve": "webpack --mode development --watch",
"check": "biome check --write"
},
"keywords": [],
"author": "",

View File

@ -127,17 +127,13 @@ document.addEventListener("alpine:init", () => {
element: $(this.$refs.search),
data_source: remote_data_source("/api/user/search", {
excluded: () => [
...(this.current_picture.identifications || []).map(
(i) => i.user.id,
),
...(this.current_picture.identifications || []).map((i) => i.user.id),
],
result_converter: (obj) => Object({ ...obj, text: obj.display_name }),
}),
picture_getter: (user) => user.profile_pict,
});
this.current_picture = this.pictures.find(
(i) => i.id === first_picture_id,
);
this.current_picture = this.pictures.find((i) => i.id === first_picture_id);
this.$watch("current_picture", (current, previous) => {
if (current === previous) {
/* Avoid recursive updates */
@ -193,12 +189,9 @@ document.addEventListener("alpine:init", () => {
},
async moderate_picture() {
const res = await fetch(
`/api/sas/picture/${this.current_picture.id}/moderate`,
{
const res = await fetch(`/api/sas/picture/${this.current_picture.id}/moderate`, {
method: "PATCH",
},
);
});
if (!res.ok) {
this.moderation_error = `${gettext("Couldn't moderate picture")} : ${res.statusText}`;
return;
@ -231,9 +224,7 @@ document.addEventListener("alpine:init", () => {
const url = `/api/sas/picture/${this.current_picture.id}/identified`;
await fetch(url, {
method: "PUT",
body: JSON.stringify(
this.selector.val().map((i) => Number.parseInt(i)),
),
body: JSON.stringify(this.selector.val().map((i) => Number.parseInt(i))),
});
// refresh the identified users list
await this.current_picture.load_identifications({ force_reload: true });

View File

@ -5,9 +5,7 @@ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
entry: glob
.sync("./!(static)/static/webpack/**?(-)index.js")
.reduce((obj, el) => {
entry: glob.sync("./!(static)/static/webpack/**?(-)index.js").reduce((obj, el) => {
obj[path.parse(el).name] = `./${el}`;
return obj;
}, {}),