Skip to content

Add ESLint configuration and fix linting issues across monorepo packages - #348

Open
AnnieIj wants to merge 3 commits into
Adamantine-guild:mainfrom
AnnieIj:chore/monorepo-eslint
Open

Add ESLint configuration and fix linting issues across monorepo packages#348
AnnieIj wants to merge 3 commits into
Adamantine-guild:mainfrom
AnnieIj:chore/monorepo-eslint

Conversation

@AnnieIj

@AnnieIj AnnieIj commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a single, shared ESLint configuration for the whole monorepo and fixes all linting issues so pnpm lint runs cleanly.

The repo already runs ESLint 10 (flat config only — .eslintrc files are no longer supported), so the shared config lives in the root eslint.config.js and is inherited automatically by every workspace package. No per-package configs are needed.

Linked Issue

Closes #339

Type of Change

  • 🐛 Bug fix
  • ✨ New feature / enhancement
  • 📝 Documentation update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made

  • eslint.config.js — the unified flat config every package inherits:
    • eslint:recommended + typescript-eslint recommended
    • Type-aware linting: every package's tsconfig.json is registered (with tsconfig.base.json as fallback), so rules like no-floating-promises / no-misused-promises now run with full type information
    • consistent-type-imports (error), no-floating-promises (error), no-misused-promises (error), no-non-null-assertion (warn)
    • no-explicit-any kept as a warning (per the issue's suggested config) — visible in the editor without blocking CI
    • Node globals (Buffer, URL, fetch, timers, …) added for .js/.cjs/.mjs files
    • Build artifacts ignored (dist, node_modules, .next, docs build output)
    • no-floating-promises disabled for *.test.ts and test/ helpers: node:test's top-level test()/describe() return promises that the runner itself awaits, so flagging them is a false positive
  • Root package.json — added lint:fix script (eslint . --fix)
  • apps/access-api & packages/contracts — added missing lint scripts so pnpm -r lint covers every package
  • packages/contracts — added prepare script (matches sibling packages) so its dist is built on install and @guildpass/contracts resolves on a fresh clone
  • apps/discord-bot — added @types/node (tsconfig declares types: ["node"] but it was missing)
  • Fixed lint errors across the repo: unused imports/vars, empty interface extends {} → type alias, unawaited load()/mutate() calls in dashboard pages and hooks (now void/.catch()), async handlers extracted out of onClick props, and import type conversions
  • .github/workflows/ci.yml — new CI workflow: installs with pnpm, runs pnpm lint, runs pnpm typecheck, fails on violations

Note on the "no hardcoded .js extensions" criterion: the workspace uses module: NodeNext (ESM), which requires .js extensions on relative imports — removing them would break pnpm build in 5 of 7 packages. The .js extensions in this codebase are correct ESM specifiers, not a linting gap, so enforcing import/extensions: never was intentionally not applied. TypeScript already validates module resolution.

Test Evidence

  • pnpm lint — passes across all 7 packages (0 errors; remaining warnings are intentional no-explicit-any / no-non-null-assertion warnings)
  • pnpm lint:fix — runs clean
  • pnpm typecheck — passes in all 7 packages
  • pnpm test — all tests pass (dashboard 47/47, access-api 2/2, webhook-utils)

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes with no errors
  • pnpm lint passes (or issues are pre-existing and documented)
  • pnpm test passes (all existing tests still pass)
  • The dashboard starts and renders correctly (if UI or API code changed)
  • The Discord bot still starts and responds to commands (if bot code changed)
  • Docs site renders correctly (if docs changed): pnpm dev:docs
  • No secrets, tokens, or API keys are included in this PR
  • Environment variable changes are reflected in .env.example
  • I have updated documentation if new behaviour was introduced

Additional Notes

The lint fixes in the dashboard are behavior-preserving: load()/mutate() calls now use void or .catch(() => {}) (errors were already surfaced via each mutation's onError → alert), and the two inline async onClick handlers were extracted into named handleInvite/handleCreate functions.

Centralize ESLint in the root flat config (eslint.config.js) so every
workspace package inherits the same rules: type-aware linting via each
package's tsconfig, consistent type imports, and no-floating/misused
promise enforcement. Add lint scripts to access-api and contracts, a
root lint:fix script, Node globals for JS files, and a CI workflow that
runs lint and typecheck.

Fixes lint errors across the monorepo and keeps pre-existing build-order
gaps working (contracts prepare script, @types/node for discord-bot).
@Lakes41

Lakes41 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR cannot be merged automatically because it has merge conflicts.

Please update the branch with the latest base branch and resolve the conflicts.

After the conflicts are resolved and checks pass, the automation can review it again.

Resolve conflicts with upstream main (guild-scoped multi-tenancy, auth/CSRF
routes, new env/contracts packages, access-api backfill/leader-election, and
other merged features). Lint fixes from the ESLint PR are reapplied on top of
the merged code, and pre-existing upstream issues are left untouched:
- dashboard tsconfig no longer maps @guildpass/env to package source (broke
  rootDir/typecheck); the package now builds via its prepare script
- hash-chain tests pass guildId to the guild-scoped append() signature
- upstream main's access-api typecheck remains broken there (code references
  Prisma models absent from the committed schema) — unrelated to this PR
CI failed at setup-node because actions/setup-node's pnpm cache requires a
pnpm-lock.yaml, but lock files are untracked in this repo — remove the cache
option.

Also fix upstream's pre-existing access-api typecheck breakage (code
referenced Prisma models missing from the committed schema): add the
FailedEvent model and ProcessedEvent.previousState field to schema.prisma,
and make applyEventApplication snapshot the pre-application membership state
so previousState is actually populated. The dead-letter retry path
(retryFailedEvent/getDeadLetterMetrics) now typechecks.
@AnnieIj

AnnieIj commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@Lakes41 all merged and all CI checked. Thanks

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.

Add ESLint configuration and fix linting issues across monorepo packages

2 participants