Skip to content

Commit fc85ce8

Browse files
chore: activate "prefer-const" eslint error (#1432)
1 parent d08d5d2 commit fc85ce8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default defineConfig([
127127
"@typescript-eslint/no-floating-promises": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
128128

129129
// **************** Enforce usage of `const` over `let` wherever possible, to prevent accidental reassignments
130-
"prefer-const": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
130+
"prefer-const": "error",
131131

132132
// *************** Other rules ***************
133133
"no-restricted-globals": "error",

packages/core/src/consumed-thing.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
588588
throw new Error(`ConsumedThing '${this.title}' does not have property ${propertyName}`);
589589
}
590590

591-
let { client, form } = this.getClientFor(tp.forms, "readproperty", Affordance.PropertyAffordance, options);
591+
const { client, form } = this.getClientFor(tp.forms, "readproperty", Affordance.PropertyAffordance, options);
592592
if (form == null) {
593593
throw new Error(`ConsumedThing '${this.title}' did not get suitable form`);
594594
}
@@ -598,11 +598,11 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
598598
debug(`ConsumedThing '${this.title}' reading ${form.href}`);
599599

600600
// uriVariables ?
601-
form = this.handleUriVariables(tp, form, options);
601+
const formWithUriVariables = this.handleUriVariables(tp, form, options);
602602

603-
const content = await client.readResource(form);
603+
const content = await client.readResource(formWithUriVariables);
604604
try {
605-
return this.handleInteractionOutput(content, form, tp);
605+
return this.handleInteractionOutput(content, formWithUriVariables, tp);
606606
} catch (e) {
607607
const error = e instanceof Error ? e : new Error(JSON.stringify(e));
608608
throw new Error(`Error while processing property for ${tp.title}. ${error.message}`);
@@ -698,7 +698,7 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
698698
if (tp == null) {
699699
throw new Error(`ConsumedThing '${this.title}' does not have property ${propertyName}`);
700700
}
701-
let { client, form } = this.getClientFor(tp.forms, "writeproperty", Affordance.PropertyAffordance, options);
701+
const { client, form } = this.getClientFor(tp.forms, "writeproperty", Affordance.PropertyAffordance, options);
702702
if (form == null) {
703703
throw new Error(`ConsumedThing '${this.title}' did not get suitable form`);
704704
}
@@ -710,8 +710,8 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
710710
const content = ContentManager.valueToContent(value, tp, form.contentType);
711711

712712
// uriVariables ?
713-
form = this.handleUriVariables(tp, form, options);
714-
await client.writeResource(form, content);
713+
const formWithUriVariables = this.handleUriVariables(tp, form, options);
714+
await client.writeResource(formWithUriVariables, content);
715715
}
716716

717717
async writeMultipleProperties(valueMap: WoT.PropertyWriteMap, options?: WoT.InteractionOptions): Promise<void> {
@@ -739,7 +739,7 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
739739
if (ta == null) {
740740
throw new Error(`ConsumedThing '${this.title}' does not have action ${actionName}`);
741741
}
742-
let { client, form } = this.getClientFor(ta.forms, "invokeaction", Affordance.ActionAffordance, options);
742+
const { client, form } = this.getClientFor(ta.forms, "invokeaction", Affordance.ActionAffordance, options);
743743
if (form == null) {
744744
throw new Error(`ConsumedThing '${this.title}' did not get suitable form`);
745745
}
@@ -759,11 +759,11 @@ export default class ConsumedThing extends Thing implements IConsumedThing {
759759
}
760760

761761
// uriVariables ?
762-
form = this.handleUriVariables(ta, form, options);
762+
const formWithUriVariables = this.handleUriVariables(ta, form, options);
763763

764-
const content = await client.invokeResource(form, input);
764+
const content = await client.invokeResource(formWithUriVariables, input);
765765
try {
766-
return this.handleActionInteractionOutput(content, form, ta.output, ta.synchronous);
766+
return this.handleActionInteractionOutput(content, formWithUriVariables, ta.output, ta.synchronous);
767767
} catch (e) {
768768
const error = e instanceof Error ? e : new Error(JSON.stringify(e));
769769
throw new Error(`Error while processing action for ${ta.title}. ${error.message}`);

0 commit comments

Comments
 (0)