Skip to content

chore: align ESLint rules with the monorepo's portable ruleset#54

Open
varin-nair-factory wants to merge 1 commit into
mainfrom
vn/align-lint-rules
Open

chore: align ESLint rules with the monorepo's portable ruleset#54
varin-nair-factory wants to merge 1 commit into
mainfrom
vn/align-lint-rules

Conversation

@varin-nair-factory
Copy link
Copy Markdown
Contributor

What

Aligns this public SDK's ESLint config with the portable subset of the private monorepo's shared @factory/eslint-config, so we enforce the same standards as the internal source of truth.

Approach

The monorepo uses ESLint 8 + legacy .eslintrc + airbnb + a custom in-repo plugin; this repo uses ESLint 9 flat config, so a literal copy is impossible. We ported only the rules that are portable and relevant to a standalone library.

Rules added (matching the monorepo)

  • @typescript-eslint/no-empty-object-type (off → error)
  • @typescript-eslint/no-require-imports
  • no-barrel-files/no-barrel-files
  • import/no-default-export, import/named, import/no-extraneous-dependencies, import/extensions
  • eslint-comments/no-unused-disable
  • no-void, default-case, no-constant-condition, no-param-reassign, no-promise-executor-return, prefer-promise-reject-errors, prefer-arrow-callback
  • no-restricted-syntax (for-in, labels, with, ExportAllDeclaration ban)
  • tests: vitest/expect-expect, vitest/valid-expect

Deliberately excluded

  • All factory/* rules — custom in-repo plugin (~80 rules), not installable from npm, and encode monorepo-specific concerns (feature flags, @factory/environment, structured logging).
  • React / JSX / Next rules — no React in this SDK.

Refactors to comply (strict, no carve-outs for our own code)

  • Deleted src/protocol/index.ts — it was an unused export * barrel (nothing imported it; tests import the subfiles directly). Violated both no-barrel-files and the ExportAllDeclaration ban.
  • src/index.ts — converted export * to explicit named re-exports, preserving every public-API name (verified against tests/public-api.test.ts).
  • Public-API barrels (src/index.ts, src/schemas/index.ts, src/daemon/index.ts) are exempted from no-barrel-files via a scoped override — matching the monorepo's own index.ts exemption in factory-package.js.
  • Fixed all resulting violations: no-promise-executor-return (wrapped setTimeout executors), vitest/expect-expect (added real assertions), no-empty-object-type (empty interfaces → type aliases), default-case, no-void, no-param-reassign.

New devDependencies

eslint-plugin-no-barrel-files, eslint-plugin-eslint-comments, @vitest/eslint-plugin.

Prettier

Already byte-identical to the monorepo's .prettierrc — no change needed.

Verification

  • npm run lintclean (0 errors)
  • npm run typecheck + npm run typecheck:examples — clean
  • npm run format:check — clean
  • npm test911 passing

Note

Branch is based on TIER-1 (main); the TIER-2 PR (#53) is independent and not yet merged, so the test count here is 911 (not 916). No tests were removed.

Port the portable, non-custom, non-React rules from factory-mono-alpha's
shared @factory/eslint-config into our ESLint 9 flat config, so the public
SDK enforces the same standards as the internal source of truth.

Added rules: no-empty-object-type (error), no-require-imports, no-barrel-files,
import/no-default-export, import/named, import/no-extraneous-dependencies,
import/extensions, eslint-comments/no-unused-disable, no-void, default-case,
no-constant-condition, no-param-reassign, no-promise-executor-return,
prefer-promise-reject-errors, prefer-arrow-callback, no-restricted-syntax
(incl. ExportAllDeclaration ban), and vitest/expect-expect + valid-expect
for tests.

Excluded the monorepo's factory/* custom-plugin rules (not installable from
npm) and React/Next rules (no React here). Refactored to comply: deleted the
unused src/protocol/index.ts export* barrel and converted src/index.ts to
explicit named re-exports. Public-API barrels are exempted from no-barrel-files
(matching the monorepo's index.ts exemption). Fixed all resulting violations.

New devDeps: eslint-plugin-no-barrel-files, eslint-plugin-eslint-comments,
@vitest/eslint-plugin.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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