Skip to content

Add stricter compiler options - #103

Merged
heavyrubberslave merged 5 commits into
mainfrom
chore/ts-and-lint-hardening
Aug 5, 2026
Merged

heavyrubberslave merged 5 commits into
mainfrom
chore/ts-and-lint-hardening

Conversation

@heavyrubberslave

@heavyrubberslave heavyrubberslave commented Aug 2, 2026

Copy link
Copy Markdown
Member

Fixes #73 and #61

Summary by CodeRabbit

  • Refactor
    • Standardized TypeScript type declarations and strengthened strict compiler checks.
    • Improved type inference across device, transport, repository, and protocol components.
    • Simplified discriminator setup while preserving existing device and attribute mappings.
  • Bug Fixes
    • Improved safe handling of empty event queues.
    • Clarified protocol responses that do not return a value.
  • Chores
    • Updated linting rules and arrow-function linting support.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a7067b70-d4cf-4e4b-8d75-8314c6a34544

📥 Commits

Reviewing files that changed from the base of the PR and between 972748c and 794ab4d.

📒 Files selected for processing (2)
  • src/app.ts
  • src/serialization/discriminator/objectDiscriminator.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app.ts
  • src/serialization/discriminator/objectDiscriminator.ts

📝 Walkthrough

Walkthrough

The PR enables stricter TypeScript and ESLint settings, converts interfaces to type aliases, updates discriminator construction, simplifies inferred typings, and makes small runtime-safe callback and property changes.

Changes

TypeScript strictness and type-style migration

