Skip to content

Adopted correctnessRules in apps/admin + cleaned 14 violations#28863

Merged
9larsons merged 3 commits into
mainfrom
admin-correctness-rules
Jun 24, 2026
Merged

Adopted correctnessRules in apps/admin + cleaned 14 violations#28863
9larsons merged 3 commits into
mainfrom
admin-correctness-rules

Conversation

@9larsons

@9larsons 9larsons commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

apps/admin's standalone ESLint config now spreads correctnessRules from eslint.shared.mjs — matches the rule posture every factory-using workspace already has.

5 curly violations autofixed (single-statement if returns now braced).

5 source fixes (all done in source, no new file-glob exemptions):

  • nav-content.tsx: count != nullcount !== null && count !== undefined (eqeqeq — variable is number | null | undefined)
  • ember-bridge.test.tsx: renderCount++renderCount += 1 (no-plusplus)
  • user-preferences.test.tsx: await new Promise(r => setTimeout(r, 25)) → braces wrap (no-promise-executor-return)
  • vite-backend-proxy.ts: same brace fix (no-promise-executor-return)
  • vite-ember-assets.ts:85 was already console.warn, allowed by the new workspace override

One workspace-level override added:

  • 'no-console': ['error', {allow: ['error', 'warn']}]console.error is the conventional browser error sink, kept in 4 places (auth fetch catch, sidebar shared-views parse fallback, onboarding error logs). console.log etc. still error.

The ghost/filenames/match-regex rule from the previous config is now covered by correctnessRules (same rule, same args), so its explicit line is dropped.

no ref

apps/admin's standalone ESLint config now spreads correctnessRules from eslint.shared.mjs — matches the rule posture every factory-using workspace already has.

5 curly violations autofixed (single-statement if returns now braced).

5 source fixes:
- nav-content.tsx: count != null → count !== null && count !== undefined (eqeqeq with always — the variable is number | null | undefined)
- 4 console.error calls untouched: workspace overrides 'no-console' to ['error', { allow: ['error', 'warn'] }] since console.error is the conventional browser error sink

Scoped exemptions added to apps/admin/eslint.config.js (mirrors ghost/core's pattern):
- Test files (*.test.{ts,tsx}, *.spec.{ts,tsx}, test-utils/**): no-plusplus + no-promise-executor-return off (renderCount++, await new Promise(r => setTimeout(r, N)) are common test idioms)
- Build scripts at workspace root (*.ts/*.mts/*.cts — vite-backend-proxy.ts, vite-ember-assets.ts, vite.config.ts): no-console + no-promise-executor-return off (Node side, intentional)

The 'ghost/filenames/match-regex' rule from the previous config is now covered by correctnessRules (same rule, same args), so its explicit line is dropped.
@nx-cloud

nx-cloud Bot commented Jun 24, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 742042d

Command Status Duration Result
nx build @tryghost/admin-toolbar ✅ Succeeded <1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/portal ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 1m 11s View ↗
Additional runs (5) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-24 15:21:26 UTC

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d06a94b-88ee-4289-81d9-a2be045172c7

📥 Commits

Reviewing files that changed from the base of the PR and between 94821a4 and 742042d.

📒 Files selected for processing (6)
  • apps/admin/eslint.config.js
  • apps/admin/src/layout/app-sidebar/shared-views.ts
  • apps/admin/src/layout/app-sidebar/user-menu.tsx
  • apps/admin/src/onboarding/hooks/use-onboarding.ts
  • apps/admin/src/onboarding/onboarding-route.tsx
  • apps/admin/vite-ember-assets.ts
💤 Files with no reviewable changes (1)
  • apps/admin/eslint.config.js
✅ Files skipped from review due to trivial changes (5)
  • apps/admin/src/onboarding/onboarding-route.tsx
  • apps/admin/src/layout/app-sidebar/shared-views.ts
  • apps/admin/vite-ember-assets.ts
  • apps/admin/src/layout/app-sidebar/user-menu.tsx
  • apps/admin/src/onboarding/hooks/use-onboarding.ts

Walkthrough

The admin ESLint config now imports and applies correctnessRules from the shared module, removes ghost/filenames/match-regex, and updates the local rule comments. Related admin source and test code now uses explicit blocks, explicit counter updates, null/undefined guards, and targeted no-console suppressions.

Possibly related PRs

  • TryGhost/Ghost#28805: Adjusts ESLint rule handling around ghost/filenames/match-regex, which overlaps with the config change here.
  • TryGhost/Ghost#28807: Also revises ghost/filenames/match-regex-related ESLint configuration in the admin workspace.
  • TryGhost/Ghost#28839: Updates admin ESLint configuration around correctnessRules from eslint.shared.mjs.

Suggested reviewers

  • EvanHahn
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adopting shared correctness rules and fixing violations in apps/admin.
Description check ✅ Passed The description is directly related to the changeset and matches the ESLint rule updates and fixes in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch admin-correctness-rules

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ptions

no ref

Dropped the test-files + build-scripts override blocks. The 4 underlying violations they were covering are now fixed in source:

- ember-bridge.test.tsx:429 — renderCount++ → renderCount += 1 (no-plusplus)
- user-preferences.test.tsx:322 — await new Promise(resolve => setTimeout(...)) → braces wrap (no-promise-executor-return)
- vite-backend-proxy.ts:22 — same brace fix (no-promise-executor-return)
- vite-ember-assets.ts:85 — already console.warn, allowed by the workspace's existing browser-style no-console override

apps/admin's only remaining workspace-level relaxation is the no-console allow: ['error', 'warn'] override — which IS the conventional browser pattern for production code.
@9larsons 9larsons enabled auto-merge (squash) June 24, 2026 15:08
no ref

Removed the workspace-level no-console allow-list. Every other workspace in the monorepo uses no-console: 'error' with inline // eslint-disable-next-line no-console (or file-level /* eslint-disable no-console */) at each call site. apps/admin now matches.

5 sites get explicit inline disables: shared-views, user-menu, use-onboarding, onboarding-route, vite-ember-assets. Each is visible at the call site as 'yes, console here is intentional' — and reportUnusedDisableDirectives (once flipped) will catch any that go stale.
@9larsons 9larsons merged commit 54a8523 into main Jun 24, 2026
47 checks passed
@9larsons 9larsons deleted the admin-correctness-rules branch June 24, 2026 15:35
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