Update Node version, TS, ESLint and co.

This commit is contained in:
Jean-Baptiste Emmanuel Zorg 2025-11-05 02:41:58 +01:00
parent 9f084197ac
commit 3b67645ac3
17 changed files with 8088 additions and 7670 deletions

2
.nvmrc
View file

@ -1 +1 @@
v20.11.1
v24.11.0

View file

@ -1,49 +0,0 @@
"use strict";
module.exports = {
extends: ["eslint:recommended", "plugin:compat/recommended"],
env: {
browser: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2022,
},
root: true,
plugins: [
'sort-keys-custom',
'compat'
],
ignorePatterns: [
"Scripts/lib/**/*.js",
"*.min.js",
"Screens/MiniGame/KinkyDungeon/*.js"
],
settings: {
polyfills: [
// Notification is not supported in iOS Safari 14.5-14.8
"Notification",
],
},
rules: {
"dot-notation": "error",
"no-unused-expressions": "error",
"no-caller": "error",
"no-eval": "error",
"no-new-wrappers": "error",
"no-throw-literal": "error",
"no-shadow": ["warn", { "hoist": "all" }],
"strict": ["error", "global"],
"no-constant-condition": ["error", { "checkLoops": false }],
"no-unused-vars": ["warn", { "vars": "local", "args": "none", "varsIgnorePattern": "^_" }],
"no-trailing-spaces": "warn",
"semi": "warn",
"indent": ["warn", "tab", { "SwitchCase": 1, "ignoredNodes": ["ConditionalExpression"] }],
"unicode-bom": ["error", "never"],
"eol-last": "error",
"no-tabs": ["warn", { "allowIndentationTabs": true }],
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
// Until globals are properly documented
"no-undef": "off",
"no-var": "off"
},
};

View file

@ -2042,7 +2042,7 @@ function CharacterAppearancePaste(C, CompApp, ChatRoomRefresh) {
let DecompressedData = null;
try {
DecompressedData = LZString.decompressFromBase64(CompApp);
} catch(err) {
} catch {
DecompressedData = null;
}
@ -2055,7 +2055,7 @@ function CharacterAppearancePaste(C, CompApp, ChatRoomRefresh) {
let App = null;
try {
App = JSON.parse(DecompressedData);
} catch(err) {
} catch {
App = null;
}

View file

@ -1008,7 +1008,7 @@ function LoginSetupPlayer(C) {
}
// Loads the ownership data
Player.Ownership = ServerAccountDataSyncedValidate.Ownership(C.Ownership);
Player.Ownership = ServerAccountDataSyncedValidate.Ownership(C.Ownership, Player);
if (Player.Ownership != null) {
Player.Owner = (Player.Ownership.Stage == 1) ? Player.Ownership.Name : "";
}
@ -1059,7 +1059,7 @@ function LoginSetupPlayer(C) {
if (data === null) throw new Error();
const json = /** @type {[number, string][]} */(JSON.parse(data));
friendNames = new Map(json);
} catch (err) {
} catch (_err) {
console.warn("An error occured while parsing friendnames, entries have been reset.");
}
}
@ -1074,7 +1074,7 @@ function LoginSetupPlayer(C) {
if (!CommonIsArray(json)) throw new Error();
const numbers = /** @type {number[]} */(json.filter(Number));
submissivesList = new Set(numbers);
} catch (err) {
} catch (_err) {
console.warn("An error occured while parsing submissives, entries have been reset.");
}
}

View file

