fix: eslint errors

This commit is contained in:
windingwind 2023-06-20 11:52:27 +08:00
parent 1121dc5d6c
commit f22a071042

View File

@ -294,6 +294,7 @@ export class UIExampleFactory {
static async registerCustomCellRenderer() { static async registerCustomCellRenderer() {
await ztoolkit.ItemTree.addRenderCellHook( await ztoolkit.ItemTree.addRenderCellHook(
"title", "title",
// eslint-disable-next-line @typescript-eslint/ban-types
(index: number, data: string, column: any, original: Function) => { (index: number, data: string, column: any, original: Function) => {
const span = original(index, data, column) as HTMLSpanElement; const span = original(index, data, column) as HTMLSpanElement;
span.style.background = "rgb(30, 30, 30)"; span.style.background = "rgb(30, 30, 30)";
@ -483,21 +484,21 @@ export class PromptExampleFactory {
callback: async (prompt) => { callback: async (prompt) => {
// https://github.com/zotero/zotero/blob/7262465109c21919b56a7ab214f7c7a8e1e63909/chrome/content/zotero/integration/quickFormat.js#L589 // https://github.com/zotero/zotero/blob/7262465109c21919b56a7ab214f7c7a8e1e63909/chrome/content/zotero/integration/quickFormat.js#L589
function getItemDescription(item: Zotero.Item) { function getItemDescription(item: Zotero.Item) {
var nodes = []; const nodes = [];
var str = ""; let str = "";
var author, let author,
authorDate = ""; authorDate = "";
if (item.firstCreator) { if (item.firstCreator) {
author = authorDate = item.firstCreator; author = authorDate = item.firstCreator;
} }
var date = item.getField("date", true, true) as string; let date = item.getField("date", true, true) as string;
if (date && (date = date.substr(0, 4)) !== "0000") { if (date && (date = date.substr(0, 4)) !== "0000") {
authorDate += " (" + parseInt(date) + ")"; authorDate += " (" + parseInt(date) + ")";
} }
authorDate = authorDate.trim(); authorDate = authorDate.trim();
if (authorDate) nodes.push(authorDate); if (authorDate) nodes.push(authorDate);
var publicationTitle = item.getField( const publicationTitle = item.getField(
"publicationTitle", "publicationTitle",
false, false,
true true
@ -505,34 +506,34 @@ export class PromptExampleFactory {
if (publicationTitle) { if (publicationTitle) {
nodes.push(`<i>${publicationTitle}</i>`); nodes.push(`<i>${publicationTitle}</i>`);
} }
var volumeIssue = item.getField("volume"); let volumeIssue = item.getField("volume");
var issue = item.getField("issue"); const issue = item.getField("issue");
if (issue) volumeIssue += "(" + issue + ")"; if (issue) volumeIssue += "(" + issue + ")";
if (volumeIssue) nodes.push(volumeIssue); if (volumeIssue) nodes.push(volumeIssue);
var publisherPlace = [], const publisherPlace = [];
field; let field;
if ((field = item.getField("publisher"))) if ((field = item.getField("publisher")))
publisherPlace.push(field); publisherPlace.push(field);
if ((field = item.getField("place"))) publisherPlace.push(field); if ((field = item.getField("place"))) publisherPlace.push(field);
if (publisherPlace.length) nodes.push(publisherPlace.join(": ")); if (publisherPlace.length) nodes.push(publisherPlace.join(": "));
var pages = item.getField("pages"); const pages = item.getField("pages");
if (pages) nodes.push(pages); if (pages) nodes.push(pages);
if (!nodes.length) { if (!nodes.length) {
var url = item.getField("url"); const url = item.getField("url");
if (url) nodes.push(url); if (url) nodes.push(url);
} }
// compile everything together // compile everything together
for (var i = 0, n = nodes.length; i < n; i++) { for (let i = 0, n = nodes.length; i < n; i++) {
var node = nodes[i]; const node = nodes[i];
if (i != 0) str += ", "; if (i != 0) str += ", ";
if (typeof node === "object") { if (typeof node === "object") {
var label = document.createElement("label"); const label = document.createElement("label");
label.setAttribute("value", str); label.setAttribute("value", str);
label.setAttribute("crop", "end"); label.setAttribute("crop", "end");
str = ""; str = "";
@ -578,12 +579,12 @@ export class PromptExampleFactory {
"beginsWith", "beginsWith",
]; ];
let hasValidCondition = false; let hasValidCondition = false;
let joinMode: string = "all"; let joinMode = "all";
if (/\s*\|\|\s*/.test(text)) { if (/\s*\|\|\s*/.test(text)) {
joinMode = "any"; joinMode = "any";
} }
text.split(/\s*(&&|\|\|)\s*/g).forEach((conditinString: string) => { text.split(/\s*(&&|\|\|)\s*/g).forEach((conditinString: string) => {
let conditions = conditinString.split(/\s+/g); const conditions = conditinString.split(/\s+/g);
if ( if (
conditions.length == 3 && conditions.length == 3 &&
operators.indexOf(conditions[1]) != -1 operators.indexOf(conditions[1]) != -1