WebUI: prefer Number static properties over global ones

`Number` purpose is modularization of globals in ECMAScript 2015.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt#number.parseint_vs._parseint
This commit is contained in:
Chocobo1
2025-08-24 20:02:59 +08:00
parent fb4b266828
commit 86acc01b1a
5 changed files with 10 additions and 6 deletions

View File

@@ -3,8 +3,9 @@ import Html from "eslint-plugin-html";
import Js from "@eslint/js";
import PluginQbtWebUI from "eslint-plugin-qbt-webui";
import PreferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
import Stylistic from "@stylistic/eslint-plugin";
import * as RegexpPlugin from "eslint-plugin-regexp";
import Stylistic from "@stylistic/eslint-plugin";
import Unicorn from "eslint-plugin-unicorn";
export default [
Js.configs.recommended,
@@ -27,7 +28,8 @@ export default [
PluginQbtWebUI,
PreferArrowFunctions,
RegexpPlugin,
Stylistic
Stylistic,
Unicorn
},
rules: {
"curly": ["error", "multi-or-nest", "consistent"],
@@ -65,7 +67,8 @@ export default [
],
"Stylistic/quote-props": ["error", "consistent-as-needed"],
"Stylistic/semi": "error",
"Stylistic/spaced-comment": ["error", "always", { exceptions: ["*"] }]
"Stylistic/spaced-comment": ["error", "always", { exceptions: ["*"] }],
"Unicorn/prefer-number-properties": "error"
}
}
];

View File

@@ -17,6 +17,7 @@
"eslint-plugin-prefer-arrow-functions": "*",
"eslint-plugin-qbt-webui": "https://github.com/Chocobo1/eslint-plugin-qbt-webui/tarball/v1",
"eslint-plugin-regexp": "*",
"eslint-plugin-unicorn": "*",
"happy-dom": "*",
"html-validate": "*",
"js-beautify": "*",

View File

@@ -1618,7 +1618,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
},
column: "mainColumn",
onResize: window.qBittorrent.Misc.createDebounceHandler(500, (e) => {
const isHidden = (parseInt(document.getElementById("propertiesPanel").style.height, 10) === 0);
const isHidden = (Number.parseInt(document.getElementById("propertiesPanel").style.height, 10) === 0);
if (!isHidden)
saveColumnSizes();
}),

View File

@@ -285,7 +285,7 @@ window.qBittorrent.DynamicTable ??= (() => {
const onStart = function(el, event) {
if (this.canResize) {
this.currentHeaderAction = "resize";
this.startWidth = parseInt(this.resizeTh.style.width, 10);
this.startWidth = Number.parseInt(this.resizeTh.style.width, 10);
}
else {
this.currentHeaderAction = "drag";

View File

@@ -2928,7 +2928,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
let maxRatio = -1;
if (document.getElementById("maxRatioCheckbox").checked) {
maxRatio = Number(document.getElementById("maxRatioValue").value);
if (isNaN(maxRatio) || (maxRatio < 0)) {
if (Number.isNaN(maxRatio) || (maxRatio < 0)) {
alert("QBT_TR(Share ratio limit must not have a negative value.)QBT_TR[CONTEXT=HttpServer]");
return;
}