Skip to content

refactor: move sort-lit-get-properties from Prettier to ESLint#1699

Open
Galimede wants to merge 3 commits intomasterfrom
eslint/move-prettier-plugin-to-eslint
Open

refactor: move sort-lit-get-properties from Prettier to ESLint#1699
Galimede wants to merge 3 commits intomasterfrom
eslint/move-prettier-plugin-to-eslint

Conversation

@Galimede
Copy link
Member

@Galimede Galimede commented Mar 18, 2026

Context

The sort-lit-get-properties rule sorts properties inside static get properties() in Lit components.
This is a structural/organizational concern (ordering class members), not a formatting concern — it doesn't belong in Prettier.

Having it as a Prettier plugin also required a parser merge hack to avoid conflicts between plugins sharing the same Babel parser. Moving it to ESLint removes that complexity entirely.

What does this PR do?

  • Adds an ESLint custom rule (lit-cc/sort-get-properties) that does the same sorting: spreads first, then alphabetical, then _-prefixed last,
  • Creates the lit-cc ESLint plugin to host lit-specific custom rules,
  • Removes the Prettier plugin, its test, and the parser merge hack,
  • Simplifies prettier.config.js (plugins as strings, no more import/wrapper).

How to review?

  • Check the commits,
  • npm run test:mocha -- --grep "eslint lit" — 5 tests pass,
  • 2 reviewers should be enough.

@Galimede Galimede force-pushed the eslint/move-prettier-plugin-to-eslint branch 2 times, most recently from 6ebc6a4 to 201c7c7 Compare March 18, 2026 14:56
@github-actions
Copy link
Contributor

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

This preview will be deleted once this PR is closed.

@Galimede Galimede force-pushed the eslint/move-prettier-plugin-to-eslint branch from 201c7c7 to 05ba9af Compare March 18, 2026 15:16
Migrate the sort-lit-get-properties logic from Prettier plugin to ESLint
custom rule, as property ordering is a structural concern, not formatting.
The property sorting logic has been migrated to an ESLint rule.
Remove the Prettier plugin, its test, and simplify the config.
@Galimede Galimede force-pushed the eslint/move-prettier-plugin-to-eslint branch from 05ba9af to 7faa1d4 Compare March 18, 2026 15:17
Copy link
Contributor

@florian-sanders-cc florian-sanders-cc left a comment

Choose a reason for hiding this comment

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

All good, mostly nitpicks and I think the last commit should be a refactor, it shouldn't be part of the changelog since there's no impact on the consumers of this project 👍 (EDIT: same for the first commit as well)

I really like the change, you've convinced me it's fine / better to do this with ESLint and I like that you also added tests 🙌

Comment on lines +1 to +2
/** @import { Rule } from 'eslint' */
/** @import { Identifier } from 'estree' */
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: merge these comments

}
}

const sorted = [...properties].sort((pA, pB) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: use toSorted instead

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.

2 participants