Skip to content

Add initial implementation extracted from frontend-clients - #1

Open
diogoquintas wants to merge 1 commit into
masterfrom
feature/extract-from-frontend-clients
Open

Add initial implementation extracted from frontend-clients#1
diogoquintas wants to merge 1 commit into
masterfrom
feature/extract-from-frontend-clients

Conversation

@diogoquintas

Copy link
Copy Markdown

Summary

Extracts @frontend-clients/eslint-plugin-sort-declarations from the frontend-clients monorepo into this standalone repository, so the plugin can be versioned and published independently. The structure mirrors uphold/eslint-plugin-sort-imports-requires.

The package takes the unscoped name eslint-plugin-sort-declarations, which changes the rule prefix from @frontend-clients/sort-declarations/* to sort-declarations/*.

What's here

  • The three rules — sort-module-declarations, sort-variable-declarations and sort-export-declarations — plus the shared lib/utils.js, functionally unchanged.
  • meta.namespace: 'sort-declarations'.
  • .github/workflows/ci.yml (node 20/22/24) and release.yaml, plus .release-it.json and .gitignore, taken from the reference repo.
  • version starts at 0.0.0 so the release workflow produces the first published version.
  • Dogfooding through a flat config in eslint.config.js.

Deviations from the reference repo

Here Reference Why
peerDependencies eslint >=8 eslint >=9 frontend-clients runs eslint 8.57 with eslintrc
dev eslint 8.57.0 ^10.0.0 keeps RuleTester behaviour identical to the consumer
@typescript-eslint/parser present absent lib/utils.js handles TSTypeQuery, so the tests need it
lib/index.d.ts absent present worth adding as a follow-up

The flat config runs under eslint 8.57 via ESLINT_USE_FLAT_CONFIG=true.

Verification

  • npm cinpm test (3/3 files pass) → npm run lint (clean), which is what CI runs.
  • Neither prettier nor the plugin's own sort rules had ever executed in the monorepo, because the package's lint script was a bare eslint with no file pattern. Both are applied here, and the resulting reordering was confirmed to be a pure move of existing lines — every non-blank line is preserved exactly, with only position and blank lines changing.
  • Lint output across all 11 frontend-clients packages was captured before and after the extraction and compared per file and per rule.

Follow-ups

  • Publish a first version and move frontend-clients off the branch dependency onto a version range.
  • Add lib/index.d.ts.
  • Consider extracting @frontend-clients/eslint-plugin-sort-hook-deps the same way.

Copilot AI lite review requested due to automatic review settings September 3, 2026 17:42
@diogoquintas diogoquintas self-assigned this Sep 3, 2026
Comment thread package-lock.json Outdated

Copilot AI 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.

🟡 Changes recommended

There are correctness/operability issues in the release-it changelog command (can hang) and in the missingNewline autofix insertion point (can break indentation), plus README omissions around the export rule.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a standalone eslint-plugin-sort-declarations package extracted from the frontend-clients monorepo, including three sorting rules, shared utilities, tests, and CI/release automation to support independent versioning and publishing.

Changes:

  • Added rule implementations for sorting module declarations, variable declarations, and export declarations (plus shared lib/utils.js).
  • Added comprehensive RuleTester coverage for all three rules, including TypeScript parser regressions.
  • Added repo scaffolding for publishing and maintenance (README, workflows, release-it config, eslint flat config, package metadata).
File summaries
File Description
tests/sort-variable-declarations.js Adds extensive test suite for variable-declaration sorting (JS + TS cases).
tests/sort-module-declarations.js Adds tests for module-level declaration grouping/sorting (CJS + ESM + TS).
tests/sort-export-declarations.js Adds tests for ESM export sorting and blank-line rules.
README.md Adds installation/configuration and rule documentation.
package.json Defines package metadata, scripts, deps/peers, and export entrypoints.
LICENSE Adds MIT license text.
lib/utils.js Adds shared AST utilities (identifier collection, topo sort, comment helpers).
lib/rules/sort-variable-declarations.js Implements variable declaration ordering, blank-line rules, and safe autofix.
lib/rules/sort-module-declarations.js Implements module declaration ordering with dependency-aware topo sorting (incl. GraphQL mode).
lib/rules/sort-export-declarations.js Implements export statement grouping/sorting and blank-line normalization.
lib/index.js Exposes plugin meta and rule map.
eslint.config.js Adds flat config for dogfooding lint + prettier integration.
CHANGELOG.md Adds initial changelog placeholder.
.release-it.json Adds release-it automation and changelog generation hook.
.gitignore Adds basic Node/ESLint ignores.
.github/workflows/release.yaml Adds manual release workflow (npm publish + GitHub release).
.github/workflows/ci.yml Adds CI workflow for lint + tests on Node 20/22/24.
.editorconfig Adds editor defaults (2-space, LF, final newline, trim).
Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .release-it.json
Comment thread lib/rules/sort-variable-declarations.js
Comment thread README.md
Comment thread README.md
Extract the `@frontend-clients/eslint-plugin-sort-declarations` workspace
package into this standalone repository, mirroring the structure of
`uphold/eslint-plugin-sort-imports-requires`.

The rule implementations are functionally unchanged. Prettier formatting
and the plugin's own sort rules had never run in the monorepo because the
package's `lint` script had no file pattern, so both are applied here.
The resulting reordering is a pure move of existing lines.

`peerDependencies` keeps `eslint >= 8` and the dev dependency stays on
eslint 8.57.0 so `RuleTester` behaviour matches the consuming monorepo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@diogoquintas
diogoquintas force-pushed the feature/extract-from-frontend-clients branch from 9219c7e to af3355e Compare September 4, 2026 08:59
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