Skip to content

Commit 9e8a456

Browse files
committed
fix: linting errors (2)
1 parent 70bbbc8 commit 9e8a456

File tree

22 files changed

+139
-140
lines changed

22 files changed

+139
-140
lines changed

src/ace/commands.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ const commands = [
287287
exec(editor) {
288288
const size = Number.parseInt(editor.getFontSize(), 10) || 12;
289289
editor.setFontSize(size + 1);
290-
settings.value.fontSize = size + 1 + "px";
290+
settings.value.fontSize = `${size + 1}px`;
291291
settings.update(false);
292292
},
293293
},
@@ -297,7 +297,7 @@ const commands = [
297297
exec(editor) {
298298
const size = Number.parseInt(editor.getFontSize(), 10) || 12;
299299
editor.setFontSize(Math.max(size - 1 || 1));
300-
settings.value.fontSize = Math.max(size - 1 || 1) + "px";
300+
settings.value.fontSize = `${Math.max(size - 1 || 1)}px`;
301301
settings.update(false);
302302
},
303303
},
@@ -344,9 +344,9 @@ const commands = [
344344
];
345345

346346
export function setCommands(editor) {
347-
commands.forEach((command) => {
347+
for (const command of commands) {
348348
editor.commands.addCommand(command);
349-
});
349+
}
350350
}
351351

