WebUI: disallow unnecessary quotes in property name

Those two forms are the same and from now on we enforce to one style.

PR #22051.
This commit is contained in:
Chocobo1 2024-12-24 22:25:18 +08:00 committed by GitHub
parent bbc3c2832f
commit 7487cd7e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 144 additions and 143 deletions

View File

@ -42,7 +42,7 @@ export default [
"Stylistic/no-mixed-operators": [
"error",
{
"groups": [
groups: [
["&", "|", "^", "~", "<<", ">>", ">>>", "==", "!=", "===", "!==", ">", ">=", "<", "<=", "&&", "||", "in", "instanceof"]
]
}
@ -52,12 +52,13 @@ export default [
"error",
"double",
{
"avoidEscape": true,
"allowTemplateLiterals": true
avoidEscape: true,
allowTemplateLiterals: true
}
],
"Stylistic/quote-props": ["error", "consistent-as-needed"],
"Stylistic/semi": "error",
"Stylistic/spaced-comment": ["error", "always", { "exceptions": ["*"] }]
"Stylistic/spaced-comment": ["error", "always", { exceptions: ["*"] }]
}
}
];

View File

@ -39,8 +39,8 @@
fetch("api/v2/torrents/addPeers", {
method: "POST",
body: new URLSearchParams({
"hashes": hash,
"peers": peers.join("|")
hashes: hash,
peers: peers.join("|")
})
})
.then((response) => {

View File

@ -30,8 +30,8 @@
fetch("api/v2/torrents/addTrackers", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"urls": $("trackersUrls").value
hash: new URI().getData("hash"),
urls: $("trackersUrls").value
})
})
.then((response) => {

View File

@ -29,8 +29,8 @@
fetch("api/v2/torrents/addWebSeeds", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"urls": $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
hash: new URI().getData("hash"),
urls: $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
})
})
.then((response) => {

View File

@ -29,7 +29,7 @@
fetch("api/v2/rss/removeItem", {
method: "POST",
body: new URLSearchParams({
"path": decodeURIComponent(path)
path: decodeURIComponent(path)
})
})
.then((response) => {

View File

@ -30,7 +30,7 @@
fetch("api/v2/rss/removeRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": decodeURIComponent(rule)
ruleName: decodeURIComponent(rule)
})
})
.then((response) => {

View File

@ -28,8 +28,8 @@
fetch("api/v2/torrents/removeTrackers", {
method: "POST",
body: new URLSearchParams({
"hash": "*",
"urls": urls
hash: "*",
urls: urls
})
})
.then((response) => {

View File

@ -53,7 +53,7 @@
fetch("api/v2/transfer/setDownloadLimit", {
method: "POST",
body: new URLSearchParams({
"limit": limit
limit: limit
})
})
.then(async (response) => {
@ -68,8 +68,8 @@
fetch("api/v2/torrents/setDownloadLimit", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|"),
"limit": limit
hashes: hashes.join("|"),
limit: limit
})
})
.then(async (response) => {

View File

@ -54,8 +54,8 @@
fetch("api/v2/rss/setFeedURL", {
method: "POST",
body: new URLSearchParams({
"path": new URI().getData("path"),
"url": newUrl
path: new URI().getData("path"),
url: newUrl
})
})
.then(async (response) => {

View File

@ -40,9 +40,9 @@
fetch("api/v2/torrents/editTracker", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"origUrl": currentUrl,
"newUrl": $("trackerUrl").value
hash: new URI().getData("hash"),
origUrl: currentUrl,
newUrl: $("trackerUrl").value
})
})
.then((response) => {

View File

@ -36,9 +36,9 @@
fetch("api/v2/torrents/editWebSeed", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"origUrl": origUrl,
"newUrl": encodeURIComponent($("url").value.trim())
hash: new URI().getData("hash"),
origUrl: origUrl,
newUrl: encodeURIComponent($("url").value.trim())
})
})
.then((response) => {

View File

@ -75,8 +75,8 @@
fetch("api/v2/torrents/createCategory", {
method: "POST",
body: new URLSearchParams({
"category": categoryName,
"savePath": savePath
category: categoryName,
savePath: savePath
})
})
.then((response) => {
@ -88,8 +88,8 @@
fetch("api/v2/torrents/setCategory", {
method: "POST",
body: new URLSearchParams({
"hashes": uriHashes,
"category": categoryName
hashes: uriHashes,
category: categoryName
})
})
.then((response) => {
@ -111,8 +111,8 @@
fetch("api/v2/torrents/createCategory", {
method: "POST",
body: new URLSearchParams({
"category": categoryName,
"savePath": savePath
category: categoryName,
savePath: savePath
})
})
.then((response) => {
@ -130,8 +130,8 @@
fetch("api/v2/torrents/editCategory", {
method: "POST",
body: new URLSearchParams({
"category": uriCategoryName, // category name can't be changed
"savePath": savePath
category: uriCategoryName, // category name can't be changed
savePath: savePath
})
})
.then((response) => {

View File

@ -45,8 +45,8 @@
fetch("api/v2/rss/addFeed", {
method: "POST",
body: new URLSearchParams({
"url": feedURL,
"path": path ? (path + "\\" + feedURL) : ""
url: feedURL,
path: path ? (path + "\\" + feedURL) : ""
})
})
.then(async (response) => {

View File

@ -46,7 +46,7 @@
fetch("api/v2/rss/addFolder", {
method: "POST",
body: new URLSearchParams({
"path": path ? (path + "\\" + folderName) : folderName
path: path ? (path + "\\" + folderName) : folderName
})
})
.then(async (response) => {

View File

@ -43,8 +43,8 @@
fetch("api/v2/rss/setRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": name,
"ruleDef": "{}"
ruleName: name,
ruleDef: "{}"
})
})
.then((response) => {

View File

@ -59,8 +59,8 @@
fetch("api/v2/torrents/addTags", {
method: "POST",
body: new URLSearchParams({
"hashes": uriHashes,
"tags": tagName
hashes: uriHashes,
tags: tagName
})
})
.then(async (response) => {
@ -78,7 +78,7 @@
fetch("api/v2/torrents/createTags", {
method: "POST",
body: new URLSearchParams({
"tags": tagName
tags: tagName
})
})
.then(async (response) => {

View File

@ -47,8 +47,8 @@
fetch("api/v2/torrents/rename", {
method: "POST",
body: new URLSearchParams({
"hash": hash,
"name": name
hash: hash,
name: name
})
})
.then((response) => {

View File

@ -54,8 +54,8 @@
fetch("api/v2/rss/moveItem", {
method: "POST",
body: new URLSearchParams({
"itemPath": oldPath,
"destPath": newPath
itemPath: oldPath,
destPath: newPath
})
})
.then(async (response) => {

View File

@ -63,9 +63,9 @@
fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
method: "POST",
body: new URLSearchParams({
"hash": hash,
"oldPath": oldPath,
"newPath": newPath
hash: hash,
oldPath: oldPath,
newPath: newPath
})
})
.then((response) => {

View File

@ -64,11 +64,11 @@
new Keyboard({
defaultEventType: "keydown",
events: {
"Escape": function(event) {
Escape: (event) => {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
},
"Esc": function(event) {
Esc: (event) => {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
}

View File

@ -54,8 +54,8 @@
fetch("api/v2/rss/renameRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": oldName,
"newRuleName": newName
ruleName: oldName,
newRuleName: newName
})
})
.then((response) => {

View File

@ -121,7 +121,7 @@ window.qBittorrent.Cache ??= (() => {
fetch("api/v2/app/setPreferences", {
method: "POST",
body: new URLSearchParams({
"json": JSON.stringify(obj.data)
json: JSON.stringify(obj.data)
})
})
.then(async (response) => {

View File

@ -724,25 +724,25 @@ window.addEventListener("DOMContentLoaded", () => {
};
const statusSortOrder = Object.freeze({
"unknown": -1,
"forcedDL": 0,
"downloading": 1,
"forcedMetaDL": 2,
"metaDL": 3,
"stalledDL": 4,
"forcedUP": 5,
"uploading": 6,
"stalledUP": 7,
"checkingResumeData": 8,
"queuedDL": 9,
"queuedUP": 10,
"checkingUP": 11,
"checkingDL": 12,
"stoppedDL": 13,
"stoppedUP": 14,
"moving": 15,
"missingFiles": 16,
"error": 17
unknown: -1,
forcedDL: 0,
downloading: 1,
forcedMetaDL: 2,
metaDL: 3,
stalledDL: 4,
forcedUP: 5,
uploading: 6,
stalledUP: 7,
checkingResumeData: 8,
queuedDL: 9,
queuedUP: 10,
checkingUP: 11,
checkingDL: 12,
stoppedDL: 13,
stoppedUP: 14,
moving: 15,
missingFiles: 16,
error: 17
});
let syncMainDataTimeoutID = -1;

View File

@ -64,7 +64,7 @@ window.qBittorrent.DynamicTable ??= (() => {
};
let DynamicTableHeaderContextMenuClass = null;
let ProgressColumnWidth = -1;
let progressColumnWidth = -1;
const DynamicTable = new Class({
@ -772,8 +772,8 @@ window.qBittorrent.DynamicTable ??= (() => {
if (!this.rows.has(rowId)) {
row = {
"full_data": {},
"rowId": rowId
full_data: {},
rowId: rowId
};
this.rows.set(rowId, row);
}
@ -1231,16 +1231,16 @@ window.qBittorrent.DynamicTable ??= (() => {
const div = td.getChildren("div")[0];
if (td.resized) {
td.resized = false;
div.setWidth(ProgressColumnWidth - 5);
div.setWidth(progressColumnWidth - 5);
}
if (div.getValue() !== progressFormatted)
div.setValue(progressFormatted);
}
else {
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
if (progressColumnWidth < 0)
progressColumnWidth = td.offsetWidth;
td.append(new window.qBittorrent.ProgressBar.ProgressBar(progressFormatted.toFloat(), {
"width": ProgressColumnWidth - 5
width: progressColumnWidth - 5
}));
td.resized = false;
}
@ -1249,11 +1249,11 @@ window.qBittorrent.DynamicTable ??= (() => {
this.columns["progress"].onResize = function(columnName) {
const pos = this.getColumnPos(columnName);
const trs = this.tableBody.getElements("tr");
ProgressColumnWidth = -1;
progressColumnWidth = -1;
for (let i = 0; i < trs.length; ++i) {
const td = trs[i].getElements("td")[pos];
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
if (progressColumnWidth < 0)
progressColumnWidth = td.offsetWidth;
td.resized = true;
this.columns[columnName].updateTd(td, this.rows.get(trs[i].rowId));
}
@ -3265,7 +3265,7 @@ window.qBittorrent.DynamicTable ??= (() => {
initColumnsFunctions: function() {
this.columns["timestamp"].updateTd = function(td, row) {
const date = new Date(this.getRowValue(row) * 1000).toLocaleString();
td.set({ "text": date, "title": date });
td.set({ text: date, title: date });
};
this.columns["type"].updateTd = function(td, row) {
@ -3293,7 +3293,7 @@ window.qBittorrent.DynamicTable ??= (() => {
addClass = "logUnknown";
break;
}
td.set({ "text": logLevel, "title": logLevel });
td.set({ text: logLevel, title: logLevel });
td.closest("tr").className = `logTableRow${addClass}`;
};
},
@ -3340,7 +3340,7 @@ window.qBittorrent.DynamicTable ??= (() => {
this.columns["timestamp"].updateTd = function(td, row) {
const date = new Date(this.getRowValue(row) * 1000).toLocaleString();
td.set({ "text": date, "title": date });
td.set({ text: date, title: date });
};
this.columns["blocked"].updateTd = function(td, row) {
@ -3353,7 +3353,7 @@ window.qBittorrent.DynamicTable ??= (() => {
status = "QBT_TR(Banned)QBT_TR[CONTEXT=ExecutionLogWidget]";
addClass = "peerBanned";
}
td.set({ "text": status, "title": status });
td.set({ text: status, title: status });
td.closest("tr").className = `logTableRow${addClass}`;
};
},

View File

@ -41,18 +41,18 @@ window.qBittorrent.FileTree ??= (() => {
};
const FilePriority = {
"Ignored": 0,
"Normal": 1,
"High": 6,
"Maximum": 7,
"Mixed": -1
Ignored: 0,
Normal: 1,
High: 6,
Maximum: 7,
Mixed: -1
};
Object.freeze(FilePriority);
const TriState = {
"Unchecked": 0,
"Checked": 1,
"Partial": 2
Unchecked: 0,
Checked: 1,
Partial: 2
};
Object.freeze(TriState);

View File

@ -600,7 +600,7 @@ const initializeWindows = () => {
url: "api/v2/torrents/recheck",
method: "post",
data: {
"hashes": hashes.join("|"),
hashes: hashes.join("|"),
},
onSuccess: () => {
updateMainData();
@ -694,7 +694,7 @@ const initializeWindows = () => {
paddingHorizontal: 0,
width: 800,
height: 420,
resizeLimit: { "x": [800], "y": [420] }
resizeLimit: { x: [800], y: [420] }
});
}
}

View File

@ -48,13 +48,13 @@ window.qBittorrent.PiecesBar ??= (() => {
const PiecesBar = new Class({
initialize: (pieces, parameters) => {
const vals = {
"id": "piecesbar_" + (piecesBarUniqueId++),
"width": 0,
"height": 0,
"downloadingColor": "hsl(110deg 94% 27%)", // @TODO palette vars not supported for this value, apply average
"haveColor": "hsl(210deg 55% 55%)", // @TODO palette vars not supported for this value, apply average
"borderSize": 1,
"borderColor": "var(--color-border-default)"
id: "piecesbar_" + (piecesBarUniqueId++),
width: 0,
height: 0,
downloadingColor: "hsl(110deg 94% 27%)", // @TODO palette vars not supported for this value, apply average
haveColor: "hsl(210deg 55% 55%)", // @TODO palette vars not supported for this value, apply average
borderSize: 1,
borderColor: "var(--color-border-default)"
};
if (parameters && (typeOf(parameters) === "object"))

View File

@ -36,18 +36,18 @@ window.qBittorrent.ProgressBar ??= (() => {
};
};
let ProgressBars = 0;
let progressBars = 0;
const ProgressBar = new Class({
initialize: (value, parameters) => {
const vals = {
"id": "progressbar_" + (ProgressBars++),
"value": [value, 0].pick(),
"width": 0,
"height": 0,
"darkbg": "var(--color-background-blue)",
"darkfg": "var(--color-text-white)",
"lightbg": "var(--color-background-default)",
"lightfg": "var(--color-text-default)"
id: "progressbar_" + (progressBars++),
value: [value, 0].pick(),
width: 0,
height: 0,
darkbg: "var(--color-background-blue)",
darkfg: "var(--color-text-white)",
lightbg: "var(--color-background-default)",
lightfg: "var(--color-text-default)"
};
if (parameters && (typeOf(parameters) === "object"))
Object.append(vals, parameters);

View File

@ -311,9 +311,9 @@ window.qBittorrent.PropFiles ??= (() => {
fetch("api/v2/torrents/filePrio", {
method: "POST",
body: new URLSearchParams({
"hash": current_hash,
"id": fileIds.join("|"),
"priority": priority
hash: current_hash,
id: fileIds.join("|"),
priority: priority
})
})
.then((response) => {
@ -580,7 +580,7 @@ window.qBittorrent.PropFiles ??= (() => {
paddingHorizontal: 0,
width: 800,
height: 420,
resizeLimit: { "x": [800], "y": [420] }
resizeLimit: { x: [800], y: [420] }
});
};

View File

@ -154,8 +154,8 @@ window.qBittorrent.PropPeers ??= (() => {
fetch("api/v2/transfer/banPeers", {
method: "POST",
body: new URLSearchParams({
"hash": torrentsTable.getCurrentTorrentID(),
"peers": selectedPeers.join("|")
hash: torrentsTable.getCurrentTorrentID(),
peers: selectedPeers.join("|")
})
});
}

View File

@ -10,9 +10,9 @@ window.qBittorrent.MultiRename ??= (() => {
};
const AppliesTo = {
"FilenameExtension": "FilenameExtension",
"Filename": "Filename",
"Extension": "Extension"
FilenameExtension: "FilenameExtension",
Filename: "Filename",
Extension: "Extension"
};
const RenameFiles = new Class({

View File

@ -90,7 +90,7 @@ MochaUI.extend({
fetch("api/v2/torrents/uploadLimit", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|")
hashes: hashes.join("|")
})
})
.then(async (response) => {
@ -199,7 +199,7 @@ MochaUI.extend({
fetch("api/v2/torrents/downloadLimit", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|")
hashes: hashes.join("|")
})
})
.then(async (response) => {

View File

@ -48,8 +48,8 @@
fetch("api/v2/torrents/setLocation", {
method: "POST",
body: new URLSearchParams({
"hashes": new URI().getData("hashes"),
"location": location
hashes: new URI().getData("hashes"),
location: location
})
})
.then(async (response) => {

View File

@ -103,10 +103,10 @@
fetch("api/v2/torrents/setShareLimits", {
method: "POST",
body: new URLSearchParams({
"hashes": hashesList.join("|"),
"ratioLimit": ratioLimitValue,
"seedingTimeLimit": seedingTimeLimitValue,
"inactiveSeedingTimeLimit": inactiveSeedingTimeLimitValue
hashes: hashesList.join("|"),
ratioLimit: ratioLimitValue,
seedingTimeLimit: seedingTimeLimitValue,
inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue
})
})
.then(async (response) => {

View File

@ -53,7 +53,7 @@
fetch("api/v2/transfer/setUploadLimit", {
method: "POST",
body: new URLSearchParams({
"limit": limit
limit: limit
})
})
.then((response) => {
@ -68,8 +68,8 @@
fetch("api/v2/torrents/setUploadLimit", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|"),
"limit": limit
hashes: hashes.join("|"),
limit: limit
})
})
.then((response) => {

View File

@ -29,8 +29,8 @@
fetch("api/v2/torrents/setAutoManagement", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|"),
"enable": enable
hashes: hashes.join("|"),
enable: enable
})
})
.then((response) => {

View File

@ -31,7 +31,7 @@
fetch("api/v2/torrents/recheck", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|")
hashes: hashes.join("|")
})
})
.then((response) => {

View File

@ -59,7 +59,7 @@
rememberButton.addEventListener("click", (e) => {
window.qBittorrent.Cache.preferences.set({
data: {
"delete_torrent_content_files": deleteCB.checked
delete_torrent_content_files: deleteCB.checked
},
onSuccess: () => {
prefDeleteContentFiles = deleteCB.checked;
@ -80,8 +80,8 @@
fetch("api/v2/torrents/delete", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|"),
"deleteFiles": deleteCB.checked
hashes: hashes.join("|"),
deleteFiles: deleteCB.checked
})
})
.then((response) => {

View File

@ -2112,7 +2112,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
method: "get",
noCache: true,
data: {
"iface": iface
iface: iface
},
onFailure: () => {
alert("Could not contact qBittorrent");

View File

@ -883,8 +883,8 @@
saveWindowSize(id);
}),
resizeLimit: {
"x": [800, 2500],
"y": [500, 2000]
x: [800, 2500],
y: [500, 2000]
}
});
};

View File

@ -40,8 +40,8 @@ const submitLoginForm = (event) => {
fetch("api/v2/auth/login", {
method: "POST",
body: new URLSearchParams({
"username": usernameElement.value,
"password": passwordElement.value
username: usernameElement.value,
password: passwordElement.value
})
})
.then(async (response) => {