[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,9 +1,9 @@
import Trie from 'substring-trie';
import Trie from "substring-trie";
import { autoPlayGif, useSystemEmojiFont } from 'flavours/glitch/initial_state';
import { assetHost } from 'flavours/glitch/utils/config';
import { autoPlayGif, useSystemEmojiFont } from "flavours/glitch/initial_state";
import { assetHost } from "flavours/glitch/utils/config";
import unicodeMapping from './emoji_unicode_mapping_light';
import unicodeMapping from "./emoji_unicode_mapping_light";
const trie = new Trie(Object.keys(unicodeMapping));
@@ -13,12 +13,12 @@ const emojiFilenames = (emojis) => {
};
// Emoji requiring extra borders depending on theme
const darkEmoji = emojiFilenames(['🎱', '🐜', '⚫', '🖤', '⬛', '◼️', '◾', '◼️', '✒️', '▪️', '💣', '🎳', '📷', '📸', '♣️', '🕶️', '✴️', '🔌', '💂‍♀️', '📽️', '🍳', '🦍', '💂', '🔪', '🕳️', '🕹️', '🕋', '🖊️', '🖋️', '💂‍♂️', '🎤', '🎓', '🎥', '🎼', '♠️', '🎩', '🦃', '📼', '📹', '🎮', '🐃', '🏴', '🐞', '🕺', '📱', '📲', '🚲']);
const lightEmoji = emojiFilenames(['👽', '⚾', '🐔', '☁️', '💨', '🕊️', '👀', '🍥', '👻', '🐐', '❕', '❔', '⛸️', '🌩️', '🔊', '🔇', '📃', '🌧️', '🐏', '🍚', '🍙', '🐓', '🐑', '💀', '☠️', '🌨️', '🔉', '🔈', '💬', '💭', '🏐', '🏳️', '⚪', '⬜', '◽', '◻️', '▫️']);
const darkEmoji = emojiFilenames(["🎱", "🐜", "⚫", "🖤", "⬛", "◼️", "◾", "◼️", "✒️", "▪️", "💣", "🎳", "📷", "📸", "♣️", "🕶️", "✴️", "🔌", "💂‍♀️", "📽️", "🍳", "🦍", "💂", "🔪", "🕳️", "🕹️", "🕋", "🖊️", "🖋️", "💂‍♂️", "🎤", "🎓", "🎥", "🎼", "♠️", "🎩", "🦃", "📼", "📹", "🎮", "🐃", "🏴", "🐞", "🕺", "📱", "📲", "🚲"]);
const lightEmoji = emojiFilenames(["👽", "⚾", "🐔", "☁️", "💨", "🕊️", "👀", "🍥", "👻", "🐐", "❕", "❔", "⛸️", "🌩️", "🔊", "🔇", "📃", "🌧️", "🐏", "🍚", "🍙", "🐓", "🐑", "💀", "☠️", "🌨️", "🔉", "🔈", "💬", "💭", "🏐", "🏳️", "⚪", "⬜", "◽", "◻️", "▫️"]);
const emojiFilename = (filename) => {
const borderedEmoji = (document.body && document.body.classList.contains('skin-mastodon-light')) ? lightEmoji : darkEmoji;
return borderedEmoji.includes(filename) ? (filename + '_border') : filename;
const borderedEmoji = (document.body && document.body.classList.contains("skin-mastodon-light")) ? lightEmoji : darkEmoji;
return borderedEmoji.includes(filename) ? (filename + "_border") : filename;
};
const emojifyTextNode = (node, customEmojis) => {
@@ -39,7 +39,7 @@ const emojifyTextNode = (node, customEmojis) => {
i += str.codePointAt(i) < 65536 ? 1 : 2;
}
} else {
while (i < str.length && str[i] !== ':' && (useSystemEmojiFont || !(unicode_emoji = trie.search(str.slice(i))))) {
while (i < str.length && str[i] !== ":" && (useSystemEmojiFont || !(unicode_emoji = trie.search(str.slice(i))))) {
i += str.codePointAt(i) < 65536 ? 1 : 2;
}
}
@@ -50,8 +50,8 @@ const emojifyTextNode = (node, customEmojis) => {
}
let rend, replacement = null;
if (str[i] === ':') { // Potentially the start of a custom emoji :shortcode:
rend = str.indexOf(':', i + 1) + 1;
if (str[i] === ":") { // Potentially the start of a custom emoji :shortcode:
rend = str.indexOf(":", i + 1) + 1;
// no matching ending ':', skip
if (!rend) {
@@ -71,14 +71,14 @@ const emojifyTextNode = (node, customEmojis) => {
// now got a replacee as ':shortcode:'
// if you want additional emoji handler, add statements below which set replacement and return true.
const filename = autoPlayGif ? custom_emoji.url : custom_emoji.static_url;
replacement = document.createElement('img');
replacement.setAttribute('draggable', 'false');
replacement.setAttribute('class', 'emojione custom-emoji');
replacement.setAttribute('alt', shortcode);
replacement.setAttribute('title', shortcode);
replacement.setAttribute('src', filename);
replacement.setAttribute('data-original', custom_emoji.url);
replacement.setAttribute('data-static', custom_emoji.static_url);
replacement = document.createElement("img");
replacement.setAttribute("draggable", "false");
replacement.setAttribute("class", "emojione custom-emoji");
replacement.setAttribute("alt", shortcode);
replacement.setAttribute("title", shortcode);
replacement.setAttribute("src", filename);
replacement.setAttribute("data-original", custom_emoji.url);
replacement.setAttribute("data-static", custom_emoji.static_url);
} else { // start of an unicode emoji
rend = i + unicode_emoji.length;
@@ -89,14 +89,14 @@ const emojifyTextNode = (node, customEmojis) => {
}
const { filename, shortCode } = unicodeMapping[unicode_emoji];
const title = shortCode ? `:${shortCode}:` : '';
const title = shortCode ? `:${shortCode}:` : "";
replacement = document.createElement('img');
replacement.setAttribute('draggable', 'false');
replacement.setAttribute('class', 'emojione');
replacement.setAttribute('alt', unicode_emoji);
replacement.setAttribute('title', title);
replacement.setAttribute('src', `${assetHost}/emoji/${emojiFilename(filename)}.svg`);
replacement = document.createElement("img");
replacement.setAttribute("draggable", "false");
replacement.setAttribute("class", "emojione");
replacement.setAttribute("alt", unicode_emoji);
replacement.setAttribute("title", title);
replacement.setAttribute("src", `${assetHost}/emoji/${emojiFilename(filename)}.svg`);
}
// Add the processed-up-to-now string and the emoji replacement
@@ -113,23 +113,25 @@ const emojifyTextNode = (node, customEmojis) => {
const emojifyNode = (node, customEmojis) => {
for (const child of node.childNodes) {
switch(child.nodeType) {
case Node.TEXT_NODE:
emojifyTextNode(child, customEmojis);
break;
case Node.ELEMENT_NODE:
if (!child.classList.contains('invisible'))
emojifyNode(child, customEmojis);
break;
case Node.TEXT_NODE:
emojifyTextNode(child, customEmojis);
break;
case Node.ELEMENT_NODE:
if (!child.classList.contains("invisible")) {
emojifyNode(child, customEmojis);
}
break;
}
}
};
const emojify = (str, customEmojis = {}) => {
const wrapper = document.createElement('div');
const wrapper = document.createElement("div");
wrapper.innerHTML = str;
if (!Object.keys(customEmojis).length)
if (!Object.keys(customEmojis).length) {
customEmojis = null;
}
emojifyNode(wrapper, customEmojis);
@@ -143,24 +145,24 @@ export const buildCustomEmojis = (customEmojis) => {
const emojis = [];
customEmojis.forEach(emoji => {
const shortcode = emoji.get('shortcode');
const url = autoPlayGif ? emoji.get('url') : emoji.get('static_url');
const name = shortcode.replace(':', '');
const shortcode = emoji.get("shortcode");
const url = autoPlayGif ? emoji.get("url") : emoji.get("static_url");
const name = shortcode.replace(":", "");
emojis.push({
id: name,
name,
short_names: [name],
text: '',
text: "",
emoticons: [],
keywords: [name],
imageUrl: url,
custom: true,
customCategory: emoji.get('category'),
customCategory: emoji.get("category"),
});
});
return emojis;
};
export const categoriesFromEmojis = customEmojis => customEmojis.reduce((set, emoji) => set.add(emoji.get('category') ? `custom-${emoji.get('category')}` : 'custom'), new Set(['custom']));
export const categoriesFromEmojis = customEmojis => customEmojis.reduce((set, emoji) => set.add(emoji.get("category") ? `custom-${emoji.get("category")}` : "custom"), new Set(["custom"]));
@@ -1,5 +1,5 @@
import type { BaseEmoji, EmojiData, NimbleEmojiIndex } from 'emoji-mart';
import type { Category, Data, Emoji } from 'emoji-mart/dist-es/utils/data';
import { type BaseEmoji, type EmojiData, type NimbleEmojiIndex } from "emoji-mart";
import { type Category, type Data, type Emoji } from "emoji-mart/dist-es/utils/data";
/*
* The 'search' property, although not defined in the [`Emoji`]{@link node_modules/@types/emoji-mart/dist-es/utils/data.d.ts#Emoji} type,
@@ -17,15 +17,15 @@ export type Skins = null;
export type FilenameData = string[] | string[][];
export type ShortCodesToEmojiDataKey =
| EmojiData['id']
| BaseEmoji['native']
| keyof NimbleEmojiIndex['emojis'];
| EmojiData["id"]
| BaseEmoji["native"]
| keyof NimbleEmojiIndex["emojis"];
export type SearchData = [
BaseEmoji['native'],
Emoji['short_names'],
BaseEmoji["native"],
Emoji["short_names"],
Search,
Emoji['unified'],
Emoji["unified"],
];
export type ShortCodesToEmojiData = Record<
@@ -38,7 +38,7 @@ export type EmojiCompressed = [
ShortCodesToEmojiData,
Skins,
Category[],
Data['aliases'],
Data["aliases"],
EmojisWithoutShortCodes,
];
@@ -49,4 +49,4 @@ export type EmojiCompressed = [
*/
declare const emojiCompressed: EmojiCompressed;
export default emojiCompressed; // eslint-disable-line import/no-default-export
export default emojiCompressed;
@@ -1,5 +1,4 @@
/* eslint-disable import/no-commonjs --
We need to use CommonJS here due to preval */
// @preval
// http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
// This file contains the compressed version of the emoji data from
@@ -7,13 +6,13 @@
// It's designed to be emitted in an array format to take up less space
// over the wire.
const { emojiIndex } = require('emoji-mart');
let data = require('emoji-mart/data/all.json');
const { uncompress: emojiMartUncompress } = require('emoji-mart/dist/utils/data');
const { emojiIndex } = require("emoji-mart");
let data = require("emoji-mart/data/all.json");
const { uncompress: emojiMartUncompress } = require("emoji-mart/dist/utils/data");
const emojiMap = require('./emoji_map.json');
const { unicodeToFilename } = require('./unicode_to_filename');
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
const emojiMap = require("./emoji_map.json");
const { unicodeToFilename } = require("./unicode_to_filename");
const { unicodeToUnifiedName } = require("./unicode_to_unified_name");
if(data.compressed) {
@@ -22,8 +21,8 @@ if(data.compressed) {
const emojiMartData = data;
const excluded = ['®', '©', '™'];
const skinTones = ['🏻', '🏼', '🏽', '🏾', '🏿'];
const excluded = ["®", "©", "™"];
const skinTones = ["🏻", "🏼", "🏽", "🏾", "🏿"];
const shortcodeMap = {};
const shortCodesToEmojiData = {};
@@ -33,8 +32,8 @@ Object.keys(emojiIndex.emojis).forEach(key => {
let emoji = emojiIndex.emojis[key];
// Emojis with skin tone modifiers are stored like this
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
emoji = emoji['1'];
if (Object.prototype.hasOwnProperty.call(emoji, "1")) {
emoji = emoji["1"];
}
shortcodeMap[emoji.native] = emoji.id;
@@ -42,7 +41,7 @@ Object.keys(emojiIndex.emojis).forEach(key => {
const stripModifiers = unicode => {
skinTones.forEach(tone => {
unicode = unicode.replace(tone, '');
unicode = unicode.replace(tone, "");
});
return unicode;
@@ -58,7 +57,7 @@ Object.keys(emojiMap).forEach(key => {
let shortcode = shortcodeMap[normalizedKey];
if (!shortcode) {
shortcode = shortcodeMap[normalizedKey + '\uFE0F'];
shortcode = shortcodeMap[normalizedKey + "\uFE0F"];
}
const filename = emojiMap[key];
@@ -70,7 +69,7 @@ Object.keys(emojiMap).forEach(key => {
filenameData.push(filename);
}
if (typeof shortcode === 'undefined') {
if (typeof shortcode === "undefined") {
emojisWithoutShortCodes.push(filenameData);
} else {
if (!Array.isArray(shortCodesToEmojiData[shortcode])) {
@@ -85,17 +84,17 @@ Object.keys(emojiIndex.emojis).forEach(key => {
let emoji = emojiIndex.emojis[key];
// Emojis with skin tone modifiers are stored like this
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
emoji = emoji['1'];
if (Object.prototype.hasOwnProperty.call(emoji, "1")) {
emoji = emoji["1"];
}
const { native } = emoji;
let { short_names, search, unified } = emojiMartData.emojis[key];
if (short_names[0] !== key) {
throw new Error('The compresser expects the first short_code to be the ' +
'key. It may need to be rewritten if the emoji change such that this ' +
'is no longer the case.');
throw new Error("The compresser expects the first short_code to be the " +
"key. It may need to be rewritten if the emoji change such that this " +
"is no longer the case.");
}
short_names = short_names.slice(1); // first short name can be inferred from the key
@@ -1,19 +1,19 @@
// The output of this module is designed to mimic emoji-mart's
// "data" object, such that we can use it for a light version of emoji-mart's
// emojiIndex.search functionality.
import type { BaseEmoji } from 'emoji-mart';
import type { Emoji } from 'emoji-mart/dist-es/utils/data';
import { type BaseEmoji } from "emoji-mart";
import { type Emoji } from "emoji-mart/dist-es/utils/data";
import type { Search, ShortCodesToEmojiData } from './emoji_compressed';
import emojiCompressed from './emoji_compressed';
import { unicodeToUnifiedName } from './unicode_to_unified_name';
import { type Search, type ShortCodesToEmojiData } from "./emoji_compressed";
import emojiCompressed from "./emoji_compressed";
import { unicodeToUnifiedName } from "./unicode_to_unified_name";
type Emojis = {
[key in NonNullable<keyof ShortCodesToEmojiData>]: {
native: BaseEmoji['native'];
search: Search;
short_names: Emoji['short_names'];
unified: Emoji['unified'];
native: BaseEmoji["native"],
search: Search,
short_names: Emoji["short_names"],
unified: Emoji["unified"],
};
};
@@ -40,7 +40,9 @@ Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
unified = unicodeToUnifiedName(native);
}
if (short_names) short_names = [shortCode].concat(short_names);
if (short_names) {
short_names = [shortCode].concat(short_names);
}
emojis[shortCode] = {
native,
search,
@@ -1,8 +1,8 @@
// This code is largely borrowed from:
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/emoji-index.js
import * as data from './emoji_mart_data_light';
import { getData, getSanitizedData, uniq, intersect } from './emoji_utils';
import * as data from "./emoji_mart_data_light";
import { getData, getSanitizedData, uniq, intersect } from "./emoji_utils";
let originalPool = {};
let index = {};
@@ -39,7 +39,9 @@ function clearCustomEmojis(pool) {
}
function addCustomToPool(custom, pool) {
if (customEmojisList.length) clearCustomEmojis(pool);
if (customEmojisList.length) {
clearCustomEmojis(pool);
}
custom.forEach((emoji) => {
let emojiId = emoji.id || emoji.short_names[0];
@@ -56,8 +58,9 @@ function addCustomToPool(custom, pool) {
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom } = {}) {
if (custom !== undefined) {
if (customEmojisList !== custom)
if (customEmojisList !== custom) {
addCustomToPool(custom, originalPool);
}
} else {
custom = [];
}
@@ -70,8 +73,8 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
pool = originalPool;
if (value.length) {
if (value === '-' || value === '-1') {
return [emojisList['-1']];
if (value === "-" || value === "-1") {
return [emojisList["-1"]];
}
let values = value.toLowerCase().split(/[\s|,\-_]+/),
@@ -95,8 +98,8 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
});
if (custom.length) {
let customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true;
let customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false;
let customIsIncluded = include && include.length ? include.indexOf("custom") > -1 : true;
let customIsExcluded = exclude && exclude.length ? exclude.indexOf("custom") > -1 : false;
if (customIsIncluded && !customIsExcluded) {
addCustomToPool(custom, pool);
}
@@ -129,7 +132,9 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
if (subIndex !== -1) {
let score = subIndex + 1;
if (sub === id) score = 0;
if (sub === id) {
score = 0;
}
aIndex.results.push(emojisList[id]);
aIndex.pool[id] = emoji;
@@ -1,5 +1,5 @@
import Emoji from 'emoji-mart/dist-es/components/emoji/emoji';
import Picker from 'emoji-mart/dist-es/components/picker/picker';
import Emoji from "emoji-mart/dist-es/components/emoji/emoji";
import Picker from "emoji-mart/dist-es/components/picker/picker";
export {
Picker,
@@ -2,8 +2,8 @@
// (i.e. the svg filename) and a shortCode intended to be shown
// as a "title" attribute in an HTML element (aka tooltip).
import emojiCompressed from './emoji_compressed';
import { unicodeToFilename } from './unicode_to_filename';
import emojiCompressed from "./emoji_compressed";
import { unicodeToFilename } from "./unicode_to_filename";
const [
shortCodesToEmojiData,
@@ -1,7 +1,7 @@
// This code is largely borrowed from:
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/index.js
import * as data from './emoji_mart_data_light';
import * as data from "./emoji_mart_data_light";
const buildSearch = (data) => {
const search = [];
@@ -27,7 +27,7 @@ const buildSearch = (data) => {
addToSearch(data.keywords, false);
addToSearch(data.emoticons, false);
return search.join(',');
return search.join(",");
};
const _String = String;
@@ -40,9 +40,9 @@ const stringFromCodePoint = _String.fromCodePoint || function () {
let index = -1;
let length = arguments.length;
if (!length) {
return '';
return "";
}
let result = '';
let result = "";
while (++index < length) {
let codePoint = Number(arguments[index]);
if (
@@ -51,7 +51,7 @@ const stringFromCodePoint = _String.fromCodePoint || function () {
codePoint > 0x10FFFF || // not a valid Unicode code point
Math.floor(codePoint) !== codePoint // not an integer
) {
throw RangeError('Invalid code point: ' + codePoint);
throw RangeError("Invalid code point: " + codePoint);
}
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint);
@@ -75,12 +75,12 @@ const _JSON = JSON;
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
const SKINS = [
'1F3FA', '1F3FB', '1F3FC',
'1F3FD', '1F3FE', '1F3FF',
"1F3FA", "1F3FB", "1F3FC",
"1F3FD", "1F3FE", "1F3FF",
];
function unifiedToNative(unified) {
let unicodes = unified.split('-'),
let unicodes = unified.split("-"),
codePoints = unicodes.map((u) => `0x${u}`);
return stringFromCodePoint.apply(null, codePoints);
@@ -124,7 +124,7 @@ function getSanitizedData() {
function getData(emoji, skin, set) {
let emojiData = {};
if (typeof emoji === 'string') {
if (typeof emoji === "string") {
let matches = emoji.match(COLONS_REGEX);
if (matches) {
@@ -220,7 +220,7 @@ function deepMerge(a, b) {
value = b[key];
}
if (typeof value === 'object') {
if (typeof value === "object") {
value = deepMerge(originalValue, value);
}
@@ -232,13 +232,13 @@ function deepMerge(a, b) {
// https://github.com/sonicdoe/measure-scrollbar
function measureScrollbar() {
const div = document.createElement('div');
const div = document.createElement("div");
div.style.width = '100px';
div.style.height = '100px';
div.style.overflow = 'scroll';
div.style.position = 'absolute';
div.style.top = '-9999px';
div.style.width = "100px";
div.style.height = "100px";
div.style.overflow = "scroll";
div.style.position = "absolute";
div.style.top = "-9999px";
document.body.appendChild(div);
const scrollbarWidth = div.offsetWidth - div.clientWidth;
@@ -1,10 +1,9 @@
/* eslint-disable import/no-commonjs --
We need to use CommonJS here as its imported into a preval file (`emoji_compressed.js`) */
// taken from:
// https://github.com/twitter/twemoji/blob/47732c7/twemoji-generator.js#L848-L866
exports.unicodeToFilename = (str) => {
let result = '';
let result = "";
let charCode = 0;
let p = 0;
let i = 0;
@@ -12,7 +11,7 @@ exports.unicodeToFilename = (str) => {
charCode = str.charCodeAt(i++);
if (p) {
if (result.length > 0) {
result += '-';
result += "-";
}
result += (0x10000 + ((p - 0xD800) << 10) + (charCode - 0xDC00)).toString(16);
p = 0;
@@ -20,7 +19,7 @@ exports.unicodeToFilename = (str) => {
p = charCode;
} else {
if (result.length > 0) {
result += '-';
result += "-";
}
result += charCode.toString(16);
}
@@ -1,20 +1,19 @@
/* eslint-disable import/no-commonjs --
We need to use CommonJS here as its imported into a preval file (`emoji_compressed.js`) */
function padLeft(str, num) {
while (str.length < num) {
str = '0' + str;
str = "0" + str;
}
return str;
}
exports.unicodeToUnifiedName = (str) => {
let output = '';
let output = "";
for (let i = 0; i < str.length; i += 2) {
if (i > 0) {
output += '-';
output += "-";
}
output += padLeft(str.codePointAt(i).toString(16).toUpperCase(), 4);