Skip to content

Commit 28af07c

Browse files
authored
Merge pull request #1440 from danielpeintner/issue-1430-typescript-eslint-prefer-nullish-coalescing
refactor: activate eslint typescript-eslint/prefer-nullish-coalescing
2 parents 6560614 + ab2e33c commit 28af07c

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default defineConfig([
122122
"@typescript-eslint/no-unused-vars": "off",
123123
"@typescript-eslint/no-unused-expressions": "off",
124124
"@typescript-eslint/no-require-imports": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
125-
"@typescript-eslint/prefer-nullish-coalescing": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
125+
"@typescript-eslint/prefer-nullish-coalescing": "error",
126126
"@typescript-eslint/no-empty-object-type": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
127127
"@typescript-eslint/no-floating-promises": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
128128

packages/binding-coap/src/coap-server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ export default class CoapServer implements ProtocolServer {
201201
return;
202202
}
203203

204-
if (thing.forms == null) {
205-
thing.forms = [];
206-
}
204+
thing.forms ??= [];
207205

208206
const form = this.createAffordanceForm(base, this.PROPERTY_DIR, offeredMediaType, opValues, thing.uriVariables);
209207

packages/binding-http/src/http-client-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export default class HttpClient implements ProtocolClient {
356356

357357
const url = HttpClient.fixLocalhostName(form.href);
358358

359-
requestInit.method = form["htv:methodName"] ? form["htv:methodName"] : defaultMethod;
359+
requestInit.method = form["htv:methodName"] ?? defaultMethod;
360360

361361
requestInit.headers = requestInit.headers ?? [];
362362
requestInit.headers = requestInit.headers as string[][];

packages/binding-http/src/http-server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ export default class HttpServer implements ProtocolServer {
369369
"writemultipleproperties",
370370
];
371371
}
372-
if (thing.forms == null) {
373-
thing.forms = [];
374-
}
372+
thing.forms ??= [];
375373
thing.forms.push(form);
376374
this.addUrlRewriteEndpoints(form, thing.forms);
377375
}

packages/binding-modbus/src/modbus-client.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ class ModbusSubscription {
3939
error?: (error: Error) => void,
4040
complete?: () => void
4141
) {
42-
if (!complete) {
43-
complete = () => {
44-
// do nothing.
45-
};
46-
}
42+
complete ??= () => {
43+
// do nothing.
44+
};
4745
this.interval = global.setInterval(async () => {
4846
try {
4947
const result = await client.readResource(form);

packages/binding-opcua/src/opcua-protocol-client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ export class OPCUAProtocolClient implements ProtocolClient {
257257

258258
private async _getNamespaceArray(form: OPCUAForm): Promise<string[]> {
259259
return this._withConnection(form, async (c: OPCUAConnection) => {
260-
if (!c.namespaceArray) {
261-
c.namespaceArray = await readNamespaceArray(c.session);
262-
}
260+
c.namespaceArray ??= await readNamespaceArray(c.session);
263261
return c.namespaceArray;
264262
});
265263
}

0 commit comments

Comments
 (0)