Skip to content
6 changes: 3 additions & 3 deletions src/commands/apps/channel-rules/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class ChannelRulesCreateCommand extends ControlBaseCommand {
authenticated: flags.authenticated,
batchingEnabled: flags["batching-enabled"],
batchingInterval: flags["batching-interval"],
channelNamespace: flags.name,
id: flags.name,
conflationEnabled: flags["conflation-enabled"],
conflationInterval: flags["conflation-interval"],
conflationKey: flags["conflation-key"],
Expand Down Expand Up @@ -209,7 +209,7 @@ export default class ChannelRulesCreateCommand extends ControlBaseCommand {
);
}

if (createdNamespace.batchingInterval !== undefined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be falsy checks?

        if (!createdNamespace.batchingInterval) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using !createdNamespace.batchingInterval would be problematic because batchingInterval could legitimately be 0 (a valid number), and !0 evaluates to true, which would incorrectly skip displaying a valid interval of 0. The typeof === "number" check is the safest approach because:

  1. It handles null (from API) → typeof null === "object" → skipped ✓
  2. It handles undefined (absent) → typeof undefined === "undefined" → skipped ✓
  3. It handles 0 (valid interval) → typeof 0 === "number" → displayed ✓
  4. It satisfies ESLint's eqeqeq rule (no loose equality)

if (createdNamespace.batchingInterval != null) {
this.log(
`Batching Interval: ${chalk.green(createdNamespace.batchingInterval.toString())}`,
);
Expand All @@ -221,7 +221,7 @@ export default class ChannelRulesCreateCommand extends ControlBaseCommand {
);
}

if (createdNamespace.conflationInterval !== undefined) {
if (createdNamespace.conflationInterval != null) {
this.log(
`Conflation Interval: ${chalk.green(createdNamespace.conflationInterval.toString())}`,
);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/apps/channel-rules/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default class ChannelRulesDeleteCommand extends ControlBaseCommand {
);
}

if (namespace.batchingInterval !== undefined) {
if (namespace.batchingInterval != null) {
this.log(
`Batching Interval: ${chalk.green(namespace.batchingInterval.toString())}`,
);
Expand All @@ -147,7 +147,7 @@ export default class ChannelRulesDeleteCommand extends ControlBaseCommand {
);
}

if (namespace.conflationInterval !== undefined) {
if (namespace.conflationInterval != null) {
this.log(
`Conflation Interval: ${chalk.green(namespace.conflationInterval.toString())}`,
);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/apps/channel-rules/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default class ChannelRulesUpdateCommand extends ControlBaseCommand {
);
}

if (updatedNamespace.batchingInterval !== undefined) {
if (updatedNamespace.batchingInterval != null) {
this.log(
`Batching Interval: ${chalk.green(updatedNamespace.batchingInterval.toString())}`,
);
Expand All @@ -317,7 +317,7 @@ export default class ChannelRulesUpdateCommand extends ControlBaseCommand {
);
}

if (updatedNamespace.conflationInterval !== undefined) {
if (updatedNamespace.conflationInterval != null) {
this.log(
`Conflation Interval: ${chalk.green(updatedNamespace.conflationInterval.toString())}`,
);
Expand Down
2 changes: 1 addition & 1 deletion src/services/control-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class ControlApi {
authenticated?: boolean;
batchingEnabled?: boolean;
batchingInterval?: number;
channelNamespace: string;
id: string;
conflationEnabled?: boolean;
conflationInterval?: number;
conflationKey?: string;
Comment thread
sacOO7 marked this conversation as resolved.
Expand Down
Loading