Skip to content

chore: Add Prettier and reformat - #245

Merged
RobinBol merged 6 commits into
masterfrom
chore/prettier
Oct 23, 2026
Merged

RobinBol merged 6 commits into
masterfrom
chore/prettier

Conversation

@RobinBol

@RobinBol RobinBol commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

Wires up prettier and reformats the repo. Six commits:

  1. chore: add prettier - dependency, scripts, .prettierignore
  2. refactor: move the M/O annotations above the attribute key - 77 annotations, no formatting
  3. chore: apply prettier - pure format:write output, 82 files
  4. docs: record where the M/O annotation goes, and lowercase hex - AGENTS.md
  5. ci: enforce the Prettier formatting in CI - format:check in lint.yml
  6. refactor: use the node: prefix for core imports in lib

Skip commit 3 while reviewing. The others are real.

Why

#244 drops eslint-config-athom and every airbnb style rule with it. .prettierrc was already in the repo, unused, with no dependency and no script. It is the same config our other Node projects run.

Commit 5 matters as much as the reformat: nothing ran format:check, so prettier was advisory and the next format:write would be another hundred-file diff.

How

The M/O annotations move above the key. // Mandatory describes the attribute, not its first line, but prettier pulls a trailing comment inside the braces where it reads as if it belongs to id. Above the key it says what it means and prettier leaves it alone: the reformat touches none of the 77 moved lines.

