Skip to content

Commit

Permalink
fix: use correct lint command on CI, fix lint errors, disable wotan
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Aug 29, 2020
1 parent bf74518 commit fc67029
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
build/
node_modules/
**/node_modules/
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
Note to future self:
If ESLint is ever extremely slow again, check if there are .js and/or .map files in the source directories
and delete them:
```bash
find . -type f -name "*.map" | grep ./packages | grep /src/ | xargs -n1 rm
find . -type f -name "*.js" | grep ./packages | grep /src/ | xargs -n1 rm
```
Running `TIMING=1 DEBUG=eslint:cli-engine npm run lint:ts` helps detect the problem
*/

module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
Expand Down Expand Up @@ -78,6 +92,9 @@ module.exports = {
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",

// Although this rule makes sense, it takes about a second to execute (and we don't need it)
"@typescript-eslint/no-implied-eval": "off",

"@typescript-eslint/explicit-module-boundary-types": [
"warn",
{ allowArgumentsExplicitlyTypedAsAny: true },
Expand Down
2 changes: 1 addition & 1 deletion .fimbullinter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ config: .wotanrc.yaml
exclude:
#- "**/*.d.ts"
- "**/*.test.ts"
project: tsconfig.build.json
project: tsconfig.eslint.json
2 changes: 1 addition & 1 deletion .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: npx lerna run build

- name: Lint TypeScript code
run: npx lerna run lint
run: npm run lint

- name: Lint config files
run: npx lerna run lint:config
Expand Down
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@types/serialport": "^8.0.1",
"@types/triple-beam": "^1.3.1",
"@types/yargs": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"ansi-colors": "^4.1.1",
"axios": "^0.19.2",
"clipboardy": "^2.3.0",
Expand Down Expand Up @@ -97,9 +97,9 @@
"coverage": "npm run test:ts -- --collect-coverage",
"coverage:ci": "npm run test:ci -- --collect-coverage",
"show-coverage": "npm run coverage && start ./coverage/index.html",
"lint:ts": "eslint --ext .ts \"packages/**/src/**\"",
"lint:ts": "eslint --ext .ts \"packages/*/src/**\"",
"lint:wotan": "wotan",
"lint": "npm run lint:ts && npm run lint:wotan",
"lint": "npm run lint:ts",
"implemented_ccs": "ts-node maintenance/implemented_ccs.ts",
"gh-cc-table": "npm run implemented_ccs -- --flavor=github --only-incomplete",
"usbdebug": "cmd.exe /c \"test\\usbdebug.bat\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/log/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const logMessagePrinter: Format = {
),
);
}
info[MESSAGE] = lines.join("\n");
info[MESSAGE as any] = lines.join("\n");
return info;
}) as unknown) as TransformFunction,
};
Expand Down
13 changes: 12 additions & 1 deletion packages/zwave-js/src/lib/commandclass/AlarmSensorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class AlarmSensorCCAPI extends CCAPI {
* Retrieves the current value from this sensor
* @param sensorType The (optional) sensor type to retrieve the value for
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public async get(sensorType?: AlarmSensorType) {
this.assertSupportsCommand(AlarmSensorCommand, AlarmSensorCommand.Get);

Expand Down Expand Up @@ -203,9 +204,19 @@ export class AlarmSensorCC extends CommandClass {
direction: "outbound",
});
const currentValue = await api.get(type);
let message = `received current value for ${sensorName}:
state: ${currentValue.state}`;
if (currentValue.severity != undefined) {
message += `
severity: ${currentValue.severity}`;
}
if (currentValue.duration != undefined) {
message += `
duration: ${currentValue.duration}`;
}
log.controller.logNode(node.id, {
endpoint: this.endpointIndex,
message: `received current value for ${sensorName}: ${currentValue}`,
message,
direction: "inbound",
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/commandclass/MultiChannelCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
lookupSpecificDeviceClass,
SpecificDeviceClass,
} from "@zwave-js/config";
import type { ValueID } from "@zwave-js/core";
import {
CommandClasses,
encodeBitMask,
Expand All @@ -16,7 +17,6 @@ import {
ZWaveError,
ZWaveErrorCodes,
} from "@zwave-js/core";
import type { ValueID } from "@zwave-js/core";
import { getEnumMemberName, num2hex } from "@zwave-js/shared";
import type { Driver } from "../driver/Driver";
import log from "../log";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ interface ApplicationCommandRequestOptions extends MessageBaseOptions {
@messageTypes(MessageType.Request, FunctionType.ApplicationCommand)
// This does not expect a response. The controller sends us this when a node sends a command
@priority(MessagePriority.Normal)
export class ApplicationCommandRequest extends Message
export class ApplicationCommandRequest
extends Message
implements ICommandClassContainer {
public constructor(
driver: Driver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export interface AssignReturnRouteRequestOptions extends MessageBaseOptions {
}

@expectedResponse(testResponseForAssignReturnRouteRequest)
export class AssignReturnRouteRequest extends AssignReturnRouteRequestBase
export class AssignReturnRouteRequest
extends AssignReturnRouteRequestBase
implements INodeQuery {
public constructor(
driver: Driver,
Expand Down
13 changes: 7 additions & 6 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,15 @@ export class ZWaveController extends EventEmitter {
newNode.isSecure = true;
} catch (e: unknown) {
let errorMessage = `Security bootstrapping failed, the node is included insecurely`;
if (
!(e instanceof ZWaveError) ||
(e.code !==
if (!(e instanceof ZWaveError)) {
errorMessage += `: ${e as any}`;
} else if (
e.code !==
ZWaveErrorCodes.Controller_MessageDropped &&
e.code !==
ZWaveErrorCodes.Controller_NodeTimeout)
e.code !==
ZWaveErrorCodes.Controller_NodeTimeout
) {
errorMessage += `: ${e}`;
errorMessage += `: ${e.message}`;
}
log.controller.logNode(
newNode.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export interface DeleteReturnRouteRequestOptions extends MessageBaseOptions {
}

@expectedResponse(testResponseForDeleteReturnRouteRequest)
export class DeleteReturnRouteRequest extends DeleteReturnRouteRequestBase
export class DeleteReturnRouteRequest
extends DeleteReturnRouteRequestBase
implements INodeQuery {
public constructor(
driver: Driver,
Expand Down
6 changes: 4 additions & 2 deletions packages/zwave-js/src/lib/controller/SendDataMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,10 @@ interface SendDataMulticastRequestOptions<CCType extends CommandClass>

@expectedResponse(testResponseForSendDataMulticastRequest)
export class SendDataMulticastRequest<
CCType extends CommandClass = CommandClass
> extends SendDataMulticastRequestBase implements ICommandClassContainer {
CCType extends CommandClass = CommandClass
>
extends SendDataMulticastRequestBase
implements ICommandClassContainer {
public constructor(
driver: Driver,
options: SendDataMulticastRequestOptions<CCType>,
Expand Down

0 comments on commit fc67029

Please sign in to comment.