fix(eslint): enable no-restricted-globals and fix ts/no-unused-expressions

This commit is contained in:
Northword 2024-09-24 20:18:45 +08:00
parent cd946d31dd
commit 66143e2e21
3 changed files with 13 additions and 5 deletions

View File

@ -10,6 +10,14 @@ export default tseslint.config(
{
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
rules: {
"no-restricted-globals": [
"error",
"window",
"document",
"ZoteroPane",
"Zotero_Tabs",
],
"@typescript-eslint/ban-ts-comment": [
"warn",
{

View File

@ -72,7 +72,7 @@ async function onMainWindowLoad(win: Window): Promise<void> {
PromptExampleFactory.registerNormalCommandExample();
PromptExampleFactory.registerAnonymousCommandExample();
PromptExampleFactory.registerAnonymousCommandExample(win);
PromptExampleFactory.registerConditionalCommandExample();

View File

@ -346,7 +346,7 @@ export class PromptExampleFactory {
}
@example
static registerAnonymousCommandExample() {
static registerAnonymousCommandExample(window: Window) {
ztoolkit.Prompt.register([
{
id: "search",
@ -411,7 +411,7 @@ export class PromptExampleFactory {
str += node;
}
}
str.length && (str += ".");
if (str.length) str += ".";
return str;
}
function filter(ids: number[]) {
@ -482,7 +482,7 @@ export class PromptExampleFactory {
ids.forEach((id: number) => {
const item = Zotero.Items.get(id);
const title = item.getField("title");
const ele = ztoolkit.UI.createElement(document, "div", {
const ele = ztoolkit.UI.createElement(window.document, "div", {
namespace: "html",
classList: ["command"],
listeners: [
@ -795,7 +795,7 @@ export class HelperExampleFactory {
addon.data.dialog = dialogHelper;
await dialogData.unloadLock.promise;
addon.data.dialog = undefined;
addon.data.alive &&
if (addon.data.alive)
ztoolkit.getGlobal("alert")(
`Close dialog with ${dialogData._lastButtonId}.\nCheckbox: ${dialogData.checkboxValue}\nInput: ${dialogData.inputValue}.`,
);