352352
/**
@@ -368,7 +368,7 @@ export async function setKeyBindings({ commands }) {
368368
await resetKeyBindings();
369369
}
370370

371-
Object.keys(commands.byName).forEach((name) => {
371+
for (const name of Object.keys(commands.byName)) {
372372
const shortcut = keyboardShortcuts[name];
373373
const command = commands.byName[name];
374374

@@ -379,7 +379,7 @@ export async function setKeyBindings({ commands }) {
379379
// not chekiang if shortcut is empty because it can be used to remove shortcut
380380
command.bindKey = { win: shortcut?.key ?? null };
381381
commands.addCommand(command);
382-
});
382+
}
383383
}
384384

385385
/**

src/ace/supportedModes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ const languageNames = {
211211
AutoHotKey: "AutoHotkey/AutoIt",
212212
};
213213

214-
Object.keys(modeList).forEach((key) => {
214+
for (const key of Object.keys(modeList)) {
215215
const extensions = modeList[key];
216216
const caption = languageNames[key];
217217

218218
addMode(key, extensions, caption);
219-
});
219+
}

src/components/WebComponents/wcPage.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ export default class WCPage extends HTMLElement {
3434
this.onwilldisconnect();
3535
}
3636

37-
this.#on.willdisconnect.forEach((cb) => cb.call(this));
37+
for (const cb of this.#on.willdisconnect) cb.call(this);
3838
};
3939

4040
this.handler.onRestore = () => {
4141
if (typeof this.onwillconnect === "function") {
4242
this.onwillconnect();
4343
}
4444

45-
this.#on.willconnect.forEach((cb) => cb.call(this));
45+
for (const cb of this.#on.willconnect) cb.call(this);
4646
};
4747

4848
this.#leadBtn = (
4949
<span
5050
className="icon arrow_back"
5151
onclick={() => this.hide.call(this)}
5252
attr-action="go-back"
53-
></span>
53+
/>
5454
);
5555

5656
this.#header = tile({
@@ -81,12 +81,12 @@ export default class WCPage extends HTMLElement {
8181
connectedCallback() {
8282
this.classList.remove("hide");
8383
if (typeof this.onconnect === "function") this.onconnect();
84-
this.#on.show.forEach((cb) => cb.call(this));
84+
for (const cb of this.#on.show) cb.call(this);
8585
}
8686

8787
disconnectedCallback() {
8888
if (typeof this.ondisconnect === "function") this.ondisconnect();
89-
this.#on.hide.forEach((cb) => cb.call(this));
89+
for (const cb of this.#on.hide) cb.call(this);
9090
}
9191

9292
/**
@@ -187,7 +187,7 @@ export default class WCPage extends HTMLElement {
187187
#addHeaderOrAssignHeader() {
188188
if (!this.classList.contains("primary")) {
189189
this.#append(this.#header);
190-
this.#append(<div className="main"></div>);
190+
this.#append(<div className="main" />);
191191
} else {
192192
this.#header = this.get("header");
193193
if (this.#header) {
@@ -213,7 +213,7 @@ class PageHandler {
213213
this.onhide = this.onhide.bind(this);
214214
this.onshow = this.onshow.bind(this);
215215

216-
this.$replacement = <span className="page-replacement"></span>;
216+
this.$replacement = <span className="page-replacement" />;
217217
this.$replacement.handler = this;
218218

219219
this.$el.on("hide", this.onhide);

src/components/audioPlayer/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@ export default class AudioPlayer {
2525
const audioPlayer = (
2626
<div className="audio-player">
2727
<button
28+
type="button"
2829
ref={this.elements.playBtn}
2930
className="play-btn"
3031
ariaLabel="Play/Pause"
3132
>
32-
<span ref={this.elements.playIcon} className="icon play_arrow"></span>
33+
<span ref={this.elements.playIcon} className="icon play_arrow" />
3334
</button>
3435

3536
<div ref={this.elements.timeline} className="timeline">
36-
<div ref={this.elements.progress} className="progress"></div>
37-
<div
38-
ref={this.elements.progressHandle}
39-
className="progress-handle"
40-
></div>
37+
<div ref={this.elements.progress} className="progress" />
38+
<div ref={this.elements.progressHandle} className="progress-handle" />
4139
</div>
4240

4341
<div ref={this.elements.timeDisplay} className="time">
@@ -46,10 +44,11 @@ export default class AudioPlayer {
4644

4745
<div className="volume-control">
4846
<button
47+
type="button"
4948
ref={this.elements.volumeBtn}
5049
className="volume-btn"
5150
ariaLabel="Volume"
52-
></button>
51+
/>
5352
</div>
5453
</div>
5554
);

src/components/checkbox/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Checkbox(text, checked, name, id, type, ref, size) {
4040
name={name}
4141
id={id}
4242
/>
43-
<span style={{ height: size, width: size }} className="box"></span>
43+
<span style={{ height: size, width: size }} className="box" />
4444
<span>{text}</span>
4545
</label>
4646
);

src/components/contextmenu/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ export default function Contextmenu(content, options) {
6767
});
6868

6969
if (Array.isArray(options.items)) {
70-
options.items.forEach(([text, action]) => {
70+
for (const [text, action] of options.items) {
7171
$el.append(<li data-action={action}>{text}</li>);
72-
});
72+
}
7373
}
7474

7575
if (!options.innerHTML) addTabindex();
@@ -90,17 +90,17 @@ export default function Contextmenu(content, options) {
9090
if (options.toggler) {
9191
const client = options.toggler.getBoundingClientRect();
9292
if (!options.top && !options.bottom) {
93-
$el.style.top = client.top + "px";
93+
$el.style.top = `${client.top}px`;
9494
}
9595
if (!options.left && !options.right) {
96-
$el.style.right = innerWidth - client.right + "px";
96+
$el.style.right = `${innerWidth - client.right}px`;
9797
}
9898
}
9999

100100
app.append($el, $mask);
101101

102102
const $firstChild = $el.firstChild;
103-
if ($firstChild && $firstChild.focus) $firstChild.focus();
103+
if ($firstChild?.focus) $firstChild.focus();
104104
}
105105

106106
function hide() {

src/components/inputhints/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ export default function inputhints($input, hints, onSelect) {
140140
const { value: toTest } = this;
141141
const matched = [];
142142
const regexp = new RegExp(toTest, "i");
143-
hints.forEach((hint) => {
143+
for (const hint of hints) {
144144
const { value, text } = hint;
145145
if (regexp.test(value) || regexp.test(text)) {
146146
matched.push(hint);
147147
}
148-
});
148+
}
149149
updateUl(matched);
150150
}
151151

@@ -360,7 +360,7 @@ function Hint({ hint }) {
360360
text = hint.text;
361361
}
362362

363-
return <li attr-action="hint" attr-value={value} innerHTML={text}></li>;
363+
return <li attr-action="hint" attr-value={value} innerHTML={text} />;
364364
}
365365

366366
/**

src/components/quickTools/footer.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ export const SearchRow2 = ({ inputRef, posRef, totalRef }) => (
6565
);
6666

6767
/**@type {HTMLElement} */
68-
export const $footer = <footer id="quick-tools" tabIndex={-1}></footer>;
68+
export const $footer = <footer id="quick-tools" tabIndex={-1} />;
6969