Layer / File(s) Summary
Compiler and lint configuration
eslint.config.ts, package.json, tsconfig.json
The project adopts stricter TypeScript ESLint presets and rules, explicit strict compiler options, and an updated arrow-function plugin.
Shared contracts and inferred fields
src/app.ts, src/controller/..., src/device/..., src/transport/..., src/repository/..., src/socket/types.ts, src/settings/..., src/logging/Logger.ts, src/util/...
Public interfaces become equivalent type aliases. Several fields and constructor parameters now use inferred types. Equivalent index signatures use Record.
Protocol and virtual-device type models
src/device/protocol/..., src/device/transport/..., src/serial/frameParser.ts
Protocol messages, responses, attributes, and factory contracts use type aliases, intersections, records, and updated undefined response typing.
Instance-based discriminator wiring
src/serialization/discriminator/..., src/app.ts, src/controller/getDeviceController.ts, src/entity/deviceList.ts
ObjectDiscriminator receives mappings through its constructor and exposes instance methods. Device consumers use configured discriminator instances.
Runtime callback and property adjustments
src/automation/scriptRuntime.ts, src/device/updater/bufferedDeviceUpdater.ts, src/device/protocol/virtual/..., src/device/protocol/zc95/zc95Device.ts
Queue processing handles empty removals, buffered updates use a static arrow-function property, refresh intervals use readonly fields, and attribute removal uses Reflect.deleteProperty.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: minor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes broad ESLint changes, dependency updates, and runtime or public API refactors beyond issue [#73]. Limit this PR to the compiler option changes, or link issues that explicitly cover the additional ESLint, API, and runtime changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary objective of enabling stricter TypeScript compiler options.
Linked Issues check ✅ Passed The PR enables all eight compiler options requested in issue [#73]; existing noImplicitAny remains enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ts-and-lint-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- Fix 10 ESLint errors surfaced by the stricter linting rules
  (non-null assertion, invalid void type, strict-boolean-expressions,
  class-literal-property-style, dynamic delete, extraneous static
  class)
- Switch consistent-type-definitions to prefer type over interface,
  since interfaces don't get an implicit index signature the way type
  aliases do, which was causing real type errors (and, more
  importantly, was silently defeating attribute key/value type
  checking in getAttribute/setAttribute across the whole device
  hierarchy - K extended plain string instead of AttributeKeyOf<T>)
- Remove now-unnecessary explicit index signatures and extends
  workarounds that were needed while interface was still enforced
- ObjectDiscriminator: convert from a static-only abstract base class
  (extended by DeviceDiscriminator/GenericDeviceAttributeDiscriminator
  overriding a static discriminatorMap) to a concrete class taking
  discriminatorMap via constructor, with the two former subclasses
  becoming pre-built exported instances instead. Removes the need
  for no-extraneous-class's allowStaticOnly.
- BufferedDeviceUpdater.handleUpdate: no longer needs an explicit
  `this: void` parameter to satisfy unbound-method. Removes the need
  for no-invalid-void-type's allowAsThisParameter.
@heavyrubberslave
heavyrubberslave marked this pull request as ready for review August 3, 2026 19:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/device/protocol/virtual/audio/piperVirtualDeviceLogic.ts`:
- Line 110: Restore the abstract accessor contract by replacing the readonly
refreshInterval properties with getters returning the existing values: 175 in
src/device/protocol/virtual/audio/piperVirtualDeviceLogic.ts:110,
src/device/protocol/virtual/audio/ttsVirtualDeviceLogic.ts:83, and
src/device/protocol/virtual/display/displayVirtualDeviceLogic.ts:20; return 100
in
src/device/protocol/virtual/randomGenerator/randomGeneratorVirtualDeviceLogic.ts:27.
Update each virtual device logic class without changing the interval values.

In `@src/serialization/discriminator/objectDiscriminator.ts`:
- Around line 14-21: Update the application setup around the existing
createClassTransformerTypeDiscriminator call to use the exported configured
DeviceDiscriminator instance rather than constructing or referencing the former
default discriminator class. Invoke
createClassTransformerTypeDiscriminator('type') through that instance while
preserving the existing transformer configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 03fdac27-9221-4ef3-949e-bc8e523a7b80

📥 Commits

Reviewing files that changed from the base of the PR and between cda97d1 and 972748c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (60)
  • eslint.config.ts
  • package.json
  • src/app.ts
  • src/automation/scriptRuntime.ts
  • src/automation/scriptVm.ts
  • src/automation/scriptVmFactory.ts
  • src/controller/automation/createScriptController.ts
  • src/controller/automation/deleteScriptController.ts
  • src/controller/automation/getScriptController.ts
  • src/controller/controllerInterface.ts
  • src/controller/getDeviceController.ts
  • src/device/attribute/listDeviceAttribute.ts
  • src/device/bleDevice.ts
  • src/device/detectedDeviceOfferQueue.ts
  • src/device/deviceManager.ts
  • src/device/genericDeviceUpdater.ts
  • src/device/protocol/airotic/airoticDevice.ts
  • src/device/protocol/deviceProtocol.ts
  • src/device/protocol/estim2b/estim2bDevice.ts
  • src/device/protocol/estim2b/estim2bProtocol.ts
  • src/device/protocol/messageResponseHandler.ts
  • src/device/protocol/slvCtrlPlus/slvCtrlProtocol.ts
  • src/device/protocol/slvCtrlPlus/slvCtrlProtocolLegacy.ts
  • src/device/protocol/virtual/audio/piperVirtualDeviceLogic.ts
  • src/device/protocol/virtual/audio/ttsVirtualDeviceLogic.ts
  • src/device/protocol/virtual/display/displayVirtualDeviceLogic.ts
  • src/device/protocol/virtual/genericVirtualDeviceFactory.ts
  • src/device/protocol/virtual/randomGenerator/randomGeneratorVirtualDeviceLogic.ts
  • src/device/protocol/virtual/virtualDeviceFactory.ts
  • src/device/protocol/virtual/virtualDeviceLogicFactory.ts
  • src/device/protocol/zc95/zc95Device.ts
  • src/device/protocol/zc95/zc95MessageFactory.ts
  • src/device/protocol/zc95/zc95Protocol.ts
  • src/device/protocol/zc95/zc95SerialDeviceProvider.ts
  • src/device/provider/deviceProvider.ts
  • src/device/provider/deviceProviderFactory.ts
  • src/device/provider/deviceProviderManager.ts
  • src/device/transport/bleDeviceTransport.ts
  • src/device/transport/deviceBidirectionalTransport.ts
  • src/device/transport/deviceReadableTransport.ts
  • src/device/transport/deviceWritableTransport.ts
  • src/device/transport/serialPortObserver.ts
  • src/device/updater/bufferedDeviceUpdater.ts
  • src/device/updater/deviceUpdaterInterface.ts
  • src/entity/deviceList.ts
  • src/health/serializedTypes.ts
  • src/logging/Logger.ts
  • src/repository/automationScriptRepositoryInterface.ts
  • src/repository/deviceRepositoryInterface.ts
  • src/serial/frameParser.ts
  • src/serialization/discriminator/deviceDiscriminator.ts
  • src/serialization/discriminator/genericDeviceAttributeDiscriminator.ts
  • src/serialization/discriminator/objectDiscriminator.ts
  • src/settings/deviceSource.ts
  • src/settings/knownDevice.ts
  • src/socket/types.ts
  • src/types.d.ts
  • src/util/async.ts
  • src/util/devNullStream.ts
  • tsconfig.json

Comment thread src/device/protocol/virtual/audio/piperVirtualDeviceLogic.ts
Comment thread src/serialization/discriminator/objectDiscriminator.ts
@heavyrubberslave
heavyrubberslave merged commit 4acc487 into main Aug 5, 2026
11 of 13 checks passed
@heavyrubberslave
heavyrubberslave deleted the chore/ts-and-lint-hardening branch August 5, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check TS compilerOptions

1 participant