Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ export default defineConfig([
// relax missing import rule to warning, as we sometimes have optional dependencies
// import "../foo" will braise a warning ,
// import "../foo.js" is the correct way to import a file that may not exist
"n/no-missing-import": "warn",
"n/no-missing-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1428

"n/no-unsupported-features/node-builtins": "warn",
"n/no-extraneous-import": "warn",
"n/no-deprecated-api": "warn",
"n/no-unpublished-import": "warn",
"n/no-process-exit": "warn",
"n/no-unsupported-features/node-builtins": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-extraneous-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-deprecated-api": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-unpublished-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-process-exit": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/hashbang": "warn",

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

// *************** Code style and best practices ***************
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
"off", // // https://github.com/eclipse-thingweb/node-wot/issues/1430
{
args: "none",
varsIgnorePattern: "Test",
Expand All @@ -121,21 +121,21 @@ export default defineConfig([
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-require-imports": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"@typescript-eslint/prefer-nullish-coalescing": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"@typescript-eslint/no-empty-object-type": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"@typescript-eslint/no-floating-promises": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430

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

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

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

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

Expand Down
5 changes: 0 additions & 5 deletions packages/binding-coap/test/coap-server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ class CoapServerTest {
).length;
const readWriteOpValuePresent = readWriteOpValueCount > 0;

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

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

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

// eslint-disable-next-line no-unused-expressions
expect(eventOpValueCountPresent).to.be.true;

// eslint-disable-next-line no-unused-expressions
expect(form.subprotocol === "cov:observe").to.be.false;
}
}
Expand Down
3 changes: 0 additions & 3 deletions packages/binding-http/src/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ export interface TuyaCustomBearerCredentialConfiguration {
interface TokenResponse {
success?: boolean;
result?: {
// eslint-disable-next-line camelcase
access_token?: string;
// eslint-disable-next-line camelcase
refresh_token?: string;
// eslint-disable-next-line camelcase
expire_time?: number;
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-http/src/oauth-token-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface TokenInformation {
* Client identifier for the OAuth 2.0 client that
* requested this token
*/
// eslint-disable-next-line camelcase -- the name is defined in the spec
// the name is defined in the spec
client_id?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/binding-http/src/routes/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default async function propertiesRoute(
res.writeHead(200);
const recordResponse: Record<string, unknown> = {};
for (const key of propMap.keys()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- map key is always present as checked above
// map key is always present as checked above
const content = propMap.get(key)!;
const value = ContentSerdes.get().contentToValue(
{ type: ContentSerdes.DEFAULT, body: await content.toBuffer() },
Expand Down
1 change: 0 additions & 1 deletion packages/binding-http/src/subscription-protocols.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable dot-notation -- we are using private functions from HttpClient */
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
Expand Down
7 changes: 0 additions & 7 deletions packages/binding-http/test/http-client-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,7 @@ class HttpClientTest2 {

const errorSpy = chai.spy();
const completeSpy = chai.spy(() => {
// eslint-disable-next-line no-unused-expressions
errorSpy.should.have.been.called.once;
// eslint-disable-next-line no-unused-expressions
completeSpy.should.have.been.called.once;
done();
});
Expand Down Expand Up @@ -528,9 +526,7 @@ class HttpClientTest2 {

const errorSpy = chai.spy();
const completeSpy = chai.spy(function () {
// eslint-disable-next-line no-unused-expressions
errorSpy.should.have.been.called.once;
// eslint-disable-next-line no-unused-expressions
completeSpy.should.have.been.called.once;
done();
server.close();
Expand Down Expand Up @@ -566,9 +562,7 @@ class HttpClientTest2 {
const subscribeSpy = chai.spy();

const eventSpy = chai.spy(async function (data: Content) {
// eslint-disable-next-line no-unused-expressions
eventSpy.should.have.been.called.once;
// eslint-disable-next-line no-unused-expressions
subscribeSpy.should.have.been.called.once;
server.close();
done();
Expand Down Expand Up @@ -621,7 +615,6 @@ class HttpClientTest2 {
sub.unsubscribe();
// wait 100 ms, so that tests fail if unsubscribe didn't work
await new Promise((resolve) => setTimeout(resolve, 100));
// eslint-disable-next-line no-unused-expressions
eventSpy.should.have.been.called.twice;
server.close();
done();
Expand Down
11 changes: 0 additions & 11 deletions packages/binding-http/test/http-server-oauth-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,18 @@ class OAuthServerTests {
}

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

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

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

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

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

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

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

called.should.eql(true);
Expand Down
1 change: 0 additions & 1 deletion packages/binding-http/test/http-server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ class HttpServerTest {

await httpServer.start(new Servient());
expect(httpServer.getPort()).to.eq(port); // port test
// eslint-disable-next-line dot-notation
expect(httpServer["supportedSecuritySchemes"][0]).to.eq("nosec");
await httpServer.stop();
}
Expand Down
3 changes: 1 addition & 2 deletions packages/binding-mbus/src/mbus-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { MBusForm } from "./mbus";
import { Content, createLoggers } from "@node-wot/core";
import { Readable } from "stream";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const MbusMaster = require("node-mbus");

const { debug, warn, error } = createLoggers("binding-mbus", "mbus-connection");
Expand Down Expand Up @@ -298,7 +297,7 @@ export class PropertyOperation {
*/
done(
base?: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
result?: any
): void {
debug("Operation done");
Expand Down
1 change: 0 additions & 1 deletion packages/binding-mbus/test/mbus-client-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe("mbus client test", () => {
"mbus:unitID": 1,
};

// eslint-disable-next-line dot-notation
client["overrideFormFromURLPath"](form);
form["mbus:unitID"].should.be.equal(2, "Form value not overridden");
if (form["mbus:offset"] != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-modbus/src/modbus-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class ModbusClientFactory implements ProtocolClientFactory {
public getClient(): ProtocolClient {
debug(`Get client for '${this.scheme}'`);
this.init();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- singleton is initialized in init()
// singleton is initialized in init()
return this.singleton!;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/binding-modbus/src/modbus-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ export class ModbusConnection {
// inform and clean up all the operations that the connection cannot be recovered
while (this.queue.length > 0) {
const transaction = this.queue.shift();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- queue.length > 0
// queue.length > 0
transaction!.operations.forEach((operation) => {
operation.failed(error instanceof Error ? error : new Error(JSON.stringify(error)));
});
}
}
} else if (this.client.isOpen && this.currentTransaction == null && this.queue.length > 0) {
// take next transaction from queue and execute
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- queue.length > 0
// queue.length > 0
this.currentTransaction = this.queue.shift()!;
try {
await this.currentTransaction.execute();
Expand Down
9 changes: 0 additions & 9 deletions packages/binding-modbus/test/modbus-client-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,16 @@ describe("Modbus client test", () => {
"modv:entity": "Coil",
};

/* eslint-disable dot-notation */
client["validateAndFillDefaultForm"](form, 0)["modv:function"].should.be.equal(1, "Wrong default read Coil");
client["validateAndFillDefaultForm"](form, 1)["modv:function"].should.be.equal(5, "Wrong write Coil");
client["validateAndFillDefaultForm"](form, 2)["modv:function"].should.be.equal(15, "Wrong write multiple Coil");
/* eslint-enable dot-notation */
});

it("use entity alias for holding registries", () => {
const form: ModbusForm = {
href: "modbus+tcp://127.0.0.1:8502/1/0/?quantity=1",
"modv:entity": "HoldingRegister",
};
/* eslint-disable dot-notation */
client["validateAndFillDefaultForm"](form)["modv:function"].should.be.equal(3, "Wrong read Holding register");
client["validateAndFillDefaultForm"](form, 2)["modv:function"].should.be.equal(
6,
Expand All @@ -73,19 +70,16 @@ describe("Modbus client test", () => {
16,
"Wrong write multiple Holding register"
);
/* eslint-enable dot-notation */
});

it("use entity alias for other entities", () => {
const form: ModbusForm = {
href: "modbus+tcp://127.0.0.1:8502/1/0?quantity=1",
"modv:entity": "DiscreteInput",
};
/* eslint-disable dot-notation */
client["validateAndFillDefaultForm"](form)["modv:function"].should.be.equal(2, "Wrong read Discrete input");
form["modv:entity"] = "InputRegister";
client["validateAndFillDefaultForm"](form)["modv:function"].should.be.equal(4, "Wrong read Input register");
/* eslint-enable dot-notation */
});

it("should convert function names", () => {
Expand All @@ -94,7 +88,6 @@ describe("Modbus client test", () => {
"modv:function": "readCoil",
};

// eslint-disable-next-line dot-notation
client["validateAndFillDefaultForm"](form)["modv:function"].should.be.equal(1, "Wrong substitution");
});

Expand All @@ -104,7 +97,6 @@ describe("Modbus client test", () => {
"modv:function": "readCoil",
};

// eslint-disable-next-line dot-notation
const result = client["validateAndFillDefaultForm"](form);
result["modv:unitID"].should.be.equal(2, "unitID value not set");
result["modv:address"].should.be.equal(2, "address value not set");
Expand All @@ -117,7 +109,6 @@ describe("Modbus client test", () => {
"modv:function": "readCoil",
};

// eslint-disable-next-line dot-notation
const result = client["validateAndFillDefaultForm"](form);
result["modv:unitID"].should.be.equal(2, "unitID value not set");
result["modv:address"].should.be.equal(2, "address value not set");
Expand Down
1 change: 0 additions & 1 deletion packages/binding-modbus/test/modbus-connection-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe("Modbus connection", () => {
it("should connect", async () => {
const connection = new ModbusConnection("127.0.0.1", 8502);
await connection.connect();
// eslint-disable-next-line no-unused-expressions
connection.client.isOpen.should.be.true;
});

Expand Down
2 changes: 0 additions & 2 deletions packages/binding-mqtt/src/mqtt-broker-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ export default class MqttBrokerServer implements ProtocolServer {
if (this.hostedBroker !== undefined) {
// When the broker is hosted, we need to close it.
// Both this.hostedBroker and this.hostedServer are defined at the same time.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
await new Promise<void>((resolve) => this.hostedServer!.close(() => resolve()));
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
await new Promise<void>((resolve) => this.hostedBroker!.close(() => resolve()));
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/binding-mqtt/src/mqtts-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default class MqttsClientFactory implements ProtocolClientFactory {
public readonly scheme: string = "mqtts";
private readonly clients: Array<ProtocolClient> = [];

// eslint-disable-next-line no-useless-constructor
constructor(private readonly config: MqttClientConfig) {}
getClient(): ProtocolClient {
const client = new MqttClient(this.config, true);
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-netconf/src/xpath2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function isPlainObject(a: unknown): boolean {
return typeof a === "object" && a !== null && !Array.isArray(a) && !(a instanceof Date);
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function json2xpath(json: any, index: number, str: Array<string>): string[] {
if (!isPlainObject(json)) {
return str;
Expand Down
1 change: 0 additions & 1 deletion packages/binding-websockets/src/ws-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { Subscription } from "rxjs/Subscription";
const { debug, warn } = createLoggers("binding-websockets", "ws-client");

export default class WebSocketClient implements ProtocolClient {
// eslint-disable-next-line no-useless-constructor
constructor() {
// TODO: implement and remove eslint-ignore-useless-constructor
}
Expand Down
1 change: 0 additions & 1 deletion packages/binding-websockets/src/wss-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ProtocolClientFactory, ProtocolClient } from "@node-wot/core";
export default class WssClientFactory implements ProtocolClientFactory {
public readonly scheme: string = "wss";

// eslint-disable-next-line no-useless-constructor
constructor() {
// TODO: implement and remove eslint-ignore-useless-constructor
}
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/cli-default-servient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export default class DefaultServient extends Servient {
// current log level
public logLevel = "info";

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public constructor(clientOnly: boolean, config?: any) {
super();

Expand Down
Loading