// before                     // after
lockState: { // Mandatory     // Mandatory
  id: 0x0000,                 lockState: {
                                id: 0x0000,

Two forced deviations from that shared setup. prettier-plugin-jsdoc is out: it rewrites JSDoc types into TypeScript syntax that jsdoc 4 cannot parse, which breaks npm run build with 10 errors. Without it no JSDoc comment in lib/ changes at all. And AGENTS.md is in .prettierignore, because prettier mangles its M* emphasis markers until the file documents the opposite of what it says.

Prettier also lowercases hex, 0x001A -> 0x001a, 87 times. No option for it, so AGENTS.md follows.

Testing

format:check clean, npm test 114 passing, lint exit 0, build ok, generate-types leaves index.d.ts unchanged, tsc --noEmit exit 0.

Copilot AI left a comment

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.

🟢 Approval recommended

The supplied changes are limited to formatter tooling, behavior-preserving formatting, and annotation guidance, with no unresolved blocking issues.

No open issues 🎉

What changed in this PR

Adds Prettier to standardize formatting across the Zigbee Cluster Library while preserving runtime behavior and documentation-generation compatibility.

Changes:

  • Adds formatting scripts, a locked Prettier dependency, and exclusions for generated or formatting-sensitive files.
  • Applies consistent formatting across source, tests, documentation examples, and workflows.
  • Moves mandatory/optional annotations above multiline definition keys and documents the placement and lowercase hexadecimal conventions.
File Description
tsconfig.json Removes a trailing comma.
test/​util/​mockNode.js Formats mock factories and hexadecimal literals.
test/​testZCLError.js Formats error-response tests.
test/​testTrxSequenceNumber.js Formats sequence-number tests.
test/​testNode.js Formats node tests and bindings.
test/​testMfgSpecificCommands.js Formats manufacturer-specific command tests.
test/​testConfigureReportingRecordsStruct.js Formats reporting-record tests.
test/​testClusterResponseTimeout.js Formats response-timeout tests.
test/​ota.js Formats OTA request and response tests.
test/​onOff.js Formats on/off command tests.
test/​manual/​xiaomiHacks.js Formats custom Xiaomi data parsers.
test/​levelControl.js Formats level-control tests.
test/​iasZone.js Formats IAS Zone tests.
test/​endpointStandalone.js Formats standalone endpoint tests.
test/​doorLock.js Formats door-lock tests and frame literals.
test/​defaultResponse.js Formats default-response tests.
test/​colorControl.js Formats color-control tests.
test/​boundClusterAttributeStatus.js Formats attribute-status tests.
test/​attributeReport.js Formats attribute-report tests.
README.md Formats code examples and list spacing.
package.json Adds Prettier and formatting scripts.
package-lock.json Locks the Prettier dependency.
lib/​zclTypes.js Preserves status-table alignment with a formatter exclusion.
lib/​zclFrames.js Formats frame serialization and parsing code.
lib/​util/​index.js Formats utility expressions and class spacing.
lib/​Node.js Formats endpoint iteration and logging.
lib/​Endpoint.js Formats frame handling and hexadecimal literals.
lib/​clusters/​windowCovering.js Moves annotations above keys and formats spacing.
lib/​clusters/​touchlink.js Formats nested response definitions.
lib/​clusters/​time.js Formats the status attribute and class spacing.
lib/​clusters/​thermostatUserInterfaceConfiguration.js Normalizes class spacing.
lib/​clusters/​thermostat.js Formats bitmap attributes and class spacing.
lib/​clusters/​temperatureMeasurement.js Normalizes class spacing.
lib/​clusters/​shadeConfiguration.js Formats empty definitions and class spacing.
lib/​clusters/​scenes.js Normalizes class spacing.
lib/​clusters/​relativeHumidity.js Normalizes class spacing.
lib/​clusters/​pumpConfigurationAndControl.js Formats empty definitions and class spacing.
lib/​clusters/​pressureMeasurement.js Normalizes class spacing.
lib/​clusters/​powerProfile.js Formats empty definitions and class spacing.
lib/​clusters/​powerConfiguration.js Normalizes class spacing.
lib/​clusters/​pollControl.js Normalizes class spacing.
lib/​clusters/​ota.js Moves annotations above keys and formats definitions.
lib/​clusters/​onOffSwitch.js Normalizes class spacing.
lib/​clusters/​onOff.js Normalizes class spacing.
lib/​clusters/​occupancySensing.js Moves mandatory and conditional annotations above keys.
lib/​clusters/​multistateValue.js Formats status flags and class spacing.
lib/​clusters/​multistateOutput.js Formats status flags and class spacing.
lib/​clusters/​multistateInput.js Formats status flags and class spacing.
lib/​clusters/​metering.js Moves annotations and lowercases hexadecimal literals.
lib/​clusters/​levelControl.js Normalizes class spacing.
lib/​clusters/​index.js Formats constant-property extraction.
lib/​clusters/​illuminanceMeasurement.js Normalizes class spacing.
lib/​clusters/​illuminanceLevelSensing.js Normalizes class spacing.
lib/​clusters/​identify.js Normalizes class spacing.
lib/​clusters/​iasZone.js Formats zone-status bitmap arguments.
lib/​clusters/​iasWD.js Formats empty definitions and class spacing.
lib/​clusters/​iasACE.js Formats empty definitions and class spacing.
lib/​clusters/​groups.js Formats the name-support bitmap attribute.
lib/​clusters/​flowMeasurement.js Normalizes class spacing.
lib/​clusters/​fanControl.js Formats empty definitions and class spacing.
lib/​clusters/​electricalMeasurement.js Formats measurement and alarm bitmaps.
lib/​clusters/​diagnostics.js Normalizes class spacing.
lib/​clusters/​deviceTemperature.js Formats the temperature-alarm bitmap attribute.
lib/​clusters/​dehumidificationControl.js Formats empty definitions and class spacing.
lib/​clusters/​colorControl.js Formats capability and command bitmaps.
lib/​clusters/​binaryValue.js Formats status flags and class spacing.
lib/​clusters/​binaryOutput.js Formats status flags and class spacing.
lib/​clusters/​binaryInput.js Formats status flags and class spacing.
lib/​clusters/​basic.js Normalizes class spacing.
lib/​clusters/​ballastConfiguration.js Removes extra blank lines.
lib/​clusters/​analogValue.js Formats status flags and class spacing.
lib/​clusters/​analogOutput.js Formats status flags and class spacing.
lib/​clusters/​analogInput.js Formats status flags and class spacing.
lib/​clusters/​alarms.js Normalizes class spacing.
lib/​BoundCluster.js Formats attribute operations and command handling.
index.js Compacts data-type destructuring.
docs/​jsdoc.json Compacts the plugin array without changing plugins.
AGENTS.md Updates annotation placement and hexadecimal style guidance.
.prettierrc Removes the JSDoc-rewriting plugin configuration.
.prettierignore Excludes generated and formatting-sensitive content.
.github/​workflows/​lint.yml Removes an extra blank line.
.github/​workflows/​generate-types.yml Normalizes YAML quoting.
.github/​workflows/​docs.yml Normalizes YAML indentation and spacing.
.github/​workflows/​deploy.yml Normalizes condition indentation and spacing.

Review effort: Balanced

Copilot AI left a comment

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.

🟢 Approval recommended

The formatting setup, CI enforcement, annotation moves, and core-import updates have no identified blocking issues.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

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.

🟢 Approval recommended

The formatting setup and CI enforcement are consistent, the reviewed changes preserve behavior, and no blocking issues remain.

No open issues 🎉

Review effort: Balanced

Base automatically changed from chore/eslint-flat-config to master October 23, 2026 07:21
Picks up the style enforcement that went away with eslint-config-athom.
.prettierrc was already in the repo, unused, with no dependency and no
script to run it.

prettier-plugin-jsdoc is deliberately left out: it rewrites JSDoc type
expressions into TypeScript syntax (Promise<{ a: number[]; b: boolean }>)
that jsdoc 4 cannot parse, which breaks npm run build and with it the
docs and deploy workflows.

index.d.ts is ignored because it is generated, and AGENTS.md because
Prettier mangles its M* emphasis markers.
// Mandatory, // Optional and // Conditional describe the attribute or
command as a whole. On the opening brace Prettier pulls them inside it,
where they read as if they belong to the id field. Above the key they
survive the formatter and say what they mean.

77 annotations across five cluster files, no other change.
Pure npm run format:write output, except for the prettier-ignore guard
on the enum8Status table in lib/zclTypes.js, which keeps its column
alignment.
The annotation moves above the key, which is both what it means and what
survives Prettier. Prettier also lowercases hex digits, so the id
examples follow.
The format:check script was added alongside Prettier but nothing ran it,
so the formatting was advisory: one commit formatted by hand and the
next npm run format:write is a hundred-file diff again, which undoes the
point of the reformat.
The three EventEmitter imports now read node:events. The prefix cannot
be shadowed by a local events.js and says outright that the module is
built in.

Only lib/ here; the test files are converted alongside the node:test
migration they belong to.
@RobinBol RobinBol changed the title chore: add prettier and reformat chore: Add Prettier and reformat Oct 23, 2026
@RobinBol
RobinBol requested a balanced review from Copilot October 23, 2026 07:33

Copilot AI left a comment

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.

🟢 Approval recommended

The formatting setup and compatible core-import changes have no identified blockers, with successful validation reported in the PR.

No open issues 🎉

Review effort: Balanced

@RobinBol
RobinBol merged commit da91f20 into master Oct 23, 2026
4 checks passed
@RobinBol
RobinBol deleted the chore/prettier branch October 23, 2026 07:37
@RobinBol RobinBol added the internal Tooling, CI or docs, left out of the release notes label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Tooling, CI or docs, left out of the release notes

Development

Successfully merging this pull request may close these issues.

2 participants