Skip to content

Commit 177373c

Browse files
committed
chore: run lint autofix
1 parent 7b10c9f commit 177373c

File tree

15 files changed

+215
-214
lines changed

15 files changed

+215
-214
lines changed

example/gauge/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ module.exports = {
88
ecmaFeatures: { jsx: true },
99
jsxPragma: "FSComponent",
1010
},
11-
}
11+
};
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { ComponentProps, DisplayComponent, FSComponent, Subject, VNode } from "@microsoft/msfs-sdk"
2-
import "./Dropdown.css"
1+
import { ComponentProps, DisplayComponent, FSComponent, Subject, VNode } from "@microsoft/msfs-sdk";
2+
import "./Dropdown.css";
33

44
export class Dropdown extends DisplayComponent<ComponentProps> {
5-
private readonly dropdownButtonRef = FSComponent.createRef<HTMLDivElement>()
6-
private readonly dropdownMenuRef = FSComponent.createRef<HTMLUListElement>()
5+
private readonly dropdownButtonRef = FSComponent.createRef<HTMLDivElement>();
6+
private readonly dropdownMenuRef = FSComponent.createRef<HTMLUListElement>();
77

8-
private readonly dropdownButtonText = Subject.create<string>("Select an item")
8+
private readonly dropdownButtonText = Subject.create<string>("Select an item");
99

10-
private navigationDataFormat: null | string = null
10+
private navigationDataFormat: null | string = null;
1111

1212
public render(): VNode {
1313
return (
@@ -17,50 +17,50 @@ export class Dropdown extends DisplayComponent<ComponentProps> {
1717
</div>
1818
<ul ref={this.dropdownMenuRef} class="dropdown-menu" />
1919
</div>
20-
)
20+
);
2121
}
2222

2323
public onAfterRender(node: VNode): void {
24-
super.onAfterRender(node)
24+
super.onAfterRender(node);
2525

26-
const dropdownButton = this.dropdownButtonRef.instance
27-
const dropdownMenu = this.dropdownMenuRef.instance
26+
const dropdownButton = this.dropdownButtonRef.instance;
27+
const dropdownMenu = this.dropdownMenuRef.instance;
2828

2929
dropdownButton.addEventListener("click", function () {
30-
dropdownMenu.style.display = dropdownMenu.style.display === "block" ? "none" : "block"
31-
})
30+
dropdownMenu.style.display = dropdownMenu.style.display === "block" ? "none" : "block";
31+
});
3232

3333
// Close the dropdown when clicking outside of it
34-
document.addEventListener("click", this.onDropdownItemClick.bind(this))
34+
document.addEventListener("click", this.onDropdownItemClick.bind(this));
3535
}
3636

3737
public onDropdownItemClick(event: Event): void {
38-
const dropdownButton = this.dropdownButtonRef.instance
39-
const dropdownMenu = this.dropdownMenuRef.instance
38+
const dropdownButton = this.dropdownButtonRef.instance;
39+
const dropdownMenu = this.dropdownMenuRef.instance;
4040

41-
const target = event.target as HTMLElement
41+
const target = event.target as HTMLElement;
4242
if (!target) {
43-
return
43+
return;
4444
}
4545
if (!dropdownMenu.contains(target) && !dropdownButton.contains(target)) {
46-
dropdownMenu.style.display = "none"
46+
dropdownMenu.style.display = "none";
4747
} else if (dropdownMenu.contains(target)) {
48-
this.dropdownButtonText.set(target.textContent as string)
49-
const navigationDataFormat = target.dataset.navigationDataFormat
48+
this.dropdownButtonText.set(target.textContent!);
49+
const navigationDataFormat = target.dataset.navigationDataFormat;
5050
if (navigationDataFormat) {
51-
this.navigationDataFormat = navigationDataFormat
51+
this.navigationDataFormat = navigationDataFormat;
5252
}
5353
}
5454
}
5555

5656
public addDropdownItem(text: string, format: string): void {
57-
const dropdownItem = document.createElement("li")
58-
dropdownItem.textContent = text
59-
dropdownItem.dataset.navigationDataFormat = format
60-
this.dropdownMenuRef.instance.appendChild(dropdownItem)
57+
const dropdownItem = document.createElement("li");
58+
dropdownItem.textContent = text;
59+
dropdownItem.dataset.navigationDataFormat = format;
60+
this.dropdownMenuRef.instance.appendChild(dropdownItem);
6161
}
6262

6363
public getNavigationDataFormat(): string | null {
64-
return this.navigationDataFormat
64+
return this.navigationDataFormat;
6565
}
6666
}

example/gauge/Components/Input.tsx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,82 @@ import {
66
SubscribableUtils,
77
UUID,
88
VNode,
9-
} from "@microsoft/msfs-sdk"
10-
import { InterfaceNavbarItemV2 } from "./Utils"
9+
} from "@microsoft/msfs-sdk";
10+
import { InterfaceNavbarItemV2 } from "./Utils";
1111

