From 85c3fc0431e7e75a41894d4669f6a46bbda5440b Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 24 Oct 2023 03:41:47 +0700 Subject: 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 --- input/checkboxes.ts | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'input/checkboxes.ts') diff --git a/input/checkboxes.ts b/input/checkboxes.ts index 72d3da8..7226a7d 100644 --- a/input/checkboxes.ts +++ b/input/checkboxes.ts @@ -59,7 +59,7 @@ const WUI_INPUT_CHECKBOXES_CLASS_LABEL = "wui_input_checkboxes_label"; // export class WuiInputCheckboxes { el: HTMLElement; - private el_label!: HTMLElement; + private elLabel!: HTMLElement; private el_fieldset!: HTMLFieldSetElement; private el_hint!: HTMLElement; private el_hint_toggler!: HTMLElement; @@ -85,41 +85,39 @@ export class WuiInputCheckboxes { } private generateLabel(wrapper: HTMLElement) { - this.el_label = document.createElement("label"); - this.el_label.classList.add(WUI_INPUT_CHECKBOXES_CLASS_LABEL); - this.el_label.innerHTML = `${this.opts.label} `; - wrapper.appendChild(this.el_label); + this.elLabel = document.createElement("label"); + this.elLabel.classList.add(WUI_INPUT_CHECKBOXES_CLASS_LABEL); + this.elLabel.innerHTML = `${this.opts.label} `; + wrapper.appendChild(this.elLabel); } private generateInput(wrapper: HTMLElement) { this.el_fieldset = document.createElement("fieldset"); this.el_fieldset.classList.add(WUI_INPUT_CHECKBOXES_CLASS_INPUT); - for (let key in this.opts.options) { - let option = this.opts.options[key]; - let value = option.value; + Object.entries(this.opts.options).forEach(([key, option]) => { + const value = option.value; + const wrapper = document.createElement("div"); - let wrapper = document.createElement("div"); - - let el_cb = document.createElement("input"); - el_cb.type = "checkbox"; - el_cb.name = this.opts.name; - el_cb.value = option.value; + const elCb = document.createElement("input"); + elCb.type = "checkbox"; + elCb.name = this.opts.name; + elCb.value = option.value; if (option.selected) { - el_cb.checked = true; + elCb.checked = true; this.values.push(value); } - el_cb.onclick = () => { - this.onClickCheckbox(el_cb.value, el_cb.checked); + elCb.onclick = () => { + this.onClickCheckbox(elCb.value, elCb.checked); }; - wrapper.appendChild(el_cb); + wrapper.appendChild(elCb); - let el_label = document.createElement("label"); - el_label.innerHTML = key; - wrapper.appendChild(el_label); + const elLabel = document.createElement("label"); + elLabel.innerHTML = key; + wrapper.appendChild(elLabel); this.el_fieldset.appendChild(wrapper); - } + }); if (this.opts.is_disabled) { this.el_fieldset.disabled = true; -- cgit v1.3