Skip to content

Conversation

@asamuzaK
Copy link
Contributor

Fix #286

Motivation

We will apply a code style that largely matches jsdom's.
The objective is to unify code styling across the jsdom project to improve readability and maintainability, as well as to facilitate debugging.

Changes from the existing code style

  • Copied and applied .editorconfig from jsdom.
  • Aligned rules in eslint.config.mjs to nearly match jsdom's.
  • Use function declarations (function foo() {}) instead of arrow function expressions (const foo = () => {}).
  • Unified the file structure to the following order:
    • Imports (require())
    • Top-level Constants & Configuration
    • Functions
    • Module Exports

Differences from jsdom

  • We will continue using Prettier.
    • Added "consistent-return": "off" to the rules to accommodate Prettier usage.
    • As a side note, I personally believe jsdom should consider using Prettier as well.
    • "func-style": "off" for test files.

this._readonly = true;
// FIXME: The `_readonly` flag should initially be `false` to be editable,
// but should eventually be set to `true`.
this._readonly = false;
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a non-style change. Are there others like it I should keep an eye on?

Perhaps it would be better to separate the non-style changes into a different PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

globals: globals.node
},
rules: {
"func-style": "off"
Copy link
Member

Choose a reason for hiding this comment

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

Why not also update test files? What is the benefit of the inconsistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added just in case. Removed.

@asamuzaK asamuzaK requested a review from domenic January 12, 2026 12:33
@domenic domenic merged commit b7cb58d into jsdom:main Jan 13, 2026
3 checks passed
@asamuzaK asamuzaK deleted the code branch January 13, 2026 02:40
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.

Unify code style with jsdom

2 participants