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],
|
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
|
||||||
rules: {
|
rules: {
|
||||||
|
"no-restricted-globals": [
|
||||||
|
"error",
|
||||||
|
"window",
|
||||||
|
"document",
|
||||||
|
"ZoteroPane",
|
||||||
|
"Zotero_Tabs",
|
||||||
|
],
|
||||||
|
|
||||||
"@typescript-eslint/ban-ts-comment": [
|
"@typescript-eslint/ban-ts-comment": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ async function onMainWindowLoad(win: Window): Promise<void> {
|
|||||||
|
|
||||||
PromptExampleFactory.registerNormalCommandExample();
|
PromptExampleFactory.registerNormalCommandExample();
|
||||||
|
|
||||||
PromptExampleFactory.registerAnonymousCommandExample();
|
PromptExampleFactory.registerAnonymousCommandExample(win);
|
||||||
|
|
||||||
PromptExampleFactory.registerConditionalCommandExample();
|
PromptExampleFactory.registerConditionalCommandExample();
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ export class PromptExampleFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static registerAnonymousCommandExample() {
|
static registerAnonymousCommandExample(window: Window) {
|
||||||
ztoolkit.Prompt.register([
|
ztoolkit.Prompt.register([
|
||||||
{
|
{
|
||||||
id: "search",
|
id: "search",
|
||||||
@ -411,7 +411,7 @@ export class PromptExampleFactory {
|
|||||||
str += node;
|
str += node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str.length && (str += ".");
|
if (str.length) str += ".";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
function filter(ids: number[]) {
|
function filter(ids: number[]) {
|
||||||
@ -482,7 +482,7 @@ export class PromptExampleFactory {
|
|||||||
ids.forEach((id: number) => {
|
ids.forEach((id: number) => {
|
||||||
const item = Zotero.Items.get(id);
|
const item = Zotero.Items.get(id);
|
||||||
const title = item.getField("title");
|
const title = item.getField("title");
|
||||||
const ele = ztoolkit.UI.createElement(document, "div", {
|
const ele = ztoolkit.UI.createElement(window.document, "div", {
|
||||||
namespace: "html",
|
namespace: "html",
|
||||||
classList: ["command"],
|
classList: ["command"],
|
||||||
listeners: [
|
listeners: [
|
||||||
@ -795,7 +795,7 @@ export class HelperExampleFactory {
|
|||||||
addon.data.dialog = dialogHelper;
|
addon.data.dialog = dialogHelper;
|
||||||
await dialogData.unloadLock.promise;
|
await dialogData.unloadLock.promise;
|
||||||
addon.data.dialog = undefined;
|
addon.data.dialog = undefined;
|
||||||
addon.data.alive &&
|
if (addon.data.alive)
|
||||||
ztoolkit.getGlobal("alert")(
|
ztoolkit.getGlobal("alert")(
|
||||||
`Close dialog with ${dialogData._lastButtonId}.\nCheckbox: ${dialogData.checkboxValue}\nInput: ${dialogData.inputValue}.`,
|
`Close dialog with ${dialogData._lastButtonId}.\nCheckbox: ${dialogData.checkboxValue}\nInput: ${dialogData.inputValue}.`,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user