aboutsummaryrefslogtreecommitdiff
path: root/notif
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-24 03:41:47 +0700
committerShulhan <ms@kilabit.info>2023-10-24 22:28:25 +0700
commit85c3fc0431e7e75a41894d4669f6a46bbda5440b (patch)
tree15b73a82e9eaaa9ac9f2558578c8d7610ad392cd /notif
parent891a860299ac76739d59f46280cbed63ff07743e (diff)
downloadpakakeh.ts-85c3fc0431e7e75a41894d4669f6a46bbda5440b.tar.xz
all: fix all linter warnings from tsc and eslint
In this changes we introduce eslint as our linter for TypeScript and update our tsconfig to be more strict. The ".eslintrc.yaml" and "tsconfig.json" is taken from golang/website repository [1]. [1]: https://cs.opensource.google/go/x/website
Diffstat (limited to 'notif')
-rw-r--r--notif/example.ts34
-rw-r--r--notif/notif.d.ts12
-rw-r--r--notif/notif.ts16
3 files changed, 31 insertions, 31 deletions
diff --git a/notif/example.ts b/notif/example.ts
index a15f986..b2ff5d7 100644
--- a/notif/example.ts
+++ b/notif/example.ts
@@ -18,42 +18,42 @@ function main() {
inputMsg.value = `Hello world, this is a notification with HTML format using <b>bold</b> and <u>underline</u> words.`;
document.body.appendChild(inputMsg);
- let el_wrapper = document.createElement("div");
- el_wrapper.style.marginTop = "10px";
- document.body.appendChild(el_wrapper);
+ const elWrapper = document.createElement("div");
+ elWrapper.style.marginTop = "10px";
+ document.body.appendChild(elWrapper);
- let el_button_info = document.createElement("button");
- el_button_info.innerText = "Info";
- el_button_info.style.marginRight = "10px";
- el_button_info.onclick = notifInfo;
- el_wrapper.appendChild(el_button_info);
+ const elButtonInfo = document.createElement("button");
+ elButtonInfo.innerText = "Info";
+ elButtonInfo.style.marginRight = "10px";
+ elButtonInfo.onclick = notifInfo;
+ elWrapper.appendChild(elButtonInfo);
- let el_button_error = document.createElement("button");
- el_button_error.innerText = "Error";
- el_button_error.onclick = notifError;
- el_wrapper.appendChild(el_button_error);
+ const elButtonError = document.createElement("button");
+ elButtonError.innerText = "Error";
+ elButtonError.onclick = notifError;
+ elWrapper.appendChild(elButtonError);
document.body.appendChild(document.createElement("p"));
- let previewError = document.createElement("div");
+ const previewError = document.createElement("div");
previewError.classList.add(`${WUI_NOTIF_CLASS_ERROR}`);
previewError.innerText = `Preview of error style`;
document.body.appendChild(previewError);
- let previewInfo = document.createElement("div");
+ const previewInfo = document.createElement("div");
previewInfo.classList.add(`${WUI_NOTIF_CLASS_INFO}`);
previewInfo.innerText = `Preview of info style`;
document.body.appendChild(previewInfo);
}
function notifInfo() {
- wuiNotif.Info(inputMsg.value);
+ wuiNotif.info(inputMsg.value);
}
function notifError() {
- wuiNotif.Error(inputMsg.value);
+ wuiNotif.error(inputMsg.value);
}
-//----
+// ----
main();
diff --git a/notif/notif.d.ts b/notif/notif.d.ts
index ae2c331..0f90919 100644
--- a/notif/notif.d.ts
+++ b/notif/notif.d.ts
@@ -2,10 +2,10 @@ export declare const WUI_NOTIF_ID = "wui_notif";
export declare const WUI_NOTIF_CLASS_INFO = "wui_notif_info";
export declare const WUI_NOTIF_CLASS_ERROR = "wui_notif_error";
export declare class WuiNotif {
- private el;
- private timeout;
- constructor();
- Info(msg: string): void;
- Error(msg: string): void;
- private initStyle;
+ private el;
+ private timeout;
+ constructor();
+ Info(msg: string): void;
+ Error(msg: string): void;
+ private initStyle;
}
diff --git a/notif/notif.ts b/notif/notif.ts
index 8bc5d84..23933ab 100644
--- a/notif/notif.ts
+++ b/notif/notif.ts
@@ -6,7 +6,7 @@ export const WUI_NOTIF_CLASS_INFO = "wui_notif_info";
export const WUI_NOTIF_CLASS_ERROR = "wui_notif_error";
// WuiNotif implement the HTML interface to display pop-up notification.
-// The notification can be triggered by calling method Info() or Error().
+// The notification can be triggered by calling method info() or error().
// Each pop-up has 5 seconds duration, after that they will be removed
// automatically.
export class WuiNotif {
@@ -22,9 +22,9 @@ export class WuiNotif {
this.initStyle();
}
- // Info show the msg as information.
- Info(msg: string) {
- let item = document.createElement("div");
+ // info show the msg as information.
+ info(msg: string) {
+ const item = document.createElement("div");
item.innerHTML = msg;
item.classList.add(WUI_NOTIF_CLASS_INFO);
this.el.appendChild(item);
@@ -34,9 +34,9 @@ export class WuiNotif {
}, this.timeout);
}
- // Info show the msg as an error.
- Error(msg: string) {
- let item = document.createElement("div");
+ // error show the msg as an error.
+ error(msg: string) {
+ const item = document.createElement("div");
item.innerHTML = msg;
item.classList.add(WUI_NOTIF_CLASS_ERROR);
this.el.appendChild(item);
@@ -47,7 +47,7 @@ export class WuiNotif {
}
private initStyle() {
- let style = document.createElement("style");
+ const style = document.createElement("style");
style.type = "text/css";
style.innerText = `
#${WUI_NOTIF_ID} {