Skip to content

Commit

Permalink
fix(eslint): enable no-restricted-globals and fix ts/no-unused-expres…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
northword committed Sep 24, 2024
1 parent cd946d3 commit 66143e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
{
Expand Down
2 changes: 1 addition & 1 deletion src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function onMainWindowLoad(win: Window): Promise<void> {

PromptExampleFactory.registerNormalCommandExample();

PromptExampleFactory.registerAnonymousCommandExample();
PromptExampleFactory.registerAnonymousCommandExample(win);

PromptExampleFactory.registerConditionalCommandExample();

Expand Down
8 changes: 4 additions & 4 deletions src/modules/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class PromptExampleFactory {
}

@example
static registerAnonymousCommandExample() {
static registerAnonymousCommandExample(window: Window) {
ztoolkit.Prompt.register([
{
id: "search",
Expand Down Expand Up @@ -411,7 +411,7 @@ export class PromptExampleFactory {
str += node;
}
}
str.length && (str += ".");
if (str.length) str += ".";
return str;
}
function filter(ids: number[]) {
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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}.`,
);
Expand Down

0 comments on commit 66143e2

Please sign in to comment.