Skip to content

Commit d08d5d2

Browse files
Avoid eslint warnings (#1431)
* refactor: turn off some eslint warnings * refactor(core): fix warning Unused eslint-disable directive * refactor(binding-coap): fix warning Unused eslint-disable directive * refactor(binding-http): fix warning Unused eslint-disable directive * refactor(binding-mbus): fix warning Unused eslint-disable directive * refactor(binding-modbus): fix warning Unused eslint-disable directive * refactor(binding-mqtt): fix warning Unused eslint-disable directive * refactor(binding-netconf): fix warning Unused eslint-disable directive * refactor(binding-websockets): fix warning Unused eslint-disable directive * refactor(cli): fix warning Unused eslint-disable directive * refactor(examples): fix warning Unused eslint-disable directive
1 parent 736f280 commit d08d5d2

32 files changed

+28
-98
lines changed

eslint.config.mjs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,22 @@ export default defineConfig([
7979
// relax missing import rule to warning, as we sometimes have optional dependencies
8080
// import "../foo" will braise a warning ,
8181
// import "../foo.js" is the correct way to import a file that may not exist
82-
"n/no-missing-import": "warn",
82+
"n/no-missing-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1428
8383

84-
"n/no-unsupported-features/node-builtins": "warn",
85-
"n/no-extraneous-import": "warn",
86-
"n/no-deprecated-api": "warn",
87-
"n/no-unpublished-import": "warn",
88-
"n/no-process-exit": "warn",
84+
"n/no-unsupported-features/node-builtins": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
85+
"n/no-extraneous-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
86+
"n/no-deprecated-api": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
87+
"n/no-unpublished-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
88+
"n/no-process-exit": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
8989
"n/hashbang": "warn",
9090

9191
// *************** Ensure that only used dependencies are imported ***************
92-
"extraneous-dependencies/no-extraneous-dependencies": "warn",
92+
"extraneous-dependencies/no-extraneous-dependencies": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
9393

9494
// *************** Code style and best practices ***************
9595
"unused-imports/no-unused-imports": "error",
9696
"unused-imports/no-unused-vars": [
97-
"warn",
97+
"off", // // https://github.com/eclipse-thingweb/node-wot/issues/1430
9898
{
9999
args: "none",
100100
varsIgnorePattern: "Test",
@@ -121,21 +121,21 @@ export default defineConfig([
121121
"@typescript-eslint/no-use-before-define": "error",
122122
"@typescript-eslint/no-unused-vars": "off",
123123
"@typescript-eslint/no-unused-expressions": "off",
124-
"@typescript-eslint/no-require-imports": "warn",
125-
"@typescript-eslint/prefer-nullish-coalescing": "warn",
126-
"@typescript-eslint/no-empty-object-type": "warn",
127-
"@typescript-eslint/no-floating-promises": "warn",
124+
"@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
126+
"@typescript-eslint/no-empty-object-type": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
127+
"@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": "warn",
130+
"prefer-const": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
131131

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

136136
"no-use-before-define": "error",
137137

138-
"no-unused-private-class-members": "warn",
138+
"no-unused-private-class-members": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
139139
"no-prototype-builtins": "off",
140140
"no-case-declarations": "off",
141141

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ class CoapServerTest {
686686
).length;
687687
const readWriteOpValuePresent = readWriteOpValueCount > 0;
688688

689-
// eslint-disable-next-line no-unused-expressions
690689
expect(observeOpValuePresent && readWriteOpValuePresent).to.not.be.true;
691690

692691
if (property.observable !== true) {
@@ -702,16 +701,12 @@ class CoapServerTest {
702701
for (const event of Object.values(td.events!)) {
703702
for (const form of event.forms) {
704703
const opValues = form.op!;
705-
// eslint-disable-next-line no-unused-expressions
706704
expect(opValues.length > 0).to.be.true;
707705

708706
const eventOpValueCount = filterEventOperations(opValues as Array<string>).length;
709707
const eventOpValueCountPresent = eventOpValueCount > 0;
710708

711-
// eslint-disable-next-line no-unused-expressions
712709
expect(eventOpValueCountPresent).to.be.true;
713-
714-
// eslint-disable-next-line no-unused-expressions
715710
expect(form.subprotocol === "cov:observe").to.be.false;
716711
}
717712
}

packages/binding-http/src/credential.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,8 @@ export interface TuyaCustomBearerCredentialConfiguration {
166166
interface TokenResponse {
167167
success?: boolean;
168168
result?: {
169-
// eslint-disable-next-line camelcase
170169
access_token?: string;
171-
// eslint-disable-next-line camelcase
172170
refresh_token?: string;
173-
// eslint-disable-next-line camelcase
174171
expire_time?: number;
175172
};
176173
}

packages/binding-http/src/oauth-token-validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface TokenInformation {
4747
* Client identifier for the OAuth 2.0 client that
4848
* requested this token
4949
*/
50-
// eslint-disable-next-line camelcase -- the name is defined in the spec
50+
// the name is defined in the spec
5151
client_id?: string;
5252
}
5353

packages/binding-http/src/routes/properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default async function propertiesRoute(
6464
res.writeHead(200);
6565
const recordResponse: Record<string, unknown> = {};
6666
for (const key of propMap.keys()) {
67-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- map key is always present as checked above
67+
// map key is always present as checked above
6868
const content = propMap.get(key)!;
6969
const value = ContentSerdes.get().contentToValue(
7070
{ type: ContentSerdes.DEFAULT, body: await content.toBuffer() },

packages/binding-http/src/subscription-protocols.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable dot-notation -- we are using private functions from HttpClient */
21
/********************************************************************************
32
* Copyright (c) 2020 Contributors to the Eclipse Foundation
43
*

packages/binding-http/test/http-client-test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,7 @@ class HttpClientTest2 {
495495

496496
const errorSpy = chai.spy();
497497
const completeSpy = chai.spy(() => {
498-
// eslint-disable-next-line no-unused-expressions
499498
errorSpy.should.have.been.called.once;
500-
// eslint-disable-next-line no-unused-expressions
501499
completeSpy.should.have.been.called.once;
502500
done();
503501
});
@@ -528,9 +526,7 @@ class HttpClientTest2 {
528526

529527
const errorSpy = chai.spy();
530528
const completeSpy = chai.spy(function () {
531-
// eslint-disable-next-line no-unused-expressions
532529
errorSpy.should.have.been.called.once;
533-
// eslint-disable-next-line no-unused-expressions
534530
completeSpy.should.have.been.called.once;
535531
done();
536532
server.close();
@@ -566,9 +562,7 @@ class HttpClientTest2 {
566562
const subscribeSpy = chai.spy();
567563

568564
const eventSpy = chai.spy(async function (data: Content) {
569-
// eslint-disable-next-line no-unused-expressions
570565
eventSpy.should.have.been.called.once;
571-
// eslint-disable-next-line no-unused-expressions
572566
subscribeSpy.should.have.been.called.once;
573567
server.close();
574568
done();
@@ -621,7 +615,6 @@ class HttpClientTest2 {
621615
sub.unsubscribe();
622616
// wait 100 ms, so that tests fail if unsubscribe didn't work
623617
await new Promise((resolve) => setTimeout(resolve, 100));
624-
// eslint-disable-next-line no-unused-expressions
625618
eventSpy.should.have.been.called.twice;
626619
server.close();
627620
done();

packages/binding-http/test/http-server-oauth-tests.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,18 @@ class OAuthServerTests {
7171
}
7272

7373
@test async "should configure oauth"() {
74-
/* eslint-disable dot-notation */
7574
this.server["supportedSecuritySchemes"].should.contain("oauth2");
7675
expect(this.server["oAuthValidator"]).to.be.instanceOf(EndpointValidator);
77-
/* eslint-enable dot-notation */
7876
}
7977

8078
@test async "should call oauth validation"() {
8179
let called = false;
8280

83-
/* eslint-disable dot-notation */
8481
expect(this.server["oAuthValidator"]).to.not.be.equal(undefined, "OAuth validator not set");
85-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8682
this.server["oAuthValidator"]!.validate = async (token, scopes, clients) => {
8783
called = true;
8884
return true;
8985
};
90-
/* eslint-enable dot-notation */
9186
await fetch("http://localhost:8080/testoauth/properties/test");
9287

9388
called.should.eql(true);
@@ -96,14 +91,11 @@ class OAuthServerTests {
9691
@test async "should send unauthorized if oauth validation fails"() {
9792
let called = false;
9893

99-
/* eslint-disable dot-notation */
10094
expect(this.server["oAuthValidator"]).to.not.be.equal(undefined, "OAuth validator not set");
101-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10295
this.server["oAuthValidator"]!.validate = async (token, scopes, clients) => {
10396
called = true;
10497
return false;
10598
};
106-
/* eslint-enable dot-notation */
10799
const response = await fetch("http://localhost:8080/testoauth/properties/test");
108100

109101
called.should.eql(true);
@@ -114,14 +106,11 @@ class OAuthServerTests {
114106
@test async "should send error if oauth validation throws"() {
115107
let called = false;
116108

117-
/* eslint-disable dot-notation */
118109
expect(this.server["oAuthValidator"]).to.not.be.equal(undefined, "OAuth validator not set");
119-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
120110
this.server["oAuthValidator"]!.validate = async (token, scopes, clients) => {
121111
called = true;
122112
return false;
123113
};
124-
/* eslint-enable dot-notation */
125114
const response = await fetch("http://localhost:8080/testoauth/properties/test");
126115

127116
called.should.eql(true);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ class HttpServerTest {
408408

409409
await httpServer.start(new Servient());
410410
expect(httpServer.getPort()).to.eq(port); // port test
411-
// eslint-disable-next-line dot-notation
412411
expect(httpServer["supportedSecuritySchemes"][0]).to.eq("nosec");
413412
await httpServer.stop();
414413
}

packages/binding-mbus/src/mbus-connection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import { MBusForm } from "./mbus";
1717
import { Content, createLoggers } from "@node-wot/core";
1818
import { Readable } from "stream";
19-
// eslint-disable-next-line @typescript-eslint/no-var-requires
2019
const MbusMaster = require("node-mbus");
2120

2221
const { debug, warn, error } = createLoggers("binding-mbus", "mbus-connection");
@@ -298,7 +297,7 @@ export class PropertyOperation {
298297
*/
299298
done(
300299
base?: number,
301-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
300+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
302301
result?: any
303302
): void {
304303
debug("Operation done");

0 commit comments

Comments
 (0)