1212
interface InputProps extends ComponentProps {
13-
value: Subscribable<string>
14-
setValue: (value: string) => void
15-
default?: Subscribable<string> | string
16-
class?: string | Subscribable<string>
17-
textarea?: boolean
13+
value: Subscribable<string>;
14+
setValue: (value: string) => void;
15+
default?: Subscribable<string> | string;
16+
class?: string | Subscribable<string>;
17+
textarea?: boolean;
1818
}
1919

2020
export class Input extends DisplayComponent<InputProps> {
21-
private readonly inputId = UUID.GenerateUuid()
22-
private readonly inputRef = FSComponent.createRef<HTMLInputElement>()
21+
private readonly inputId = UUID.GenerateUuid();
22+
private readonly inputRef = FSComponent.createRef<HTMLInputElement>();
2323

2424
onAfterRender(node: VNode): void {
25-
super.onAfterRender(node)
25+
super.onAfterRender(node);
2626

27-
this.props.value.map(val => (this.inputRef.instance.value = val))
27+
this.props.value.map(val => (this.inputRef.instance.value = val));
2828
SubscribableUtils.toSubscribable(this.props.default ?? "", true).map(val => {
29-
this.inputRef.instance.placeholder = val
30-
})
29+
this.inputRef.instance.placeholder = val;
30+
});
3131

32-
this.inputRef.instance.addEventListener("input", () => this.props.setValue(this.inputRef.instance.value ?? ""))
32+
this.inputRef.instance.addEventListener("input", () => this.props.setValue(this.inputRef.instance.value ?? ""));
3333

34-
this.inputRef.instance.onfocus = this.onInputFocus
35-
this.inputRef.instance.onblur = this.onInputBlur
34+
this.inputRef.instance.onfocus = this.onInputFocus;
35+
this.inputRef.instance.onblur = this.onInputBlur;
3636
}
3737

3838
private getInputProps() {
39-
return { value: this.props.value, class: this.props.class }
39+
return { value: this.props.value, class: this.props.class };
4040
}
4141

4242
/**
4343
* Method to handle when input focus is set
4444
* @param e The focus event.
4545
*/
4646
private onInputFocus = (e: FocusEvent): void => {
47-
e.preventDefault()
47+
e.preventDefault();
4848

49-
Coherent.trigger("FOCUS_INPUT_FIELD", this.inputId, "", "", this.inputRef.instance.value, false)
50-
Coherent.on("mousePressOutsideView", () => this.inputRef.instance.blur())
51-
}
49+
Coherent.trigger("FOCUS_INPUT_FIELD", this.inputId, "", "", this.inputRef.instance.value, false);
50+
Coherent.on("mousePressOutsideView", () => this.inputRef.instance.blur());
51+
};
5252

5353
/**
5454
* Method to handle on input blur
5555
*/
5656
private onInputBlur = (): void => {
57-
Coherent.trigger("UNFOCUS_INPUT_FIELD", "")
58-
Coherent.off("mousePressOutsideView")
59-
}
57+
Coherent.trigger("UNFOCUS_INPUT_FIELD", "");
58+
Coherent.off("mousePressOutsideView");
59+
};
6060

6161
render() {
6262
if (this.props.textarea)
6363
return (
6464
<textarea style="width:350px;height:100px;" ref={this.inputRef} {...this.getInputProps()}>
6565
{this.props.value}
6666
</textarea>
67-
)
68-
return <input ref={this.inputRef} {...this.getInputProps()} />
67+
);
68+
return <input ref={this.inputRef} {...this.getInputProps()} />;
6969
}
7070
}
7171

7272
interface CheckboxProps extends ComponentProps {
73-
value: Subscribable<string>
74-
setValue: (value: string) => void
75-
default?: Subscribable<string> | string
76-
class?: string
73+
value: Subscribable<string>;
74+
setValue: (value: string) => void;
75+
default?: Subscribable<string> | string;
76+
class?: string;
7777
}
7878

7979
export class Checkbox extends DisplayComponent<CheckboxProps> {
80-
private readonly isActive = this.props.value.map(val => (val == "true" ? true : false))
80+
private readonly isActive = this.props.value.map(val => (val == "true" ? true : false));
8181

8282
private onClick = () => {
83-
this.props.setValue(this.isActive.get() ? "false" : "true")
84-
}
83+
this.props.setValue(this.isActive.get() ? "false" : "true");
84+
};
8585

8686
render(): VNode {
8787
return (
@@ -96,6 +96,6 @@ export class Checkbox extends DisplayComponent<CheckboxProps> {
9696
>
9797
<span class="text-4xl">{this.isActive.map(val => (val ? "✔" : "X"))}</span>
9898
</InterfaceNavbarItemV2>
99-
)
99+
);
100100
}
101101
}

example/gauge/Components/List.tsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,31 @@ import {
1414
SubscribableArray,
1515
SubscribableArrayEventType,
1616
VNode,
17-
} from "@microsoft/msfs-sdk"
17+
} from "@microsoft/msfs-sdk";
1818

