Skip to content

refactor(eslint): add sort-lit-element-members rule#1712

Open
Galimede wants to merge 3 commits intomasterfrom
eslint/members-sort-plugin
Open

refactor(eslint): add sort-lit-element-members rule#1712
Galimede wants to merge 3 commits intomasterfrom
eslint/members-sort-plugin

Conversation

@Galimede
Copy link
Copy Markdown
Member

@Galimede Galimede commented Apr 1, 2026

Context

LitElement components in this codebase follow a conventional member ordering defined in docs/cc-example-component.js:
properties → static members → constructor → public methods → private methods → event handlers → lifecycle → render → sub-render → styles.

This ordering was not enforced, and several components had members out of order.

What does this PR do?

  • Adds an ESLint custom rule (lit-cc/sort-element-members) that enforces the conventional member ordering with autofix,
  • Detects LitElement classes via extends LitElement or the presence of static get properties() / static get styles(),
  • Reports on each out-of-order member individually with a descriptive message,
  • Adds @types/estree as a dev dependency for proper typing,
  • Applies the autofix across the codebase (45 files, pure reordering).

How to review?

  • Check the commits,
  • npm run test:mocha -- --grep "sort-lit-element-members" — 13 tests pass,
  • 2 reviewers should be enough.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/eslint/members-sort-plugin/index.html.

This preview will be deleted once this PR is closed.

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.

1 participant