@ -2275,7 +2275,7 @@ function ChatRoomMapViewPaste(Param) {
let DecompressedData = null;
try {
DecompressedData = LZString.decompressFromBase64(Param);
} catch(err) {
} catch {
DecompressedData = null;
}
@ -2289,7 +2289,7 @@ function ChatRoomMapViewPaste(Param) {
let MapData = null;
try {
MapData = JSON.parse(DecompressedData);
} catch(err) {
} catch {
MapData = null;
}

View file

@ -1697,7 +1697,7 @@ function CraftingDecompressServerData(Data) {
let DecompressedData = null;
try {
DecompressedData = LZString.decompressFromUTF16(Data);
} catch(err) {
} catch {
DecompressedData = null;
}
if (DecompressedData == null) {

View file

@ -380,7 +380,7 @@ var CraftingJSON = {
if (craftString != null) {
try {
craft = JSON.parse(LZString.decompressFromBase64(craftString));
} catch (error) {
} catch (_error) {
errors.add(i);
}
}

View file

@ -1235,7 +1235,7 @@ function CharacterLoadOnline(data, SourceMemberNumber) {
Char.Name = data.Name;
Char.Lover = (data.Lover != null) ? data.Lover : "";
Char.Owner = (data.Owner != null) ? data.Owner : "";
Char.Title = ServerAccountDataSyncedValidate.Title(data.Title);
Char.Title = ServerAccountDataSyncedValidate.Title(data.Title, Char);
Char.Nickname = data.Nickname;
Char.AccountName = "Online-" + data.ID.toString();
Char.MemberNumber = data.MemberNumber;

View file

@ -37,7 +37,6 @@ let ColorPickerInitOptions = null;
*/
function isTouchEvent(event) {
// Disabled for desktop Safari has no need for touch events
// eslint-disable-next-line
return window.TouchEvent && event instanceof TouchEvent;
}

View file

@ -567,7 +567,7 @@ async function CommonSetScreen(...spec) {
TextLoad();
try {
await TextScreenCache.loadedPromise;
} catch (e) {
} catch (_e) {
console.error(`Failed to load text strings for screen!`);
}
@ -1472,7 +1472,7 @@ function CommonURLHasExtension(TestURL, Extension) {
for (let Ext of Extension)
if (FormatUrl.endsWith(Ext))
return true;
} catch (err) {
} catch (_err) {
let FormatUrl = TestURL.trim().toLowerCase();
if ((FormatUrl.startsWith("screens/")) || (FormatUrl.startsWith("backgrounds/")))
for (let Ext of Extension)

View file

@ -5412,7 +5412,7 @@ function DialogFindAutoReplace(C, KeyWord1, KeyWord2, ReturnPrevious) {
* Draw the up/down arrow to bump a character up and down if they're hidden.
*/
function DialogDrawRepositionButton() {
if (!CurrentCharacter.HeightModifier == null || !CurrentCharacter.FocusGroup) return;
if (!CurrentCharacter.FocusGroup) return;
let drawButton = "";
if (CharacterAppearanceForceUpCharacter == CurrentCharacter.MemberNumber) {

View file

@ -145,7 +145,7 @@ function InventoryLoad(Inventory, InventoryData) {
for (let I = 0; I < Inv.length; I++) {
items.push({ Group: Inv[I][1], Name: Inv[I][0] });
}
} catch(err) {
} catch(_err) {
console.log("Error while loading compressed inventory, no inventory loaded.");
}
}

View file

@ -180,7 +180,7 @@ async function fetchMergeRequests(page) {
try {
const response = await fetch(`https://gitgud.io/api/v4/projects/${GIT_GUD_PROJECT_ID}/merge_requests?page=${page}`);
return /** @type {any} */ (await response.json());
} catch (error) {
} catch {
console.warn(`Fetch of merge request page ${page} failed. Retrying...`);
await new Promise((resolve) => setTimeout(resolve, 1000));
}

View file

@ -6,7 +6,7 @@ import gulpCount from "gulp-count";
import gulpIf from "gulp-if";
import gulpSize from "gulp-size";
import filter from "gulp-filter";
import imagemin from "gulp-imagemin";
import imagemin, { optipng, svgo } from "gulp-imagemin";
import jpegtran from "imagemin-jpegtran";
import cache from "gulp-cache";
import through from "through2";
@ -22,8 +22,8 @@ const SIZE_CONFIG = { showTotal: false };
export const assetMinify = gulp.series(logIntro, analyzeBefore, generateBatches, minifyBatches, analyzeAfter, report);
export function clean(cb) {
rimraf(CACHE_DIR, cb);
export async function clean() {
await rimraf(CACHE_DIR);
}
let files = [];
@ -43,9 +43,8 @@ const supportedSizes = {
},
};
function logIntro(cb) {
async function logIntro() {
log(c.cyan("Starting image minification. Please be patient, this can take a long time..."));
cb();
}
function analyze(beforeOrAfter, sizePlugins, record = false) {
@ -196,10 +195,8 @@ function minifyBatch(batch) {
))
.pipe(sizesAfter)
.pipe(filter((file) => {
// @ts-expect-error Smuggling size through
const sizeBefore = sizesBefore.sizes.get(file.path);
// @ts-expect-error Smuggling size through
const sizeAfter = sizesAfter.sizes.get(file.path);
const sizeBefore = /** @type {number} */ (sizesBefore.sizes.get(file.path));
const sizeAfter = /** @type {number} */ (sizesAfter.sizes.get(file.path));
if (sizeAfter > sizeBefore) {
log(`Omitting file "${c.magenta(file.path)}": size after minification is greater than original size.`);
}
@ -211,16 +208,15 @@ function minifyBatch(batch) {
function configureImagemin() {
return imagemin([
jpegtran(),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
optipng({ optimizationLevel: 5 }),
svgo({
plugins: [
{
name: "removeViewBox",
active: true,
},
// @ts-expect-error no idea
{
name: "cleanupIDs",
active: true,
},
],
}),
@ -232,6 +228,7 @@ function sourceFiles() {
`${BASE_DIR}/**/*.{jpg,jpeg,png,svg}`,
`!${BASE_DIR}/**/Assets/Female3DCG/BodyUpper/3DCGPose/**/*`,
`!${BASE_DIR}/Tools/**/*`,
`!${BASE_DIR}/node_modules/**/*`
], { base: BASE_DIR });
}
@ -255,10 +252,14 @@ function gulpLog(...messages) {
);
}
/**
*
* @returns {import("stream").Transform & {sizes: Map<string, number>}}
*/
function fileSizes() {
const sizes = new Map();
return through.obj(
const obj = through.obj(
async function (file, enc, cb) {
// @ts-expect-error Smuggling size through
if (!this.sizes) {
@ -284,6 +285,7 @@ function fileSizes() {
cb(null, file);
},
);
return /** @type {import("stream").Transform & {sizes: Map<any, any>}} */ (obj);
}
function getStreamSize(file) {

View file

@ -0,0 +1,122 @@
"use strict";
const {
defineConfig,
globalIgnores,
} = require("eslint/config");
const globals = require("globals");
const sortKeysCustom = require("eslint-plugin-sort-keys-custom");
const compatPlugin = require("eslint-plugin-compat");
const js = require("@eslint/js");
const {
FlatCompat,
} = require("@eslint/eslintrc");
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
/** @type {import("eslint/config").Config} */
const common = {
extends: compat.extends("eslint:recommended", "plugin:compat/recommended"),
plugins: {
"sort-keys-custom": sortKeysCustom,
"compat": compatPlugin,
},
settings: {
polyfills: ["Notification"],
},
rules: {
"dot-notation": "error",
"no-unused-expressions": "error",
"no-caller": "error",
"no-eval": "error",
"no-new-wrappers": "error",
"no-throw-literal": "error",
"no-shadow": ["warn", {
"hoist": "all",
}],
"strict": ["error", "global"],
"no-constant-condition": ["error", {
"checkLoops": false,
}],
"no-unused-vars": ["warn", {
"vars": "local",
"args": "none",
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
}],
"no-trailing-spaces": "warn",
"semi": "warn",
"indent": ["warn", "tab", {
"SwitchCase": 1,
"ignoredNodes": ["ConditionalExpression"],
}],
"unicode-bom": ["error", "never"],
"eol-last": "error",
"no-tabs": ["warn", {
"allowIndentationTabs": true,
}],
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
// Until globals are properly documented
"no-undef": "off",
"no-var": "off",
},
};
module.exports = defineConfig([
{
...common,
ignores: ["Tools/Node/**/*.js"],
languageOptions: {
globals: {
...globals.browser,
},
ecmaVersion: 2022,
parserOptions: {},
sourceType: "script",
},
},
{
...common,
files: ["Tools/Node/**/*.js"],
languageOptions: {
globals: {
...globals.browser,
},
ecmaVersion: 2022,
parserOptions: {},
sourceType: "module",
},
},
globalIgnores(
[
"Scripts/lib/**/*.js",
"**/*.min.js",
"Screens/MiniGame/KinkyDungeon/*.js",
],
),
]);

File diff suppressed because it is too large Load diff

View file

@ -39,8 +39,9 @@
"since 2020 and > 0.5% and not dead"
],
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.39.1",
"@types/core-js": "^2.5.8",
"@types/css-font-loading-module": "^0.0.14",
"@types/fancy-log": "^2.0.2",
"@types/gulp": "^4.0.17",
"@types/gulp-cache": "^0.4.9",
@ -50,36 +51,37 @@
"@types/imagemin-jpegtran": "^5.0.4",
"@types/lodash.template": "^4.5.3",
"@types/minimist": "^1.2.5",
"@types/node": "^20.8.7",
"@types/node": "^24.10.0",
"@types/stream-counter": "^1.0.3",
"ansi-colors": "^4.1.1",
"cheerio": "^1.0.0-rc.3",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-compat": "^4.1.2",
"eslint": "^9.39.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-compat": "^6.0.2",
"eslint-plugin-sort-keys-custom": "^2.0.0",
"fancy-log": "^2.0.0",
"gulp": "^4.0.2",
"globals": "^16.5.0",
"gulp": "^5.0.1",
"gulp-cache": "^1.1.3",
"gulp-count": "^1.0.0",
"gulp-filter": "^7.0.0",
"gulp-filter": "^9.0.1",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-size": "^4.0.1",
"imagemin-jpegtran": "^7.0.0",
"marked": "^15.0.6",
"gulp-imagemin": "^9.1.0",
"gulp-size": "^5.0.0",
"imagemin-jpegtran": "^8.0.0",
"marked": "^16.4.1",
"minimist": "^1.2.6",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"prettier-eslint": "^16.1.1",
"prettier-eslint-cli": "^8.0.1",
"pretty-bytes": "^5.6.0",
"pretty-bytes": "^7.1.0",
"rimraf": "^6.0.1",
"simple-git": "^3.5.0",
"stream-counter": "^1.0.0",
"table": "^6.7.3",
"through2": "^4.0.2",
"typescript": "^5.7.3"
"typescript": "^5.9.3"
},
"dependencies": {
"csv-writer": "^1.6.0",