1919
/** The properties for the List component. */
2020
interface ListProps extends ComponentProps {
2121
/**
2222
* The data for this list.
2323
* @type {any[]}
2424
*/
25-
data: SubscribableArray<any>
25+
data: SubscribableArray<any>;
2626

2727
/** A function defining how to render each list item. */
28-
renderItem: (data: any, index: number) => VNode
28+
renderItem: (data: any, index: number) => VNode;
2929

3030
/** CSS class(es) to add to the root of the list component. */
31-
class?: string
31+
class?: string;
3232
}
3333

3434
/** The List component. */
3535
export class List extends DisplayComponent<ListProps> {
36-
private readonly _listContainer = FSComponent.createRef<HTMLElement>()
36+
private readonly _listContainer = FSComponent.createRef<HTMLElement>();
3737

3838
/** @inheritdoc */
3939
public onAfterRender(): void {
40-
this.renderList()
41-
this.props.data.sub(this.onDataChanged.bind(this))
40+
this.renderList();
41+
this.props.data.sub(this.onDataChanged.bind(this));
4242
}
4343

4444
/**
@@ -51,30 +51,30 @@ export class List extends DisplayComponent<ListProps> {
5151
switch (type) {
5252
case SubscribableArrayEventType.Added:
5353
{
54-
const el = this._listContainer.instance.children.item(index)
54+
const el = this._listContainer.instance.children.item(index);
5555
if (Array.isArray(item)) {
5656
for (let i = 0; i < item.length; i++) {
57-
this.addDomNode(item[i], index + i, el)
57+
this.addDomNode(item[i], index + i, el);
5858
}
5959
} else {
60-
this.addDomNode(item, index, el)
60+
this.addDomNode(item, index, el);
6161
}
6262
}
63-
break
63+
break;
6464
case SubscribableArrayEventType.Removed:
6565
{
6666
if (Array.isArray(item)) {
6767
for (let i = 0; i < item.length; i++) {
68-
this.removeDomNode(index)
68+
this.removeDomNode(index);
6969
}
7070
} else {
71-
this.removeDomNode(index)
71+
this.removeDomNode(index);
7272
}
7373
}
74-
break
74+
break;
7575
case SubscribableArrayEventType.Cleared:
76-
this._listContainer.instance.innerHTML = ""
77-
break
76+
this._listContainer.instance.innerHTML = "";
77+
break;
7878
}
7979
}
8080

@@ -83,8 +83,8 @@ export class List extends DisplayComponent<ListProps> {
8383
* @param index The index to remove.
8484
*/
8585
private removeDomNode(index: number): void {
86-
const child = this._listContainer.instance.childNodes.item(index)
87-
this._listContainer.instance.removeChild(child)
86+
const child = this._listContainer.instance.childNodes.item(index);
87+
this._listContainer.instance.removeChild(child);
8888
}
8989

9090
/**
@@ -94,12 +94,12 @@ export class List extends DisplayComponent<ListProps> {
9494
* @param el The element to add to.
9595
*/
9696
private addDomNode(item: any, index: number, el: Element | null): void {
97-
const node = this.renderListItem(item, index)
97+
const node = this.renderListItem(item, index);
9898
if (el !== null) {
99-
node && el && FSComponent.renderBefore(node, el as any)
99+
node && el && FSComponent.renderBefore(node, el as any);
100100
} else {
101-
el = this._listContainer.instance
102-
node && el && FSComponent.render(node, el as any)
101+
el = this._listContainer.instance;
102+
node && el && FSComponent.render(node, el as any);
103103
}
104104
}
105105

@@ -111,25 +111,25 @@ export class List extends DisplayComponent<ListProps> {
111111
* @throws error when the resulting vnode is not a scrollable control
112112
*/
113113
private renderListItem(dataItem: any, index: number): VNode {
114-
return this.props.renderItem(dataItem, index)
114+
return this.props.renderItem(dataItem, index);
115115
}
116116
/** Renders the list of data items. */
117117
private renderList(): void {
118118
// clear all items
119-
this._listContainer.instance.textContent = ""
119+
this._listContainer.instance.textContent = "";
120120

121121
// render items
122-
const dataLen = this.props.data.length
122+
const dataLen = this.props.data.length;
123123
for (let i = 0; i < dataLen; i++) {
124-
const vnode = this.renderListItem(this.props.data.get(i), i)
124+
const vnode = this.renderListItem(this.props.data.get(i), i);
125125
if (vnode !== undefined) {
126-
FSComponent.render(vnode, this._listContainer.instance)
126+
FSComponent.render(vnode, this._listContainer.instance);
127127
}
128128
}
129129
}
130130

131131
/** @inheritdoc */
132132
render(): VNode {
133-
return <div class={this.props.class ?? ""} ref={this._listContainer}></div>
133+
return <div class={this.props.class ?? ""} ref={this._listContainer}></div>;
134134
}
135135
}

0 commit comments

Comments
 (0)