Skip to content

Commit 5bc455d

Browse files
committed
refactor: Fix linter violations
1 parent d8df12d commit 5bc455d

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

examples/apps/task-selection/src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async function start(): Promise<void> {
3737
}
3838

3939
// update the browser URL and the window title with the actual container ID
40+
// eslint-disable-next-line require-atomic-updates
4041
location.hash = id;
4142
document.title = id;
4243

examples/apps/task-selection/src/containerCode.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class TaskSelectionContainerRuntimeFactory extends ModelContainerRuntimeF
5151
/**
5252
* {@inheritDoc ModelContainerRuntimeFactory.containerInitializingFirstTime}
5353
*/
54-
protected async containerInitializingFirstTime(runtime: IContainerRuntime) {
54+
protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
5555
const taskManagerDiceRoller = await runtime.createDataStore(
5656
TaskManagerDiceRollerInstantiationFactory.type,
5757
);
@@ -65,7 +65,10 @@ export class TaskSelectionContainerRuntimeFactory extends ModelContainerRuntimeF
6565
/**
6666
* {@inheritDoc ModelContainerRuntimeFactory.createModel}
6767
*/
68-
protected async createModel(runtime: IContainerRuntime, container: IContainer) {
68+
protected async createModel(
69+
runtime: IContainerRuntime,
70+
container: IContainer,
71+
): Promise<ITaskSelectionAppModel> {
6972
return new TaskSelectionAppModel(
7073
await getDataStoreEntryPoint<IDiceRoller>(runtime, taskManagerDiceId),
7174
await getDataStoreEntryPoint<IDiceRoller>(runtime, oldestClientDiceId),

examples/apps/task-selection/src/oldestClientDiceRoller.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ export class OldestClientDiceRoller extends DataObject implements IDiceRoller {
2424
* initializingFirstTime is run only once by the first client to create the DataObject. Here we use it to
2525
* initialize the state of the DataObject.
2626
*/
27-
protected async initializingFirstTime() {
27+
protected async initializingFirstTime(): Promise<void> {
2828
this.root.set(diceValueKey, 1);
2929
}
3030

3131
/**
3232
* hasInitialized is run by each client as they load the DataObject. Here we use it to set up usage of the
3333
* DataObject, by registering an event listener for dice rolls.
3434
*/
35-
protected async hasInitialized() {
35+
protected async hasInitialized(): Promise<void> {
3636
this.root.on("valueChanged", (changed) => {
3737
if (changed.key === diceValueKey) {
3838
// When we see the dice value change, we'll emit the diceRolled event we specified in our interface.
@@ -46,23 +46,23 @@ export class OldestClientDiceRoller extends DataObject implements IDiceRoller {
4646
this.volunteerForAutoRoll();
4747
}
4848

49-
private get oldestClientObserver() {
49+
private get oldestClientObserver(): OldestClientObserver {
5050
assert(this._oldestClientObserver !== undefined, "OldestClientObserver not initialized");
5151
return this._oldestClientObserver;
5252
}
5353

54-
public get value() {
54+
public get value(): number {
5555
const value = this.root.get<number>(diceValueKey);
5656
assert(value !== undefined, "Dice value not initialized");
5757
return value;
5858
}
5959

60-
public readonly roll = () => {
60+
public readonly roll = (): void => {
6161
const rollValue = Math.floor(Math.random() * 6) + 1;
6262
this.root.set(diceValueKey, rollValue);
6363
};
6464

65-
public volunteerForAutoRoll() {
65+
public volunteerForAutoRoll(): void {
6666
if (this.oldestClientObserver.isOldest()) {
6767
// If we're oldest, start the autoroll and watch for loss of oldest.
6868
this.oldestClientObserver.once("lostOldest", () => {
@@ -80,7 +80,7 @@ export class OldestClientDiceRoller extends DataObject implements IDiceRoller {
8080
}
8181
}
8282

83-
private startAutoRollTask() {
83+
private startAutoRollTask(): void {
8484
console.log("Starting autoroll from OldestClientDiceRoller");
8585
if (this.autoRollInterval === undefined) {
8686
this.autoRollInterval = setInterval(() => {
@@ -89,15 +89,15 @@ export class OldestClientDiceRoller extends DataObject implements IDiceRoller {
8989
}
9090
}
9191

92-
private endAutoRollTask() {
92+
private endAutoRollTask(): void {
9393
console.log("Ending autoroll from OldestClientDiceRoller");
9494
if (this.autoRollInterval !== undefined) {
9595
clearInterval(this.autoRollInterval);
9696
this.autoRollInterval = undefined;
9797
}
9898
}
9999

100-
public hasTask() {
100+
public hasTask(): boolean {
101101
return this.oldestClientObserver.isOldest();
102102
}
103103
}

examples/apps/task-selection/src/taskManagerDiceRoller.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class TaskManagerDiceRoller extends DataObject implements IDiceRoller {
2626
* initializingFirstTime is run only once by the first client to create the DataObject. Here we use it to
2727
* initialize the state of the DataObject.
2828
*/
29-
protected async initializingFirstTime() {
29+
protected async initializingFirstTime(): Promise<void> {
3030
this.root.set(diceValueKey, 1);
3131

3232
// We create a TaskManager just like any other DDS.
@@ -38,7 +38,7 @@ export class TaskManagerDiceRoller extends DataObject implements IDiceRoller {
3838
* hasInitialized is run by each client as they load the DataObject. Here we use it to set up usage of the
3939
* DataObject, by registering an event listener for dice rolls.
4040
*/
41-
protected async hasInitialized() {
41+
protected async hasInitialized(): Promise<void> {
4242
this.root.on("valueChanged", (changed) => {
4343
if (changed.key === diceValueKey) {
4444
// When we see the dice value change, we'll emit the diceRolled event we specified in our interface.
@@ -52,23 +52,23 @@ export class TaskManagerDiceRoller extends DataObject implements IDiceRoller {
5252
this.subscribeToAutoRoll();
5353
}
5454

55-
private get taskManager() {
55+
private get taskManager(): TaskManager {
5656
assert(this._taskManager !== undefined, "TaskManager not initialized");
5757
return this._taskManager;
5858
}
5959

60-
public get value() {
60+
public get value(): number {
6161
const value = this.root.get<number>(diceValueKey);
6262
assert(value !== undefined, "Dice value not initialized");
6363
return value;
6464
}
6565

66-
public readonly roll = () => {
66+
public readonly roll = (): void => {
6767
const rollValue = Math.floor(Math.random() * 6) + 1;
6868
this.root.set(diceValueKey, rollValue);
6969
};
7070

71-
public subscribeToAutoRoll() {
71+
public subscribeToAutoRoll(): void {
7272
// Subscribe to the auto roll task. This will constantly keep us in queue for the task until we get it. If we
7373
// lose the task assignment we will automatically re-enter queue.
7474

@@ -89,7 +89,7 @@ export class TaskManagerDiceRoller extends DataObject implements IDiceRoller {
8989
this.taskManager.subscribeToTask(autoRollTaskId);
9090
}
9191

92-
private startAutoRollTask() {
92+
private startAutoRollTask(): void {
9393
console.log("Starting autoroll from TaskManagerDiceRoller");
9494
if (this.autoRollInterval === undefined) {
9595
this.autoRollInterval = setInterval(() => {
@@ -98,15 +98,15 @@ export class TaskManagerDiceRoller extends DataObject implements IDiceRoller {
9898
}
9999
}
100100

101-
private endAutoRollTask() {
101+
private endAutoRollTask(): void {
102102
console.log("Ending autoroll from TaskManagerDiceRoller");
103103
if (this.autoRollInterval !== undefined) {
104104
clearInterval(this.autoRollInterval);
105105
this.autoRollInterval = undefined;
106106
}
107107
}
108108

109-
public hasTask() {
109+
public hasTask(): boolean {
110110
return this.taskManager.assigned(autoRollTaskId);
111111
}
112112
}

examples/apps/task-selection/src/view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ export function renderDiceRoller(diceRoller: IDiceRoller, div: HTMLDivElement):
3030
wrapperDiv.append(diceCharDiv, rollButton, taskOwnerDiv);
3131

3232
// Get the current value of the shared data to update the view whenever it changes.
33-
const updateDiceChar = () => {
33+
const updateDiceChar = (): void => {
3434
// Unicode 0x2680-0x2685 are the sides of a dice (⚀⚁⚂⚃⚄⚅)
3535
diceCharDiv.textContent = String.fromCodePoint(0x267f + diceRoller.value);
3636
diceCharDiv.style.color = `hsl(${diceRoller.value * 60}, 70%, 50%)`;
3737
};
3838
updateDiceChar();
3939

4040
// Just showing visually whether we're the task owner or not.
41-
const updateTaskOwner = () => {
41+
const updateTaskOwner = (): void => {
4242
taskOwnerDiv.textContent = diceRoller.hasTask() ? "Task owner" : "Not task owner";
4343
};
4444
updateTaskOwner();

0 commit comments

Comments
 (0)