fix(eslint): enable no-restricted-globals and fix ts/no-unused-expressions
This commit is contained in:
parent
cd946d31dd
commit
66143e2e21
@ -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",
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ async function onMainWindowLoad(win: Window): Promise<void> {
|
||||
|
||||
PromptExampleFactory.registerNormalCommandExample();
|
||||
|
||||
PromptExampleFactory.registerAnonymousCommandExample();
|
||||
PromptExampleFactory.registerAnonymousCommandExample(win);
|
||||
|
||||
PromptExampleFactory.registerConditionalCommandExample();
|
||||
|
||||
|
@ -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}.`,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user