[build] upgrade eslint to 9.37.0 (#88)

Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88
Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org>
Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
Zoë Bijl
2025-10-12 13:42:02 +02:00
committed by tobi
parent 75d7a62693
commit 1ff70886a1
975 changed files with 22196 additions and 21964 deletions
@@ -1,18 +1,18 @@
export const preferencesLink = undefined;
export const profileLink = undefined;
export const signOutLink = '/logout.html';
export const privacyPolicyLink = '/privacy-policy';
export const signOutLink = "/logout.html";
export const privacyPolicyLink = "/privacy-policy";
export const accountAdminLink = (id) => `/admin/accounts/${id}`;
export const statusAdminLink = (account_id, status_id) => `/admin/accounts/${account_id}/statuses/${status_id}`;
export const filterEditLink = (id) => `/filters/${id}/edit`;
export const relationshipsLink = '/relationships';
export const securityLink = '/auth/edit';
export const relationshipsLink = "/relationships";
export const securityLink = "/auth/edit";
export const preferenceLink = (setting_name) => {
switch (setting_name) {
case 'user_setting_expand_spoilers':
case 'user_setting_disable_swiping':
return `/settings/preferences/appearance#${setting_name}`;
default:
return preferencesLink;
case "user_setting_expand_spoilers":
case "user_setting_disable_swiping":
return `/settings/preferences/appearance#${setting_name}`;
default:
return preferencesLink;
}
};
@@ -1,10 +1,10 @@
import ready from '../ready';
import ready from "../ready";
export let assetHost = '';
export let assetHost = "";
ready(() => {
const cdnHost = document.querySelector('meta[name=cdn-host]');
const cdnHost = document.querySelector("meta[name=cdn-host]");
if (cdnHost) {
assetHost = cdnHost.content || '';
assetHost = cdnHost.content || "";
}
});
@@ -1,16 +1,18 @@
function _autoUnfoldCW(spoiler_text, settings) {
if (!settings.getIn(['content_warnings', 'auto_unfold']))
if (!settings.getIn(["content_warnings", "auto_unfold"])) {
return false;
}
const skip_unfold_regex = settings.getIn(['content_warnings', 'filter']);
const skip_unfold_regex = settings.getIn(["content_warnings", "filter"]);
if (!skip_unfold_regex)
if (!skip_unfold_regex) {
return true;
}
let regex = null;
try {
regex = new RegExp(skip_unfold_regex.trim(), 'i');
regex = new RegExp(skip_unfold_regex.trim(), "i");
} catch (e) {
// Bad regex, skip filters
return true;
@@ -24,8 +26,9 @@ export function autoHideCW(settings, spoiler_text) {
}
export function autoUnfoldCW(settings, status) {
if (!status)
if (!status) {
return false;
}
return _autoUnfoldCW(status.get('spoiler_text'), settings);
return _autoUnfoldCW(status.get("spoiler_text"), settings);
}
@@ -1,7 +1,7 @@
// Focuses the root element.
export function focusRoot () {
let e;
if (document && (e = document.querySelector('.ui')) && (e = e.parentElement)) {
if (document && (e = document.querySelector(".ui")) && (e = e.parentElement)) {
e.focus();
}
}
@@ -1,16 +1,16 @@
export const toServerSideType = (columnType: string) => {
switch (columnType) {
case 'home':
case 'notifications':
case 'public':
case 'thread':
case 'account':
case "home":
case "notifications":
case "public":
case "thread":
case "account":
return columnType;
default:
if (columnType.includes('list:')) {
return 'home';
if (columnType.includes("list:")) {
return "home";
} else {
return 'public'; // community, account, hashtag
return "public"; // community, account, hashtag
}
}
};
@@ -1,6 +1,6 @@
export function recoverHashtags (recognizedTags, text) {
return recognizedTags.map(tag => {
const re = new RegExp(`(?:^|[^/)\\w])#(${tag.name})`, 'i');
const re = new RegExp(`(?:^|[^/)\\w])#(${tag.name})`, "i");
const matched_hashtag = text.match(re);
return matched_hashtag ? matched_hashtag[1] : null;
},
@@ -1,12 +1,12 @@
const HASHTAG_SEPARATORS = '_\\u00b7\\u200c';
const ALPHA = '\\p{L}\\p{M}';
const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}';
const HASHTAG_SEPARATORS = "_\\u00b7\\u200c";
const ALPHA = "\\p{L}\\p{M}";
const WORD = "\\p{L}\\p{M}\\p{N}\\p{Pc}";
const buildHashtagPatternRegex = () => {
try {
return new RegExp(
`(?:^|[^\\/\\)\\w])#(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))`,
'iu',
"iu",
);
} catch {
return /(?:^|[^/)\w])#(\w*[a-zA-Z·]\w*)/i;
@@ -17,7 +17,7 @@ const buildHashtagRegex = () => {
try {
return new RegExp(
`^(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))$`,
'iu',
"iu",
);
} catch {
return /^(\w*[a-zA-Z·]\w*)$/i;
+2 -2
View File
@@ -1,5 +1,5 @@
export const unescapeHTML = (html) => {
const wrapper = document.createElement('div');
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
const wrapper = document.createElement("div");
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, "\n").replace(/<\/p><p>/g, "\n\n").replace(/<[^>]*>/g, "");
return wrapper.textContent;
};
+4 -4
View File
@@ -1,10 +1,10 @@
import punycode from 'punycode';
import punycode from "punycode";
const IDNA_PREFIX = 'xn--';
const IDNA_PREFIX = "xn--";
export const decode = domain => {
return domain
.split('.')
.split(".")
.map(part => part.indexOf(IDNA_PREFIX) === 0 ? punycode.decode(part.slice(IDNA_PREFIX.length)) : part)
.join('.');
.join(".");
};
@@ -1,5 +1,5 @@
// This function returns the new value unless it is `null` or
// `undefined`, in which case it returns the old one.
export function overwrite (oldVal, newVal) {
return newVal === null || typeof newVal === 'undefined' ? oldVal : newVal;
return newVal === null || typeof newVal === "undefined" ? oldVal : newVal;
}
+15 -15
View File
@@ -1,34 +1,34 @@
import Rails from '@rails/ujs';
import Rails from "@rails/ujs";
import { signOutLink } from 'flavours/glitch/utils/backend_links';
import { signOutLink } from "flavours/glitch/utils/backend_links";
export const logOut = () => {
const form = document.createElement('form');
const form = document.createElement("form");
const methodInput = document.createElement('input');
methodInput.setAttribute('name', '_method');
methodInput.setAttribute('value', 'delete');
methodInput.setAttribute('type', 'hidden');
const methodInput = document.createElement("input");
methodInput.setAttribute("name", "_method");
methodInput.setAttribute("value", "delete");
methodInput.setAttribute("type", "hidden");
form.appendChild(methodInput);
const csrfToken = Rails.csrfToken();
const csrfParam = Rails.csrfParam();
if (csrfParam && csrfToken) {
const csrfInput = document.createElement('input');
csrfInput.setAttribute('name', csrfParam);
csrfInput.setAttribute('value', csrfToken);
csrfInput.setAttribute('type', 'hidden');
const csrfInput = document.createElement("input");
csrfInput.setAttribute("name", csrfParam);
csrfInput.setAttribute("value", csrfToken);
csrfInput.setAttribute("type", "hidden");
form.appendChild(csrfInput);
}
const submitButton = document.createElement('input');
submitButton.setAttribute('type', 'submit');
const submitButton = document.createElement("input");
submitButton.setAttribute("type", "submit");
form.appendChild(submitButton);
form.method = 'get';
form.method = "get";
form.action = signOutLink;
form.style.display = 'none';
form.style.display = "none";
document.body.appendChild(form);
submitButton.click();
@@ -14,7 +14,7 @@ const checkNotificationPromise = () => {
const handlePermission = (permission, callback) => {
// Whatever the user answers, we make sure Chrome stores the information
if(!('permission' in Notification)) {
if(!("permission" in Notification)) {
Notification.permission = permission;
}
@@ -1,4 +1,4 @@
import type { ValueOf } from 'flavours/glitch/types/util';
import { type ValueOf } from "flavours/glitch/types/util";
export const DECIMAL_UNITS = Object.freeze({
ONE: 1,
@@ -1,4 +1,4 @@
export const order = ['public', 'unlisted', 'private', 'direct'];
export const order = ["public", "unlisted", "private", "direct"];
export function privacyPreference (a, b) {
return order[Math.max(order.indexOf(a), order.indexOf(b), 0)];
@@ -18,4 +18,4 @@ export function conditionalRender (test, data, component) {
}
// This object provides props to make the component not visible.
export const hiddenComponent = { style: { display: 'none' } };
export const hiddenComponent = { style: { display: "none" } };
@@ -1,4 +1,4 @@
import EXIF from 'exif-js';
import EXIF from "exif-js";
const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
@@ -10,34 +10,34 @@ const _browser_quirks = {};
// See https://github.com/w3c/csswg-drafts/issues/4666
// and https://github.com/blueimp/JavaScript-Load-Image/commit/1e4df707821a0afcc11ea0720ee403b8759f3881
const dropOrientationIfNeeded = (orientation) => new Promise(resolve => {
switch (_browser_quirks['image-orientation-automatic']) {
case true:
resolve(1);
break;
case false:
resolve(orientation);
break;
default:
switch (_browser_quirks["image-orientation-automatic"]) {
case true:
resolve(1);
break;
case false:
resolve(orientation);
break;
default:
// black 2x1 JPEG, with the following meta information set:
// - EXIF Orientation: 6 (Rotated 90° CCW)
const testImageURL =
'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' +
'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' +
'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' +
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' +
'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' +
'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==';
const img = new Image();
img.onload = () => {
const automatic = (img.width === 1 && img.height === 2);
_browser_quirks['image-orientation-automatic'] = automatic;
resolve(automatic ? 1 : orientation);
};
img.onerror = () => {
_browser_quirks['image-orientation-automatic'] = false;
resolve(orientation);
};
img.src = testImageURL;
const testImageURL =
"data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA" +
"AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA" +
"QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE" +
"BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x" +
"ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA" +
"AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==";
const img = new Image();
img.onload = () => {
const automatic = (img.width === 1 && img.height === 2);
_browser_quirks["image-orientation-automatic"] = automatic;
resolve(automatic ? 1 : orientation);
};
img.onerror = () => {
_browser_quirks["image-orientation-automatic"] = false;
resolve(orientation);
};
img.src = testImageURL;
}
});
@@ -45,38 +45,38 @@ const dropOrientationIfNeeded = (orientation) => new Promise(resolve => {
// or randomized data. Use a pre-defined image to check if reading the canvas
// works.
const checkCanvasReliability = () => new Promise((resolve, reject) => {
switch(_browser_quirks['canvas-read-unreliable']) {
case true:
reject('Canvas reading unreliable');
break;
case false:
resolve();
break;
default:
switch(_browser_quirks["canvas-read-unreliable"]) {
case true:
reject("Canvas reading unreliable");
break;
case false:
resolve();
break;
default:
// 2×2 GIF with white, red, green and blue pixels
const testImageURL =
'data:image/gif;base64,R0lGODdhAgACAKEDAAAA//8AAAD/AP///ywAAAAAAgACAAACA1wEBQA7';
const refData =
const testImageURL =
"data:image/gif;base64,R0lGODdhAgACAKEDAAAA//8AAAD/AP///ywAAAAAAgACAAACA1wEBQA7";
const refData =
[255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255];
const img = new Image();
img.onload = () => {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.drawImage(img, 0, 0, 2, 2);
const imageData = context.getImageData(0, 0, 2, 2);
if (imageData.data.every((x, i) => refData[i] === x)) {
_browser_quirks['canvas-read-unreliable'] = false;
resolve();
} else {
_browser_quirks['canvas-read-unreliable'] = true;
reject('Canvas reading unreliable');
}
};
img.onerror = () => {
_browser_quirks['canvas-read-unreliable'] = true;
reject('Failed to load test image');
};
img.src = testImageURL;
const img = new Image();
img.onload = () => {
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
context.drawImage(img, 0, 0, 2, 2);
const imageData = context.getImageData(0, 0, 2, 2);
if (imageData.data.every((x, i) => refData[i] === x)) {
_browser_quirks["canvas-read-unreliable"] = false;
resolve();
} else {
_browser_quirks["canvas-read-unreliable"] = true;
reject("Canvas reading unreliable");
}
};
img.onerror = () => {
_browser_quirks["canvas-read-unreliable"] = true;
reject("Failed to load test image");
};
img.src = testImageURL;
}
});
@@ -108,14 +108,14 @@ const loadImage = inputFile => new Promise((resolve, reject) => {
}).catch(reject);
});
const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
if (!['image/jpeg', 'image/webp'].includes(type)) {
const getOrientation = (img, type = "image/png") => new Promise(resolve => {
if (!["image/jpeg", "image/webp"].includes(type)) {
resolve(1);
return;
}
EXIF.getData(img, () => {
const orientation = EXIF.getTag(img, 'Orientation');
const orientation = EXIF.getTag(img, "Orientation");
if (orientation !== 1) {
dropOrientationIfNeeded(orientation).then(resolve).catch(() => resolve(orientation));
} else {
@@ -124,8 +124,8 @@ const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
});
});
const processImage = (img, { width, height, orientation, type = 'image/png' }) => new Promise(resolve => {
const canvas = document.createElement('canvas');
const processImage = (img, { width, height, orientation, type = "image/png" }) => new Promise(resolve => {
const canvas = document.createElement("canvas");
if (4 < orientation && orientation < 9) {
canvas.width = height;
@@ -135,16 +135,16 @@ const processImage = (img, { width, height, orientation, type = 'image/png' }) =
canvas.height = height;
}
const context = canvas.getContext('2d');
const context = canvas.getContext("2d");
switch (orientation) {
case 2: context.transform(-1, 0, 0, 1, width, 0); break;
case 3: context.transform(-1, 0, 0, -1, width, height); break;
case 4: context.transform(1, 0, 0, -1, 0, height); break;
case 5: context.transform(0, 1, 1, 0, 0, 0); break;
case 6: context.transform(0, 1, -1, 0, height, 0); break;
case 7: context.transform(0, -1, -1, 0, height, width); break;
case 8: context.transform(0, -1, 1, 0, 0, width); break;
case 2: context.transform(-1, 0, 0, 1, width, 0); break;
case 3: context.transform(-1, 0, 0, -1, width, height); break;
case 4: context.transform(1, 0, 0, -1, 0, height); break;
case 5: context.transform(0, 1, 1, 0, 0, 0); break;
case 6: context.transform(0, 1, -1, 0, height, 0); break;
case 7: context.transform(0, -1, -1, 0, height, width); break;
case 8: context.transform(0, -1, 1, 0, 0, width); break;
}
context.drawImage(img, 0, 0, width, height);
@@ -152,7 +152,7 @@ const processImage = (img, { width, height, orientation, type = 'image/png' }) =
canvas.toBlob(resolve, type);
});
const resizeImage = (img, type = 'image/png') => new Promise((resolve, reject) => {
const resizeImage = (img, type = "image/png") => new Promise((resolve, reject) => {
const { width, height } = img;
const newWidth = Math.round(Math.sqrt(MAX_IMAGE_PIXELS * (width / height)));
@@ -171,7 +171,7 @@ const resizeImage = (img, type = 'image/png') => new Promise((resolve, reject) =
});
const resizeFile = (inputFile) => new Promise((resolve) => {
if (!inputFile.type.match(/image.*/) || inputFile.type === 'image/gif') {
if (!inputFile.type.match(/image.*/) || inputFile.type === "image/gif") {
resolve(inputFile);
return;
}
@@ -5,12 +5,12 @@ let cachedScrollbarWidth = null;
* @returns {number}
*/
const getActualScrollbarWidth = () => {
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.overflow = 'scroll';
const outer = document.createElement("div");
outer.style.visibility = "hidden";
outer.style.overflow = "scroll";
document.body.appendChild(outer);
const inner = document.createElement('div');
const inner = document.createElement("div");
outer.appendChild(inner);
const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;