diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c510638..23b4d1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actionsx/prettier@v3 + - uses: actionsx/prettier@v2 with: args: --check . diff --git a/mashups/smart-home/mashup-logic.ts b/mashups/smart-home/mashup-logic.ts index 3ebae1c..51469f0 100644 --- a/mashups/smart-home/mashup-logic.ts +++ b/mashups/smart-home/mashup-logic.ts @@ -40,14 +40,14 @@ const wotHelper = new Helpers(servient); // we will fetch the TDs of the devices const coffeeMachineTD = (await wotHelper.fetch( - coffeeMachineURL, + coffeeMachineURL )) as WoT.ThingDescription; // Alternatively, this Thing self-hosts its TD at http://plugfest.thingweb.io:8081/coffee-machine that you can fetch const presenceSensorTD = (await wotHelper.fetch( - `mqtt://${process.env.PRESENCE_SENSOR_BROKER_URI}/smart-home-presence-sensor`, + `mqtt://${process.env.PRESENCE_SENSOR_BROKER_URI}/smart-home-presence-sensor` )) as WoT.ThingDescription; const smartClockTD = (await wotHelper.fetch( - `coap://${process.env.SMART_CLOCK_HOSTNAME}:${process.env.SMART_CLOCK_PORT}/smart-home-smart-clock`, + `coap://${process.env.SMART_CLOCK_HOSTNAME}:${process.env.SMART_CLOCK_PORT}/smart-home-smart-clock` )) as WoT.ThingDescription; // consuming TDs allows creates a software object, which allows us to execute functions on them @@ -79,7 +79,7 @@ const wotHelper = new Helpers(servient); "Current time is " + currentTime.hour.toString().padStart(2, "0") + ":" + - currentTime.minute.toString().padStart(2, "0"), + currentTime.minute.toString().padStart(2, "0") ); // To avoid accidental brews, a flag is used to check whether a coffee was brewed before @@ -101,6 +101,6 @@ const wotHelper = new Helpers(servient); morningCoffeeFlag = false; } }, 1000); - }, + } ); })(); diff --git a/mashups/smart-home/things/simple-coffee-machine.ts b/mashups/smart-home/things/simple-coffee-machine.ts index b880bf4..18a36d8 100644 --- a/mashups/smart-home/things/simple-coffee-machine.ts +++ b/mashups/smart-home/things/simple-coffee-machine.ts @@ -29,7 +29,7 @@ servient.addServer( new HttpServer({ baseUri: `http://${hostname}:${httpPort}`, port: parseInt(httpPort), - }), + }) ); let waterAmount = 1000; @@ -212,7 +212,7 @@ servient.start().then((WoT) => { thing.expose().then(() => { console.info(thing.getThingDescription().title + " ready"); console.info( - "TD available at http://" + hostname + ":" + httpPort, + "TD available at http://" + hostname + ":" + httpPort ); }); }) diff --git a/mashups/smart-home/things/smart-clock.ts b/mashups/smart-home/things/smart-clock.ts index b94f6a3..9688d83 100644 --- a/mashups/smart-home/things/smart-clock.ts +++ b/mashups/smart-home/things/smart-clock.ts @@ -28,7 +28,7 @@ servient.addServer( new CoapServer({ address: hostname, port: parseInt(port), - }), + }) ); let minuteCounter = 0; diff --git a/package-lock.json b/package-lock.json index a6b1b21..0f3d29f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "eslint-plugin-unused-imports": "^4.1.4", "eslint-plugin-workspaces": "^0.10.1", "mocha": "^10.7.3", - "prettier": "^3.3.3" + "prettier": "^2.3.2" } }, "mashups/smart-home": { @@ -5557,14 +5557,15 @@ } }, "node_modules/prettier": { - "version": "3.3.3", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, - "license": "MIT", "bin": { - "prettier": "bin/prettier.cjs" + "prettier": "bin-prettier.js" }, "engines": { - "node": ">=14" + "node": ">=10.13.0" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index 5bc8fb0..74182c3 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,6 @@ "eslint-plugin-unused-imports": "^4.1.4", "eslint-plugin-workspaces": "^0.10.1", "mocha": "^10.7.3", - "prettier": "^3.3.3" + "prettier": "^2.3.2" } } diff --git a/things/advanced-coffee-machine/http/ts/src/main.ts b/things/advanced-coffee-machine/http/ts/src/main.ts index 93ba5ff..848f16e 100644 --- a/things/advanced-coffee-machine/http/ts/src/main.ts +++ b/things/advanced-coffee-machine/http/ts/src/main.ts @@ -76,7 +76,7 @@ let thingModel; if (tmPath != null && tmPath !== "") { thingModel = JSON.parse( - fs.readFileSync(path.join(__dirname, tmPath)).toString(), + fs.readFileSync(path.join(__dirname, tmPath)).toString() ); } @@ -99,7 +99,7 @@ servient.addServer( new HttpServer({ baseUri: `http://${hostname}:${portNumber}`, port: portNumber, - }), + }) ); servient @@ -126,15 +126,15 @@ servient thing.setPropertyReadHandler( "allAvailableResources", - async () => allAvailableResources, + async () => allAvailableResources ); thing.setPropertyReadHandler( "possibleDrinks", - async () => possibleDrinks, + async () => possibleDrinks ); thing.setPropertyReadHandler( "maintenanceNeeded", - async () => maintenanceNeeded, + async () => maintenanceNeeded ); thing.setPropertyReadHandler("schedules", async () => schedules); @@ -150,7 +150,7 @@ servient // (the notify function here simply logs a message to the console) notify( "admin@coffeeMachine.com", - `maintenanceNeeded property has changed, new value is: ${maintenanceNeeded}`, + `maintenanceNeeded property has changed, new value is: ${maintenanceNeeded}` ); } }); @@ -181,7 +181,7 @@ servient } } throw Error("Please specify id variable as uriVariables."); - }, + } ); // Override a read handler for availableResourceLevel property, @@ -205,7 +205,7 @@ servient } } throw Error("Please specify id variable as uriVariables."); - }, + } ); // Set up a handler for makeDrink action @@ -291,22 +291,22 @@ servient newResources.water -= Math.ceil( quantity * sizeQuantifiers[size] * - drinkRecipes[drinkId].water, + drinkRecipes[drinkId].water ); newResources.milk -= Math.ceil( quantity * sizeQuantifiers[size] * - drinkRecipes[drinkId].milk, + drinkRecipes[drinkId].milk ); newResources.chocolate -= Math.ceil( quantity * sizeQuantifiers[size] * - drinkRecipes[drinkId].chocolate, + drinkRecipes[drinkId].chocolate ); newResources.coffeeBeans -= Math.ceil( quantity * sizeQuantifiers[size] * - drinkRecipes[drinkId].coffeeBeans, + drinkRecipes[drinkId].coffeeBeans ); // Check if the amount of available resources is sufficient to make a drink @@ -314,7 +314,7 @@ servient if (newResources[resource] <= 0) { thing.emitEvent( "outOfResource", - `Low level of ${resource}: ${newResources[resource]}%`, + `Low level of ${resource}: ${newResources[resource]}%` ); return { result: false, diff --git a/things/advanced-coffee-machine/http/ts/test/client.test.ts b/things/advanced-coffee-machine/http/ts/test/client.test.ts index f5a92d6..b7e2510 100644 --- a/things/advanced-coffee-machine/http/ts/test/client.test.ts +++ b/things/advanced-coffee-machine/http/ts/test/client.test.ts @@ -31,7 +31,7 @@ describe("Client Tests", () => { try { const WoT = await servient.start(); const td: WoT.ThingDescription = await WoT.requestThingDescription( - `http://localhost:${port}/http-advanced-coffee-machine`, + `http://localhost:${port}/http-advanced-coffee-machine` ); thing = await WoT.consume(td); } catch (error) { diff --git a/things/advanced-coffee-machine/http/ts/test/td.test.ts b/things/advanced-coffee-machine/http/ts/test/td.test.ts index 1bc55fc..8ab2f23 100644 --- a/things/advanced-coffee-machine/http/ts/test/td.test.ts +++ b/things/advanced-coffee-machine/http/ts/test/td.test.ts @@ -47,7 +47,7 @@ describe("TD Test", () => { response.on("end", () => { try { const result = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); const valid = validate && result !== "" @@ -60,7 +60,7 @@ describe("TD Test", () => { done(error); } }); - }, + } ); }); }); diff --git a/things/advanced-coffee-machine/tm.test.js b/things/advanced-coffee-machine/tm.test.js index 67889b9..34ffc5b 100644 --- a/things/advanced-coffee-machine/tm.test.js +++ b/things/advanced-coffee-machine/tm.test.js @@ -23,7 +23,7 @@ describe("Advanced Coffee Machine", () => { validate = ajv.compile(tmSchema); done(); }); - }, + } ); }); diff --git a/things/calculator/coap/js/client-tests/content-negotiation-coap-client.js b/things/calculator/coap/js/client-tests/content-negotiation-coap-client.js index 83d9c94..9922afe 100644 --- a/things/calculator/coap/js/client-tests/content-negotiation-coap-client.js +++ b/things/calculator/coap/js/client-tests/content-negotiation-coap-client.js @@ -51,13 +51,13 @@ function getFullTD(acceptType) { ) { console.log( "Thing Description (json):\n", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); console.log( "Thing Description (cbor):\n", - JSON.parse(decodedData), + JSON.parse(decodedData) ); } } else { @@ -90,7 +90,7 @@ function getResult(acceptType) { if (contentType.includes("application/json")) { console.log( "Result (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); @@ -127,13 +127,13 @@ function observeResultProperty(acceptType) { if (contentType.includes("application/json")) { console.log( "Observe result property (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); console.log( "Observe result property (cbor): ", - decodedData, + decodedData ); } } else { @@ -167,7 +167,7 @@ function getLastChange(acceptType) { if (contentType.includes("application/json")) { console.log( "Last Change (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); @@ -204,13 +204,13 @@ function observeLastChangeProperty(acceptType) { if (contentType.includes("application/json")) { console.log( "Observe lastChange property (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); console.log( "Observe lastChange property (cbor): ", - decodedData, + decodedData ); } } else { @@ -243,7 +243,7 @@ function addNumber(acceptType, contentType, numberToAdd) { addNumberReq.write( contentType === "application/json" ? JSON.stringify(numberToAdd) - : cbor.encode(numberToAdd), + : cbor.encode(numberToAdd) ); addNumberReq.on("response", (res) => { @@ -253,7 +253,7 @@ function addNumber(acceptType, contentType, numberToAdd) { if (contentType.includes("application/json")) { console.log( "Addition result (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); @@ -287,7 +287,7 @@ function subtractNumber(acceptType, contentType, numberToSubtract) { subtractNumberReq.write( contentType === "application/json" ? JSON.stringify(numberToSubtract) - : cbor.encode(numberToSubtract), + : cbor.encode(numberToSubtract) ); subtractNumberReq.on("response", (res) => { @@ -297,7 +297,7 @@ function subtractNumber(acceptType, contentType, numberToSubtract) { if (contentType.includes("application/json")) { console.log( "Subtraction result (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); @@ -338,7 +338,7 @@ function observeUpdateEvent(acceptType) { if (contentType.includes("application/json")) { console.log( "Observe update event (json): ", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { const decodedData = cbor.decode(res.payload); diff --git a/things/calculator/coap/js/client-tests/node-wot-content-negotiation-coap-client.js b/things/calculator/coap/js/client-tests/node-wot-content-negotiation-coap-client.js index ebc42f3..544f70c 100644 --- a/things/calculator/coap/js/client-tests/node-wot-content-negotiation-coap-client.js +++ b/things/calculator/coap/js/client-tests/node-wot-content-negotiation-coap-client.js @@ -25,7 +25,7 @@ servient .then(async (WoT) => { try { const td = await WoT.requestThingDescription( - "coap://localhost:5684/coap-calculator-content-negotiation", + "coap://localhost:5684/coap-calculator-content-negotiation" ); const thing = await WoT.consume(td); diff --git a/things/calculator/coap/js/client-tests/node-wot-simple-coap-client.js b/things/calculator/coap/js/client-tests/node-wot-simple-coap-client.js index 4828452..298033c 100644 --- a/things/calculator/coap/js/client-tests/node-wot-simple-coap-client.js +++ b/things/calculator/coap/js/client-tests/node-wot-simple-coap-client.js @@ -25,7 +25,7 @@ servient .then(async (WoT) => { try { const td = await WoT.requestThingDescription( - "coap://localhost:5683/coap-calculator-simple", + "coap://localhost:5683/coap-calculator-simple" ); const thing = await WoT.consume(td); diff --git a/things/calculator/coap/js/client-tests/simple-coap-client.js b/things/calculator/coap/js/client-tests/simple-coap-client.js index 48bba53..9f44867 100644 --- a/things/calculator/coap/js/client-tests/simple-coap-client.js +++ b/things/calculator/coap/js/client-tests/simple-coap-client.js @@ -42,11 +42,13 @@ function getThingDescription() { if (res.code === "2.05") { console.log( "Thing Description: \n", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { console.error( - `Failed to get Thing Description: ${res.code} - ${res.payload.toString()}`, + `Failed to get Thing Description: ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -71,7 +73,9 @@ function getResult() { console.log("Result:", JSON.parse(res.payload.toString())); } else { console.error( - `Failed to get Property "result": ${res.code} - ${res.payload.toString()}`, + `Failed to get Property "result": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -98,11 +102,13 @@ function observeResultProperty() { if (res.code === "2.05") { console.log( "Observe result property:", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { console.error( - `Failed to observe Event "update": ${res.code} - ${res.payload.toString()}`, + `Failed to observe Event "update": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -129,7 +135,9 @@ function getLastChange() { console.log("Last Change:", JSON.parse(res.payload.toString())); } else { console.error( - `Failed to get Property "lastChange": ${res.code} - ${res.payload.toString()}`, + `Failed to get Property "lastChange": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -156,11 +164,13 @@ function observeLastChangeProperty() { if (res.code === "2.05") { console.log( "Observe lastChange property:", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { console.error( - `Failed to observe Event "update": ${res.code} - ${res.payload.toString()}`, + `Failed to observe Event "update": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -194,7 +204,9 @@ function addNumber(numberToAdd) { console.log("Addition result:", JSON.parse(res.payload.toString())); } else { console.error( - `Failed to call the Action "add": ${res.code} - ${res.payload.toString()}`, + `Failed to call the Action "add": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -224,11 +236,13 @@ function subtractNumber(numberToSubtract) { if (res.code === "2.05") { console.log( "Subtraction result:", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { console.error( - `Failed to call the Action "subtract": ${res.code} - ${res.payload.toString()}`, + `Failed to call the Action "subtract": ${ + res.code + } - ${res.payload.toString()}` ); } }); @@ -258,11 +272,13 @@ function observeUpdateEvent() { if (res.code === "2.05") { console.log( "Observe update event:", - JSON.parse(res.payload.toString()), + JSON.parse(res.payload.toString()) ); } else { console.error( - `Failed to observe Event "update": ${res.code} - ${res.payload.toString()}`, + `Failed to observe Event "update": ${ + res.code + } - ${res.payload.toString()}` ); } }); diff --git a/things/calculator/coap/js/coap-content-negotiation-calculator.js b/things/calculator/coap/js/coap-content-negotiation-calculator.js index 0fa4869..7e34847 100644 --- a/things/calculator/coap/js/coap-content-negotiation-calculator.js +++ b/things/calculator/coap/js/coap-content-negotiation-calculator.js @@ -228,7 +228,7 @@ for (const key in thingDescription.events) { try { fs.writeFileSync( "coap-content-negotiation-calculator-thing.td.jsonld", - JSON.stringify(thingDescription, null, 2), + JSON.stringify(thingDescription, null, 2) ); } catch (err) { console.log(err); @@ -262,7 +262,7 @@ server.on("request", (req, res) => { res.end(JSON.stringify(thingDescription)); } else if (acceptHeaders.includes("application/cbor")) { const cborData = cbor.encode( - JSON.stringify(thingDescription), + JSON.stringify(thingDescription) ); res.setOption("Content-Format", "application/cbor"); res.end(cborData); @@ -297,7 +297,7 @@ server.on("request", (req, res) => { res.statusCode = 205; if ( acceptHeaders.includes( - "application/json", + "application/json" ) || acceptHeaders.includes("application/*") || acceptHeaders === "*/*" @@ -314,7 +314,7 @@ server.on("request", (req, res) => { res.on("finish", () => { console.log( - "Result property observation has been closed", + "Result property observation has been closed" ); clearInterval(changeInterval); }); @@ -345,7 +345,7 @@ server.on("request", (req, res) => { res.statusCode = 205; if ( acceptHeaders.includes( - "application/json", + "application/json" ) || acceptHeaders.includes("application/*") || acceptHeaders === "*/*" @@ -362,7 +362,7 @@ server.on("request", (req, res) => { res.on("finish", () => { console.log( - "lastChange property observation has been closed", + "lastChange property observation has been closed" ); clearInterval(changeInterval); }); @@ -435,7 +435,7 @@ server.on("request", (req, res) => { if (reqContentType.includes("application/json")) { numberToSubtract = JSON.parse( - req.payload.toString(), + req.payload.toString() ); } else { numberToSubtract = cbor.decode(req.payload); diff --git a/things/calculator/coap/js/coap-simple-calculator.js b/things/calculator/coap/js/coap-simple-calculator.js index b462a75..fbfadd7 100644 --- a/things/calculator/coap/js/coap-simple-calculator.js +++ b/things/calculator/coap/js/coap-simple-calculator.js @@ -127,7 +127,7 @@ for (const key in thingDescription.events) { try { fs.writeFileSync( "coap-simple-calculator-thing.td.jsonld", - JSON.stringify(thingDescription, null, 2), + JSON.stringify(thingDescription, null, 2) ); } catch (err) { console.log(err); @@ -206,7 +206,7 @@ server.on("request", (req, res) => { res.on("finish", () => { console.log( - "Client stopped the lastChange observation", + "Client stopped the lastChange observation" ); clearInterval(changeInterval); }); diff --git a/things/calculator/coap/js/test/client.test.js b/things/calculator/coap/js/test/client.test.js index ec7e9e6..f71b54b 100644 --- a/things/calculator/coap/js/test/client.test.js +++ b/things/calculator/coap/js/test/client.test.js @@ -54,7 +54,7 @@ describe("Client Tests", () => { before(async () => { try { const td = await WoT.requestThingDescription( - `coap://localhost:${simplePort}/coap-calculator-simple`, + `coap://localhost:${simplePort}/coap-calculator-simple` ); thing = await WoT.consume(td); } catch (error) { @@ -82,7 +82,7 @@ describe("Client Tests", () => { await thing.invokeAction("subtract", valueToSubtract); const newResultValue = await readProperty(thing, "result"); expect(newResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -98,7 +98,7 @@ describe("Client Tests", () => { "lastChange", async (response) => { value = await response.value(); - }, + } ); setTimeout(async () => { @@ -124,11 +124,11 @@ describe("Client Tests", () => { const valueToSubtract = 3; const response = await thing.invokeAction( "subtract", - valueToSubtract, + valueToSubtract ); const actionResultValue = await response.value(); expect(actionResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -146,9 +146,9 @@ describe("Client Tests", () => { "update", async (response) => { await expect( - response.value, + response.value ).to.have.eventually.be.equal(resultValue + valueToAdd); - }, + } ); await subscription.stop(); @@ -162,7 +162,7 @@ describe("Client Tests", () => { before(async () => { try { const td = await WoT.requestThingDescription( - `coap://localhost:${contentNegotiationPort}/coap-calculator-content-negotiation`, + `coap://localhost:${contentNegotiationPort}/coap-calculator-content-negotiation` ); thing = await WoT.consume(td); } catch (error) { @@ -190,7 +190,7 @@ describe("Client Tests", () => { await thing.invokeAction("subtract", valueToSubtract); const newResultValue = await readProperty(thing, "result"); expect(newResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -206,7 +206,7 @@ describe("Client Tests", () => { "lastChange", async (response) => { value = await response.value(); - }, + } ); setTimeout(async () => { @@ -232,11 +232,11 @@ describe("Client Tests", () => { const valueToSubtract = 3; const response = await thing.invokeAction( "subtract", - valueToSubtract, + valueToSubtract ); const actionResultValue = await response.value(); expect(actionResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -254,9 +254,9 @@ describe("Client Tests", () => { "update", async (response) => { await expect( - response.value, + response.value ).to.have.eventually.be.equal(resultValue + valueToAdd); - }, + } ); await subscription.stop(); diff --git a/things/calculator/coap/js/test/fixtures.js b/things/calculator/coap/js/test/fixtures.js index 5690372..07f564f 100644 --- a/things/calculator/coap/js/test/fixtures.js +++ b/things/calculator/coap/js/test/fixtures.js @@ -40,7 +40,7 @@ const mochaGlobalSetup = async function () { path.join( __dirname, "..", - "coap-content-negotiation-calculator.js", + "coap-content-negotiation-calculator.js" ), "-p", `${contentNegotiationPort}`, diff --git a/things/calculator/coap/js/test/td.test.js b/things/calculator/coap/js/test/td.test.js index 266a338..91eb852 100644 --- a/things/calculator/coap/js/test/td.test.js +++ b/things/calculator/coap/js/test/td.test.js @@ -38,7 +38,7 @@ describe("Calculator CoAP JS", () => { describe("Calculator Simple", () => { it("should have a valid TD", (done) => { const req = coap.request( - `coap://localhost:${simplePort}/coap-calculator-simple`, + `coap://localhost:${simplePort}/coap-calculator-simple` ); req.on("response", (res) => { diff --git a/things/calculator/http/express/client-tests/content-negotiation-http-client.js b/things/calculator/http/express/client-tests/content-negotiation-http-client.js index 8d7a0a8..a18a19e 100644 --- a/things/calculator/http/express/client-tests/content-negotiation-http-client.js +++ b/things/calculator/http/express/client-tests/content-negotiation-http-client.js @@ -140,7 +140,7 @@ function listenToLastChangeProperty(acceptType) { headers: { Accept: acceptType, }, - }, + } ); lastChangeEventSource.onmessage = (e) => { @@ -282,20 +282,20 @@ async function runCalculatorInteractions() { console.log("Full thing: \n", await getFullTD("application/cbor")); console.log( "Current number: ", - await getCurrentResult("application/json"), + await getCurrentResult("application/json") ); console.log("Last Change: ", await getLatestChange("application/cbor")); console.log( "Result of the addition is: ", - await addNumber(5, "application/cbor", "application/json"), + await addNumber(5, "application/cbor", "application/json") ); console.log( "Result of the subtraction is: ", - await subtractNumber(3, "application/json", "application/cbor"), + await subtractNumber(3, "application/json", "application/cbor") ); console.log( "Current number: ", - await getCurrentResult("application/cbor"), + await getCurrentResult("application/cbor") ); console.log("Last Change: ", await getLatestChange("application/json")); @@ -303,7 +303,7 @@ async function runCalculatorInteractions() { * Start listening to the update event, result property and lastChange property. */ console.log( - "\n-------- Start listening to properties and events --------\n", + "\n-------- Start listening to properties and events --------\n" ); listenToResultProperty("application/cbor"); listenToUpdateEvent("application/json"); @@ -313,7 +313,7 @@ async function runCalculatorInteractions() { console.log( "Adding 1 to test observation: ", await addNumber(1, "application/cbor", "application/json"), - "\n", + "\n" ); }, 2000); } catch (err) { diff --git a/things/calculator/http/express/client-tests/node-wot-content-negotiation-http-client.js b/things/calculator/http/express/client-tests/node-wot-content-negotiation-http-client.js index 5e7f603..4754ea1 100644 --- a/things/calculator/http/express/client-tests/node-wot-content-negotiation-http-client.js +++ b/things/calculator/http/express/client-tests/node-wot-content-negotiation-http-client.js @@ -23,7 +23,7 @@ servient .start() .then(async (WoT) => { const td = await WoT.requestThingDescription( - "http://localhost:3001/http-express-calculator-content-negotiation", + "http://localhost:3001/http-express-calculator-content-negotiation" ); const thing = await WoT.consume(td); diff --git a/things/calculator/http/express/client-tests/node-wot-simple-http-client.js b/things/calculator/http/express/client-tests/node-wot-simple-http-client.js index db6b135..9d79700 100644 --- a/things/calculator/http/express/client-tests/node-wot-simple-http-client.js +++ b/things/calculator/http/express/client-tests/node-wot-simple-http-client.js @@ -23,7 +23,7 @@ servient .start() .then(async (WoT) => { const td = await WoT.requestThingDescription( - "http://localhost:3000/http-express-calculator-simple", + "http://localhost:3000/http-express-calculator-simple" ); const thing = await WoT.consume(td); diff --git a/things/calculator/http/express/client-tests/simple-http-client.js b/things/calculator/http/express/client-tests/simple-http-client.js index faeaaa6..a0617c4 100644 --- a/things/calculator/http/express/client-tests/simple-http-client.js +++ b/things/calculator/http/express/client-tests/simple-http-client.js @@ -82,7 +82,7 @@ async function getLatestChange() { */ function listenToLastChange() { const lastChangeEventSource = new EventSource( - url + lastChangeEndPointObserve, + url + lastChangeEndPointObserve ); lastChangeEventSource.onmessage = (e) => { @@ -174,7 +174,7 @@ async function runCalculatorInteractions() { * Start listening to the update event, result property and lastChange property. */ console.log( - "\n-------- Start listening to properties and events --------\n", + "\n-------- Start listening to properties and events --------\n" ); listenToUpdateEvent(); listenToLastChange(); diff --git a/things/calculator/http/express/http-content-negotiation-calculator.js b/things/calculator/http/express/http-content-negotiation-calculator.js index ecf45c7..ab8c8a4 100644 --- a/things/calculator/http/express/http-content-negotiation-calculator.js +++ b/things/calculator/http/express/http-content-negotiation-calculator.js @@ -131,7 +131,7 @@ for (const key in thingDescription.properties) { supportedContentTypes.forEach((type) => { if ( !thingDescription.properties[key].forms[0].contentType.includes( - type, + type ) ) { const newFormRead = JSON.parse(JSON.stringify(originalForm)); @@ -235,7 +235,7 @@ for (const key in thingDescription.events) { try { fs.writeFileSync( "http-content-negotiation-calculator-thing.td.jsonld", - JSON.stringify(thingDescription, null, 2), + JSON.stringify(thingDescription, null, 2) ); } catch (err) { console.log(err); @@ -291,7 +291,7 @@ app.use((req, res, next) => { if (acceptHeader === undefined) { res.status(406).json( - "Not Acceptable: Supported formats are application/json, and application/cbor", + "Not Acceptable: Supported formats are application/json, and application/cbor" ); } else if ( acceptHeader.includes("*/*") || @@ -304,7 +304,7 @@ app.use((req, res, next) => { next(); } else { res.status(406).json( - "Not Acceptable: Supported formats are application/json, and application/cbor", + "Not Acceptable: Supported formats are application/json, and application/cbor" ); } }); diff --git a/things/calculator/http/express/http-simple-calculator.js b/things/calculator/http/express/http-simple-calculator.js index 65929ed..ce895de 100644 --- a/things/calculator/http/express/http-simple-calculator.js +++ b/things/calculator/http/express/http-simple-calculator.js @@ -165,7 +165,7 @@ for (const key in thingDescription.events) { try { fs.writeFileSync( "http-simple-calculator-thing.td.jsonld", - JSON.stringify(thingDescription, null, 2), + JSON.stringify(thingDescription, null, 2) ); } catch (err) { console.log(err); diff --git a/things/calculator/http/express/test/client.test.js b/things/calculator/http/express/test/client.test.js index e152499..e545655 100644 --- a/things/calculator/http/express/test/client.test.js +++ b/things/calculator/http/express/test/client.test.js @@ -55,7 +55,7 @@ describe("Client Tests", () => { before(async () => { try { const td = await WoT.requestThingDescription( - `http://localhost:${simplePort}/http-express-calculator-simple`, + `http://localhost:${simplePort}/http-express-calculator-simple` ); thing = await WoT.consume(td); } catch (error) { @@ -83,7 +83,7 @@ describe("Client Tests", () => { await thing.invokeAction("subtract", valueToSubtract); const newResultValue = await readProperty(thing, "result"); expect(newResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -99,7 +99,7 @@ describe("Client Tests", () => { "lastChange", async (response) => { value = await response.value(); - }, + } ); setTimeout(async () => { @@ -125,11 +125,11 @@ describe("Client Tests", () => { const valueToSubtract = 3; const response = await thing.invokeAction( "subtract", - valueToSubtract, + valueToSubtract ); const actionResultValue = await response.value(); expect(actionResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -147,9 +147,9 @@ describe("Client Tests", () => { "update", async (response) => { await expect( - response.value, + response.value ).to.have.eventually.be.equal(resultValue + valueToAdd); - }, + } ); await subscription.stop(); @@ -163,7 +163,7 @@ describe("Client Tests", () => { before(async () => { try { const td = await WoT.requestThingDescription( - `http://localhost:${contentNegotiationPort}/http-express-calculator-content-negotiation`, + `http://localhost:${contentNegotiationPort}/http-express-calculator-content-negotiation` ); thing = await WoT.consume(td); } catch (error) { @@ -191,7 +191,7 @@ describe("Client Tests", () => { await thing.invokeAction("subtract", valueToSubtract); const newResultValue = await readProperty(thing, "result"); expect(newResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -207,7 +207,7 @@ describe("Client Tests", () => { "lastChange", async (response) => { value = await response.value(); - }, + } ); setTimeout(async () => { @@ -233,11 +233,11 @@ describe("Client Tests", () => { const valueToSubtract = 3; const response = await thing.invokeAction( "subtract", - valueToSubtract, + valueToSubtract ); const actionResultValue = await response.value(); expect(actionResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -255,9 +255,9 @@ describe("Client Tests", () => { "update", async (response) => { await expect( - response.value, + response.value ).to.have.eventually.be.equal(resultValue + valueToAdd); - }, + } ); await subscription.stop(); diff --git a/things/calculator/http/express/test/fixtures.js b/things/calculator/http/express/test/fixtures.js index dc52f4c..eefa5a3 100644 --- a/things/calculator/http/express/test/fixtures.js +++ b/things/calculator/http/express/test/fixtures.js @@ -40,7 +40,7 @@ const mochaGlobalSetup = async function () { path.join( __dirname, "..", - "http-content-negotiation-calculator.js", + "http-content-negotiation-calculator.js" ), "-p", `${contentNegotiationPort}`, diff --git a/things/calculator/http/express/test/td.test.js b/things/calculator/http/express/test/td.test.js index 80d8fe8..3a863f6 100644 --- a/things/calculator/http/express/test/td.test.js +++ b/things/calculator/http/express/test/td.test.js @@ -47,7 +47,7 @@ describe("Calculator HTTP JS", () => { response.on("end", () => { try { const result = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); const valid = validate(result); expect(valid).to.be.true; @@ -56,7 +56,7 @@ describe("Calculator HTTP JS", () => { console.log(error); } }); - }, + } ); }); }); @@ -82,7 +82,7 @@ describe("Calculator HTTP JS", () => { response.on("end", () => { try { const result = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); const valid = validate(result); expect(valid).to.be.true; @@ -91,7 +91,7 @@ describe("Calculator HTTP JS", () => { console.log(error); } }); - }, + } ); }); }); diff --git a/things/calculator/http/flask/test/td.test.js b/things/calculator/http/flask/test/td.test.js index 7e4a114..aba3bd5 100644 --- a/things/calculator/http/flask/test/td.test.js +++ b/things/calculator/http/flask/test/td.test.js @@ -47,12 +47,12 @@ describe("Calculator HTTP Flask", () => { response.on("end", () => { const tdSchema = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); validate = ajv.compile(tdSchema); resolve("Success"); }); - }, + } ); }); @@ -81,13 +81,13 @@ describe("Calculator HTTP Flask", () => { response.on("end", () => { const result = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); const valid = validate(result); expect(valid).to.be.true; done(); }); - }, + } ); }, 1000); }); diff --git a/things/calculator/mqtt/js/main.js b/things/calculator/mqtt/js/main.js index 747a89e..1b62993 100644 --- a/things/calculator/mqtt/js/main.js +++ b/things/calculator/mqtt/js/main.js @@ -143,7 +143,7 @@ fs.writeFile( `${thingName}.td.json`, JSON.stringify(thingDescription, 4, 4), "utf-8", - function () {}, + function () {} ); broker.on("connect", () => { @@ -256,12 +256,12 @@ broker.on("message", (topic, payload, packet) => { broker.publish( `${thingName}/${PROPERTIES}/result`, `${result}`, - { retain: true }, + { retain: true } ); broker.publish( `${thingName}/${PROPERTIES}/lastChange`, `${lastChange}`, - { retain: true }, + { retain: true } ); } } @@ -301,12 +301,12 @@ broker.on("message", (topic, payload, packet) => { broker.publish( `${thingName}/${PROPERTIES}/result`, `${result}`, - { retain: true }, + { retain: true } ); broker.publish( `${thingName}/${PROPERTIES}/lastChange`, `${lastChange}`, - { retain: true }, + { retain: true } ); } } diff --git a/things/calculator/mqtt/js/test/client.test.js b/things/calculator/mqtt/js/test/client.test.js index 7903491..b74e0e7 100644 --- a/things/calculator/mqtt/js/test/client.test.js +++ b/things/calculator/mqtt/js/test/client.test.js @@ -95,11 +95,11 @@ describe.skip("Client Tests", () => { const valueToSubtract = 3; const response = await thing.invokeAction( "subtract", - valueToSubtract, + valueToSubtract ); const actionResultValue = await response.value(); expect(actionResultValue).to.be.equal( - resultValue - valueToSubtract, + resultValue - valueToSubtract ); }); }); @@ -113,7 +113,7 @@ describe.skip("Client Tests", () => { console.log(value); expect(value).to.be.equal("Updated the thing!"); subscription.stop(); - }, + } ); }); }); diff --git a/things/calculator/tm.test.js b/things/calculator/tm.test.js index e2fb610..48f9c5a 100644 --- a/things/calculator/tm.test.js +++ b/things/calculator/tm.test.js @@ -23,7 +23,7 @@ describe("Calculator", () => { validate = ajv.compile(tmSchema); done(); }); - }, + } ); }); diff --git a/things/data-schema-thing/http/ts/src/main.ts b/things/data-schema-thing/http/ts/src/main.ts index c536145..81acff7 100644 --- a/things/data-schema-thing/http/ts/src/main.ts +++ b/things/data-schema-thing/http/ts/src/main.ts @@ -60,7 +60,7 @@ function checkPropertyWrite(expected: string, actual: unknown) { function checkActionInvocation( name: string, expected: string, - actual: unknown, + actual: unknown ) { const output = "Action " + name + " invoked with " + actual; if (expected === actual) { @@ -94,7 +94,7 @@ if (process.platform === "win32") { let thingModel; if (tmPath != null && tmPath !== "") { thingModel = JSON.parse( - fs.readFileSync(path.join(__dirname, tmPath)).toString(), + fs.readFileSync(path.join(__dirname, tmPath)).toString() ); } @@ -214,7 +214,7 @@ servient.addServer( new HttpServer({ baseUri: `http://${hostname}:${portNumber}`, port: portNumber, - }), + }) ); servient.start().then((WoT) => { @@ -293,7 +293,7 @@ servient.start().then((WoT) => { checkActionInvocation( "void-void", "undefined", - typeof (await parameters.value()), + typeof (await parameters.value()) ); return undefined; }) @@ -310,7 +310,7 @@ servient.start().then((WoT) => { checkActionInvocation( "void-int", "undefined", - typeof (await parameters.value()), + typeof (await parameters.value()) ); logger.info({ message: `${value}`, @@ -351,7 +351,7 @@ servient.start().then((WoT) => { checkActionInvocation( "int-void", "integer", - typeof parameters, + typeof parameters ); } return undefined; @@ -384,7 +384,7 @@ servient.start().then((WoT) => { checkActionInvocation( "int-int", "integer", - typeof localParameters, + typeof localParameters ); } const value = (localParameters as number) + 1; @@ -426,13 +426,13 @@ servient.start().then((WoT) => { checkActionInvocation( "int-string", "integer", - "integer", + "integer" ); } else { checkActionInvocation( "int-string", "integer", - typeof localParameters, + typeof localParameters ); } @@ -476,7 +476,7 @@ servient.start().then((WoT) => { checkActionInvocation( "void-complex", "undefined", - typeof (await parameters.value()), + typeof (await parameters.value()) ); const value = { prop1: 123, prop2: "abc" }; logger.info({ @@ -512,7 +512,7 @@ servient.start().then((WoT) => { checkActionInvocation( "complex-void", "object", - typeof (await parameters.value()), + typeof (await parameters.value()) ); return undefined; }); diff --git a/things/data-schema-thing/http/ts/test/client.test.ts b/things/data-schema-thing/http/ts/test/client.test.ts index 7ac461b..9064c89 100644 --- a/things/data-schema-thing/http/ts/test/client.test.ts +++ b/things/data-schema-thing/http/ts/test/client.test.ts @@ -30,7 +30,7 @@ let thing: WoT.ConsumedThing; const readProperty = async ( thing: WoT.ConsumedThing, - name: string, + name: string ): Promise => { try { const res = await thing.readProperty(name); @@ -47,7 +47,7 @@ describe("Client Tests", () => { try { const WoT = await servient.start(); const td: WoT.ThingDescription = await WoT.requestThingDescription( - `http://localhost:${port}/http-data-schema-thing`, + `http://localhost:${port}/http-data-schema-thing` ); thing = await WoT.consume(td); } catch (error) { diff --git a/things/data-schema-thing/http/ts/test/td.test.ts b/things/data-schema-thing/http/ts/test/td.test.ts index 6fdad69..30c5557 100644 --- a/things/data-schema-thing/http/ts/test/td.test.ts +++ b/things/data-schema-thing/http/ts/test/td.test.ts @@ -47,7 +47,7 @@ describe("TD Test", () => { response.on("end", () => { try { const result = JSON.parse( - Buffer.concat(body).toString(), + Buffer.concat(body).toString() ); const valid = validate && result !== "" @@ -60,7 +60,7 @@ describe("TD Test", () => { done(error); } }); - }, + } ); }); }); diff --git a/things/data-schema-thing/tm.test.js b/things/data-schema-thing/tm.test.js index 3d95e70..1efa70c 100644 --- a/things/data-schema-thing/tm.test.js +++ b/things/data-schema-thing/tm.test.js @@ -23,7 +23,7 @@ describe("Test Thing", () => { validate = ajv.compile(tmSchema); done(); }); - }, + } ); }); diff --git a/things/elevator/modbus/js/main.js b/things/elevator/modbus/js/main.js index 0214ea9..602f691 100644 --- a/things/elevator/modbus/js/main.js +++ b/things/elevator/modbus/js/main.js @@ -147,7 +147,7 @@ fs.writeFile( `${thingName}.td.json`, JSON.stringify(thingDescription, 4, 4), "utf-8", - function () {}, + function () {} ); const coilMemoryRange = [1, 9999]; @@ -174,13 +174,13 @@ const vector = { console.log(`Reading discrete input @${addr}`); const normalizedAddress = getNormalizedAddress( addr, - discreteInputMemoryRange, + discreteInputMemoryRange ); if (normalizedAddress === onTheMoveAddress) { if (onTheMoveIsPolled) { console.log( - `Polling onTheMove too frequently. You should poll it every ${onTheMovePollingTime} ms.`, + `Polling onTheMove too frequently. You should poll it every ${onTheMovePollingTime} ms.` ); return; } @@ -213,7 +213,7 @@ const vector = { const normalizedAddress = getNormalizedAddress( addr, - holdingRegisterMemoryRange, + holdingRegisterMemoryRange ); setTimeout(function () { @@ -232,7 +232,7 @@ const vector = { console.log(`Reading coil @${addr}`); const normalizedAddress = getNormalizedAddress( addr, - coilMemoryRange, + coilMemoryRange ); resolve(coils[normalizedAddress]); }); @@ -248,7 +248,7 @@ const vector = { console.log(`Setting register @${addr} to ${value}`); const normalizedAddress = getNormalizedAddress( addr, - holdingRegisterMemoryRange, + holdingRegisterMemoryRange ); // trying to change floor number holdingRegisters[normalizedAddress] = value; @@ -261,20 +261,20 @@ const vector = { // elevator is on the move if (discreteInputs[onTheMoveAddress] && !isTestRun) { console.log( - "Elevator is on the move, cannot change the floor number", + "Elevator is on the move, cannot change the floor number" ); } else { const floorNumberValue = getFloorNumberValue(); if (floorNumberValue < minFloorNumber) { console.log( - `Floor number should not be under ${minFloorNumber}`, + `Floor number should not be under ${minFloorNumber}` ); return -1; } if (floorNumberValue > maxFloorNumber) { console.log( - `Floor number should not be above ${maxFloorNumber}`, + `Floor number should not be above ${maxFloorNumber}` ); return -1; } @@ -302,7 +302,7 @@ const vector = { const normalizedAddress = getNormalizedAddress( addr, - coilMemoryRange, + coilMemoryRange ); console.log(`Setting coil @${addr} to ${value}`); diff --git a/things/elevator/modbus/js/test/td.test.js b/things/elevator/modbus/js/test/td.test.js index c0f2e84..e6d15c1 100644 --- a/things/elevator/modbus/js/test/td.test.js +++ b/things/elevator/modbus/js/test/td.test.js @@ -48,7 +48,7 @@ describe("Elevator Modbus JS", () => { const valid = validate(result); expect(valid).to.be.true; done(); - }, + } ); }); }); diff --git a/things/elevator/tm.test.js b/things/elevator/tm.test.js index a4aa841..6142856 100644 --- a/things/elevator/tm.test.js +++ b/things/elevator/tm.test.js @@ -23,7 +23,7 @@ describe("Elevator", () => { validate = ajv.compile(tmSchema); done(); }); - }, + } ); }); diff --git a/util/util.ts b/util/util.ts index 2e9f050..0018c3a 100644 --- a/util/util.ts +++ b/util/util.ts @@ -31,7 +31,7 @@ const spawn = require("node:child_process").spawn; export const getInitiateMain = ( mainCmd: string, - cmdArgs: string[], + cmdArgs: string[] ): Promise => { return new Promise((resolve, reject) => { const thingProcess = spawn(mainCmd, cmdArgs); @@ -98,6 +98,6 @@ const getTDJSONSchema = new Promise((resolve, reject) => { const tdSchema = JSON.parse(Buffer.concat(body).toString()); resolve(tdSchema); }); - }, + } ); });