7070
/**@type {HTMLElement} */
7171
export const $toggler = (
72-
<span
73-
className="floating icon keyboard_arrow_up"
74-
id="quicktools-toggler"
75-
></span>
72+
<span className="floating icon keyboard_arrow_up" id="quicktools-toggler" />
7673
);
7774

7875
/**@type {HTMLTextAreaElement} */
@@ -89,7 +86,7 @@ export const $input = (
8986
top: 0,
9087
left: 0,
9188
}}
92-
></textarea>
89+
/>
9390
);
9491

9592
/**
@@ -107,13 +104,14 @@ export const $input = (
107104
export function RowItem({ id, icon, letters, action, value, ref, repeat }) {
108105
const $item = (
109106
<button
107+
type="button"
110108
ref={ref}
111109
className={`icon ${icon}`}
112110
data-id={id}
113111
data-letters={letters}
114112
data-action={action}
115113
data-repeat={repeat}
116-
></button>
114+
/>
117115
);
118116

119117
if (typeof value === "function") {
@@ -132,16 +130,16 @@ export function RowItem({ id, icon, letters, action, value, ref, repeat }) {
132130
* @returns {Array<Element>}
133131
*/
134132
function Extras({ extras }) {
135-
const div = <div className="section"></div>;
133+
const div = <div className="section" />;
136134
if (Array.isArray(extras)) {
137-
extras.forEach((i) => {
135+
for (const i of extras) {
138136
if (i instanceof HTMLElement) {
139137
div.appendChild(i);
140138
return;
141139
}
142140

143141
div.append(<RowItem {...i} />);
144-
});
142+
}
145143
}
146144
return div;
147145
}

src/components/scrollbar/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ export default function ScrollBar(options) {
8989
}
9090

9191
function setWidth(width) {
92-
if (isVertical) $scrollbar.style.width = $cursor.style.width = width + "px";
93-
else $scrollbar.style.height = $cursor.style.height = width + "px";
92+
if (isVertical) $scrollbar.style.width = $cursor.style.width = `${width}px`;
93+
else $scrollbar.style.height = $cursor.style.height = `${width}px`;
9494
}
9595

9696
/**
@@ -132,7 +132,7 @@ export default function ScrollBar(options) {
132132
else if (top > height) top = height;
133133

134134
if (currentTopValue !== top) {
135-
$cursor.style.top = top + "px";
135+
$cursor.style.top = `${top}px`;
136136
scroll = top / height;
137137
if (typeof $scrollbar.onScroll === "function")
138138
$scrollbar.onScroll(scroll);
@@ -145,7 +145,7 @@ export default function ScrollBar(options) {
145145
else if (left > width) left = width;
146146

147147
if (currentLeftValue !== left) {
148-
$cursor.style.left = left + "px";
148+
$cursor.style.left = `${left}px`;
149149
scroll = left / width;
150150
if (typeof $scrollbar.onScroll === "function")
151151
$scrollbar.onScroll(scroll);
@@ -180,16 +180,15 @@ export default function ScrollBar(options) {
180180
if (render && height && width) setValue(scroll);
181181
}
182182

183-
function setValue(val) {
183+
function setValue(value) {
184184
if (!height || !width) resize(false);
185185

186186
//Make sure value is between 0 and 1
187-
if (val < 0) val = 0;
188-
else if (val > 1) val = 1;
187+
const boundedValue = Math.max(0, Math.min(1, value));
189188

190-
scroll = val;
191-
if (isVertical) $cursor.style.top = val * height + "px";
192-
else $cursor.style.left = val * width + "px";
189+
scroll = boundedValue;
190+
if (isVertical) $cursor.style.top = `${boundedValue * height}px`;
191+
else $cursor.style.left = `${boundedValue * width}px`;
193192
}
194193

195194
function destroy() {

src/components/searchbar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function searchBar($list, setHide, onhideCb, searchFunction) {
2222
placeholder={strings.search}
2323
enterKeyHint="go"
2424
/>
25-
<span className="icon clearclose" onclick={hide}></span>
25+
<span className="icon clearclose" onclick={hide} />
2626
</div>
2727
);
2828

0 commit comments

Comments
 (0)