Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): fixing bot add Shelly Wave 1PM #6287

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,11 @@ module.exports = {
"@typescript-eslint/*": "off",
},
},
{
files: ["packages/cc/src/**/*CC.ts"],
rules: {
"@zwave-js/ccapi-validate-args": "error",
},
},
],
};
5 changes: 5 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ jobs:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}

# For linting to succeed, we need to build the eslint plugin first.
# Thanks to caching from the previous job, this should be almost a no-op
- name: Compile TypeScript code
run: yarn build $TURBO_FLAGS

- name: Run linters
run: yarn run lint $TURBO_FLAGS

Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
"source.fixAll.eslint",
"source.formatDocument"
],
"eslint.codeActionsOnSave.mode": "problems",
"eslint.codeActionsOnSave.rules": [
"!@zwave-js/no-debug-in-tests" // Don't auto-fix this rule on save, or we cannot use debug mode in tests
"!@zwave-js/no-debug-in-tests", // Don't auto-fix this rule on save, or we cannot use debug mode in tests
"!@zwave-js/ccapi-validate-args", // We may want to decide whether to fix this or not on a case-by-case basis
"!report-unused-eslint-disable-comments", // Without this, disables for the above rules would be removed
"*"
],
"eslint.rules.customizations": [
{
Expand Down
5 changes: 4 additions & 1 deletion maintenance/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const buildArgs = process.argv
// Only cc, config and projects that depend on them need codegen and partial builds
const needsNoCodegen = [
"@zwave-js/maintenance",
"@zwave-js/nvmedit",
"@zwave-js/core",
"@zwave-js/eslint-plugin",
"@zwave-js/shared",
"@zwave-js/nvmedit",
"@zwave-js/transformers",
];

Expand All @@ -22,6 +23,8 @@ const hasCodegen = ["@zwave-js/cc", "@zwave-js/config"];
// zwave-js is the main entry point, but there are projects that depend on it
const dependsOnZwaveJs = [
"@zwave-js/flash",
// The eslint plugin doesn't actually depend on zwave-js, but it needs to be built too
"@zwave-js/eslint-plugin",
// And CLI in the future
];

Expand Down
2 changes: 0 additions & 2 deletions packages/cc/maintenance/_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { generateCCExports } from "./generateCCExports";
import { generateCCValuesInterface } from "./generateCCValuesInterface";
// import { lintCCConstructors } from "./lintCCConstructor";
import { lintCCInterview } from "./lintCCInterview";
import { lintCCValidateArgs } from "./lintCCValidateArgs";

const argv = process.argv.slice(2);

const lint = () =>
Promise.all([
lintCCInterview(),
// lintCCConstructors(),
lintCCValidateArgs(),
]);
const codegen = () =>
Promise.all([
Expand Down
183 changes: 0 additions & 183 deletions packages/cc/maintenance/lintCCValidateArgs.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/cc/src/cc/AssociationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class AssociationCCAPI extends PhysicalCCAPI {
if (response) return response.groupCount;
}

@validateArgs()
public async reportGroupCount(groupCount: number): Promise<void> {
this.assertSupportsCommand(
AssociationCommand,
Expand Down Expand Up @@ -152,6 +153,7 @@ export class AssociationCCAPI extends PhysicalCCAPI {
}
}

@validateArgs()
public async sendReport(
options: AssociationCCReportSpecificOptions,
): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions packages/cc/src/cc/AssociationGroupInfoCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI {
}
}

@validateArgs()
public async reportGroupInfo(
options: AssociationGroupInfoCCInfoReportSpecificOptions,
): Promise<void> {
Expand Down
4 changes: 3 additions & 1 deletion packages/cc/src/cc/CRC16CC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import { CRC16Command } from "../lib/_Types";
// @noSetValueAPI
// @noInterview This CC only has a single encapsulation command

// @noValidateArgs - Encapsulation CCs are used internally and too frequently that we
// Encapsulation CCs are used internally and too frequently that we
// want to pay the cost of validating each call
/* eslint-disable @zwave-js/ccapi-validate-args */

@API(CommandClasses["CRC-16 Encapsulation"])
export class CRC16CCAPI extends CCAPI {
public supportsCommand(_cmd: CRC16Command): MaybeNotKnown<boolean> {
Expand Down
3 changes: 3 additions & 0 deletions packages/cc/src/cc/InclusionControllerCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import {
InclusionControllerStep,
} from "../lib/_Types";

// This CC should not be used directly from user code
/* eslint-disable @zwave-js/ccapi-validate-args */

@commandClass(CommandClasses["Inclusion Controller"])
@implementedVersion(1)
export class InclusionControllerCC extends CommandClass {
Expand Down
2 changes: 2 additions & 0 deletions packages/cc/src/cc/IndicatorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ export class IndicatorCCAPI extends CCAPI {
* - an object specifying the timeout parts. An empty object will be treated like `undefined`.
* - `undefined` to disable the timeout.
*/
@validateArgs()
public async setTimeout(
indicatorId: number,
timeout: IndicatorTimeout | string | undefined,
Expand Down Expand Up @@ -591,6 +592,7 @@ export class IndicatorCCAPI extends CCAPI {
/**
* Returns the timeout after which the given indicator will be turned off.
*/
@validateArgs()
public async getTimeout(
indicatorId: number,
): Promise<MaybeNotKnown<IndicatorTimeout>> {
Expand Down
6 changes: 4 additions & 2 deletions packages/cc/src/cc/MultiChannelCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ export class MultiChannelCCAPI extends CCAPI {
return response?.members;
}

// @noValidateArgs - Encapsulation is used internally and too frequently that we
// Encapsulation is used internally and too frequently that we
// want to pay the cost of validating each call
// eslint-disable-next-line @zwave-js/ccapi-validate-args
public async sendEncapsulated(
options: Omit<
MultiChannelCCCommandEncapsulationOptions,
Expand Down Expand Up @@ -371,8 +372,9 @@ export class MultiChannelCCAPI extends CCAPI {
return response?.endpointCount;
}

// @noValidateArgs - Encapsulation is used internally and too frequently that we
// Encapsulation is used internally and too frequently that we
// want to pay the cost of validating each call
// eslint-disable-next-line @zwave-js/ccapi-validate-args
public async sendEncapsulatedV1(encapsulated: CommandClass): Promise<void> {
this.assertSupportsCommand(
MultiChannelCommand,
Expand Down
9 changes: 5 additions & 4 deletions packages/cc/src/cc/NotificationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export class NotificationCCAPI extends PhysicalCCAPI {
}
}

function getNotificationEnumBehavior(
export function getNotificationEnumBehavior(
notificationConfig: Notification,
valueConfig: NotificationValueDefinition & { type: "state" },
): "none" | "extend" | "replace" {
Expand Down Expand Up @@ -444,9 +444,10 @@ export function getNotificationValueMetadata(
}
if (valueConfig.parameter instanceof NotificationParameterWithEnum) {
for (const [value, label] of valueConfig.parameter.values) {
metadata.states![
getNotificationStateValueWithEnum(valueConfig.value, value)
] = label;
const stateKey = enumBehavior === "replace"
? value
: getNotificationStateValueWithEnum(valueConfig.value, value);
metadata.states![stateKey] = label;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/cc/src/cc/Security2CC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ interface DecryptionResult {
securityClass: SecurityClass | undefined;
}

// @noValidateArgs - Encapsulation CCs are used internally and too frequently that we
// Encapsulation CCs are used internally and too frequently that we
// want to pay the cost of validating each call
/* eslint-disable @zwave-js/ccapi-validate-args */

@API(CommandClasses["Security 2"])
export class Security2CCAPI extends CCAPI {
public supportsCommand(_cmd: Security2Command): MaybeNotKnown<boolean> {
Expand Down
4 changes: 3 additions & 1 deletion packages/cc/src/cc/SecurityCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ const HALF_NONCE_SIZE = 8;

// TODO: Ignore commands if received via multicast

// @noValidateArgs - Encapsulation CCs are used internally and too frequently that we
// Encapsulation CCs are used internally and too frequently that we
// want to pay the cost of validating each call
/* eslint-disable @zwave-js/ccapi-validate-args */

@API(CommandClasses.Security)
export class SecurityCCAPI extends PhysicalCCAPI {
public supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {
Expand Down
Loading