Skip to content

Commit 78b893e

Browse files
committed
chore(examples): fix eslint console.log issue
1 parent 5e617d4 commit 78b893e

20 files changed

Lines changed: 170 additions & 104 deletions

packages/examples/src/bindings/coap/example-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15-
15+
/* eslint no-console: "off" */
1616
import { Servient } from "@node-wot/core";
1717
import { CoapClientFactory } from "@node-wot/binding-coap";
1818

packages/examples/src/bindings/coap/example-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
import { Servient } from "@node-wot/core";
1718
import { CoapServer } from "@node-wot/binding-coap";

packages/examples/src/bindings/http/example-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
import { Servient } from "@node-wot/core";
1718
import { HttpClientFactory } from "@node-wot/binding-http";

packages/examples/src/bindings/http/example-server-secure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
import { Servient } from "@node-wot/core";
1718
import { HttpServer } from "@node-wot/binding-http";

packages/examples/src/bindings/http/example-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
import { Servient } from "@node-wot/core";
1718
import { HttpServer } from "@node-wot/binding-http";

packages/examples/src/bindings/opcua/demo-opcua1.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
import { Servient } from "@node-wot/core";
1718
import { OPCUAClientFactory } from "@node-wot/binding-opcua";
@@ -32,4 +33,6 @@ import { thingDescription } from "./demo-opcua-thing-description";
3233
console.log("------------------------------");
3334

3435
await servient.shutdown();
35-
})();
36+
})().catch((err) => {
37+
console.error("Script error:", err);
38+
});

packages/examples/src/bindings/opcua/demo-opcua2.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
16+
1517
import { Servient } from "@node-wot/core";
1618
import { OPCUAClientFactory } from "@node-wot/binding-opcua";
1719
import { thingDescription } from "./demo-opcua-thing-description";
@@ -23,14 +25,20 @@ import { thingDescription } from "./demo-opcua-thing-description";
2325
const wot = await servient.start();
2426
const thing = await wot.consume(thingDescription);
2527

26-
thing.observeProperty("temperature", async (data) => {
27-
const temperature = await data.value();
28-
console.log("------------------------------");
29-
console.log("temperature : ", temperature, "m/s");
30-
console.log("------------------------------");
31-
});
28+
thing
29+
.observeProperty("temperature", async (data) => {
30+
const temperature = await data.value();
31+
console.log("------------------------------");
32+
console.log("temperature : ", temperature, "m/s");
33+
console.log("------------------------------");
34+
})
35+
.catch((err) => {
36+
console.error("Error observing temperature property:", err);
37+
});
3238

3339
await new Promise((resolve) => setTimeout(resolve, 10000));
3440

3541
await servient.shutdown();
36-
})();
42+
})().catch((err) => {
43+
console.error("Script error:", err);
44+
});

packages/examples/src/bindings/opcua/opcua-coffee-machine-demo.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
16+
/* eslint no-console: "off" */
17+
1518
import { Servient } from "@node-wot/core";
1619
import { OPCUAClientFactory } from "@node-wot/binding-opcua";
1720
import { thingDescription } from "./opcua-coffee-machine-thing-description";
@@ -25,18 +28,27 @@ const pause = async (ms: number) => new Promise((resolve) => setTimeout(resolve,
2528
const thing = await wot.consume(thingDescription);
2629

2730
try {
28-
thing.observeProperty("waterTankLevel", async (data) => {
29-
const waterTankLevel = await data.value();
30-
console.log("------------------------------");
31-
console.log("tankLevel : ", waterTankLevel, "ml");
32-
console.log("------------------------------");
33-
});
34-
thing.observeProperty("coffeeBeanLevel", async (data) => {
35-
const coffeBeanLevel = await data.value();
36-
console.log("------------------------------");
37-
console.log("bean level : ", coffeBeanLevel, "g");
38-
console.log("------------------------------");
39-
});
31+
thing
32+
.observeProperty("waterTankLevel", async (data) => {
33+
const waterTankLevel = await data.value();
34+
console.log("------------------------------");
35+
console.log("tankLevel : ", waterTankLevel, "ml");
36+
console.log("------------------------------");
37+
})
38+
.catch((err) => {
39+
console.error("Error observing waterTankLevel property:", err);
40+
});
41+
thing
42+
.observeProperty("coffeeBeanLevel", async (data) => {
43+
const coffeBeanLevel = await data.value();
44+
console.log("------------------------------");
45+
console.log("bean level : ", coffeBeanLevel, "g");
46+
console.log("------------------------------");
47+
})
48+
.catch((err) => {
49+
console.error("Error observing coffeeBeanLevel property:", err);
50+
});
51+
4052
await thing.invokeAction("brewCoffee", { CoffeeType: 1 });
4153
await pause(5000);
4254
await thing.invokeAction("brewCoffee", { CoffeeType: 0 });
@@ -47,4 +59,6 @@ const pause = async (ms: number) => new Promise((resolve) => setTimeout(resolve,
4759
} finally {
4860
await servient.shutdown();
4961
}
50-
})();
62+
})().catch((err) => {
63+
console.error("Script error:", err);
64+
});

packages/examples/src/quickstart/presence-sensor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
// This is an example Thing script which is a simple presence detector
1718
// It fires an event when it detects a person (mocked as every 5 second)

packages/examples/src/quickstart/simple-coffee-machine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
15+
/* eslint no-console: "off" */
1516

1617
// This is an example Thing script which is a simple coffee machine.
1718
// You can order coffee and see the status of the resources

0 commit comments

Comments
 (0)