Skip to content

fix(backend): resolve lint warnings and stabilize Turbo env cache for DB_FILE_NAME#39

Merged
Mohamed-Elshesheny merged 4 commits intomainfrom
fix/lint-warnings-backend
Apr 20, 2026
Merged

fix(backend): resolve lint warnings and stabilize Turbo env cache for DB_FILE_NAME#39
Mohamed-Elshesheny merged 4 commits intomainfrom
fix/lint-warnings-backend

Conversation

@Mohamed-Elshesheny
Copy link
Copy Markdown
Contributor

@Mohamed-Elshesheny Mohamed-Elshesheny commented Apr 20, 2026

Lint Stability and Cache Correctness Improvements

Summary

This change set resolves backend lint warnings and improves task cache correctness for environment-driven database configuration. The update is scoped to lint/config hygiene and does not introduce runtime behavior changes.

Changes Implemented

  • Added DB_FILE_NAME to Turbo global environment inputs in turbo.json so cache invalidation correctly tracks database path changes.
  • Updated shared ESLint base config in packages/eslint-config/base.js to:
    • register Node globals (process, console, etc.) for JS/MJS linting contexts
    • allow intentionally ignored parameters/errors prefixed with _ via minimal @typescript-eslint/no-unused-vars overrides
  • Replaced any-based enum validation in apps/backend/src/utils/drizzle.ts with a typed string-array check, preserving behavior while improving type safety.

Impact and Risk

  • Runtime impact: none expected.
  • Deployment impact: none expected.
  • Build/lint impact: backend lint warnings addressed; Turbo caching is now more accurate when DB_FILE_NAME changes.

Validation

  • pnpm lint (backend) now returns clean output for prior warning set.
  • TypeScript 6 compatibility banner from typescript-eslint@8.57.x is a separate version-alignment item and not part of these functional lint fixes.

Summary by CodeRabbit

  • Chores

    • Updated project package manager metadata and removed explicit pnpm version pinning from CI workflows.
    • Added an extra global environment variable for the monorepo build system.
    • Expanded a package’s public export map and bumped a development tooling dependency.
  • Style

    • Normalized linting configuration formatting and adjusted unused-variable rule to warn and ignore underscore-prefixed params.
    • Wrapped exported lint config with a standard config helper.
  • Bug Fixes

    • Tightened enum validation to strictly enforce allowed values.

- Updated packageManager in package.json to pnpm@10.33.0.
- Upgraded typescript-eslint and related packages to version 8.58.2 in pnpm-lock.yaml and package.json.
- Added new global environment variable DB_FILE_NAME in turbo.json.
- Improved enum validation in drizzle.ts for better type safety.
- Enhanced ESLint configuration in base.js to include globals and updated rules for unused variables.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28272213-53eb-4640-a61a-dbfd9872ec88

📥 Commits

Reviewing files that changed from the base of the PR and between da43079 and 3a7b5d8.

📒 Files selected for processing (1)
  • packages/eslint-config/vite.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/eslint-config/vite.js

📝 Walkthrough

Walkthrough

Refined enum validation cast in backend utils, bumped project pnpm metadata, removed pinned pnpm versions from CI steps, merged Node globals and added rule overrides in ESLint configs (and bumped a devDependency), and added DB_FILE_NAME to turborepo globalEnv.

Changes

Cohort / File(s) Summary
Type Safety
apps/backend/src/utils/drizzle.ts
Replaced an as any cast by casting values to readonly string[] before calling .includes(value) in enumType.toDriver validation; behavior unchanged.
Package Metadata & Workflows
package.json, .github/workflows/license-header.yml, .github/workflows/release.yml
Updated packageManager to pnpm@10.33.0+sha512...; removed explicit with.version: 10.27.0 pins in pnpm setup steps in two GitHub Actions workflows.
Monorepo Config
turbo.json
Added DB_FILE_NAME to globalEnv, including it in turborepo task inputs/caching.
ESLint Config & DevDependency
packages/eslint-config/base.js, packages/eslint-config/vite.js, packages/eslint-config/package.json
Imported globals, merged Node globals into languageOptions.globals, added @typescript-eslint/no-unused-vars override (warn; ignore _-prefixed args/errors), adjusted config export to use defineConfig, normalized quoting, and bumped @typescript-eslint devDependency to ^8.58.2 (also added ./vite export).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I nudged a cast, then hopped away,
Pinned versions loosened for the day,
Turbo learned a DB name anew,
ESLint got a Node-and-browser view,
A little hop — the changes brew.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: resolving lint warnings in the backend and stabilizing Turbo's environment cache by adding DB_FILE_NAME, which are the primary objectives described in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/lint-warnings-backend

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

…onfigurations

- Updated .github/workflows/license-header.yml and .github/workflows/release.yml to remove the explicit version setting for pnpm in the setup step, allowing for the latest version to be used.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/eslint-config/base.js`:
- Around line 22-37: The package is missing an export for the Vite ESLint config
and the Vite config file drops Node globals; add an export entry for "./vite":
"./vite.js" in package.json exports, and update vite.js (the config that
currently sets languageOptions.globals = globals.browser) to either spread the
baseConfig (baseConfig) or explicitly merge ...globals.node with globals.browser
so Node globals (globals.node) are available for files like
apps/web/vite.config.ts that call process.cwd(); also audit react-internal.js
and next.js to ensure they are not applied to files that need Node globals (or
else merge Node globals similarly).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8110c5f5-f0aa-49a4-8672-966ed3b4ee9c

📥 Commits

Reviewing files that changed from the base of the PR and between 065f9dd and c29fb7d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • apps/backend/src/utils/drizzle.ts
  • package.json
  • packages/eslint-config/base.js
  • packages/eslint-config/package.json
  • turbo.json

Comment on lines +22 to +37
{
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how downstream configs handle globals and whether they need Node globals

# Find all eslint config files that extend baseConfig
rg -l 'baseConfig' --glob '*.js' packages/eslint-config/

# Check if any frontend code references Node globals like process
rg -n '\bprocess\.' --type ts --type js -g '!node_modules' apps/ packages/ | head -30

Repository: TeamCoderz/WordyMe

Length of output: 451


🏁 Script executed:

#!/bin/bash

# Read the downstream config files that override globals
echo "=== react-internal.js ==="
cat packages/eslint-config/react-internal.js | head -50

echo -e "\n=== next.js ==="
cat packages/eslint-config/next.js | head -50

# Check ESLint config in apps/web (frontend)
echo -e "\n=== Apps/web ESLint config ==="
find apps/web -name 'eslint.config.*' -o -name '.eslintrc*' | xargs cat 2>/dev/null || echo "No eslintrc found in apps/web"

# Check ESLint config in apps/backend
echo -e "\n=== Apps/backend ESLint config ==="
find apps/backend -name 'eslint.config.*' -o -name '.eslintrc*' | xargs cat 2>/dev/null || echo "No eslintrc found in apps/backend"

# Check if there's a root ESLint config
echo -e "\n=== Root ESLint config ==="
cat eslint.config.js 2>/dev/null | head -100

Repository: TeamCoderz/WordyMe

Length of output: 2936


🏁 Script executed:

#!/bin/bash

# List all JS files in eslint-config
echo "=== All JS files in packages/eslint-config/ ==="
ls -la packages/eslint-config/*.js

# Search for vite in eslint-config directory
echo -e "\n=== Searching for 'vite' in eslint-config ==="
rg -i 'vite' packages/eslint-config/

# Check the full base.js to see what's exported
echo -e "\n=== Full base.js file ==="
cat packages/eslint-config/base.js

# Check what `@repo/eslint-config` exports
echo -e "\n=== Check package.json for eslint-config exports ==="
cat packages/eslint-config/package.json | grep -A 20 '"exports"'

Repository: TeamCoderz/WordyMe

Length of output: 2194


🏁 Script executed:

#!/bin/bash

# Read the full vite.js file
echo "=== Full vite.js file ==="
cat packages/eslint-config/vite.js

Repository: TeamCoderz/WordyMe

Length of output: 1221


Multiple globals configuration issues need attention.

The globals.node in base.js is properly set, but several downstream configs either override or omit it:

  1. vite.js is missing from package.json exportsapps/web imports @repo/eslint-config/vite but the export is not declared. This will cause module resolution failures.

  2. vite.js loses Node globals entirely — It sets globals: globals.browser only and does not spread baseConfig, so Node globals are unavailable. However, apps/web/vite.config.ts uses process.cwd() (line 10), which requires Node globals for linting.

  3. react-internal.js and next.js override Node globals — Both configs spread baseConfig but then replace languageOptions.globals with browser/serviceworker globals only. This is acceptable if these configs are used exclusively for frontend code that doesn't reference Node APIs.

Action items:

  • Add "./vite": "./vite.js" to package.json exports
  • Update vite.js to spread baseConfig or explicitly include ...globals.node alongside globals.browser
  • Verify that react-internal.js and next.js are not applied to any files needing Node globals (e.g., build config files)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/eslint-config/base.js` around lines 22 - 37, The package is missing
an export for the Vite ESLint config and the Vite config file drops Node
globals; add an export entry for "./vite": "./vite.js" in package.json exports,
and update vite.js (the config that currently sets languageOptions.globals =
globals.browser) to either spread the baseConfig (baseConfig) or explicitly
merge ...globals.node with globals.browser so Node globals (globals.node) are
available for files like apps/web/vite.config.ts that call process.cwd(); also
audit react-internal.js and next.js to ensure they are not applied to files that
need Node globals (or else merge Node globals similarly).

…tions

- Introduced a new Vite configuration file for ESLint.
- Updated the ESLint configuration to include Node globals alongside browser globals for improved compatibility.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/eslint-config/vite.js (1)

19-22: Consider scoping Node globals to config files only.

Lines 19-22 merge globals.node into the browser-targeted scope (applied to all **/*.{ts,tsx} files). While no violations currently exist in frontend source, this pattern unnecessarily permits Node-only identifiers like process, Buffer, and __dirname in browser code, reducing lint safety for catching runtime incompatibilities.

The apps/web/vite.config.ts legitimately uses Node APIs (process.cwd(), __dirname), so separate config blocks would allow Node globals only where needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/eslint-config/vite.js` around lines 19 - 22, The current override
merges globals.node into the browser-targeted scope (globals with
...globals.browser and ...globals.node), which lets Node identifiers like
process, Buffer, and __dirname appear in frontend files; split this into two
overrides: keep ...globals.browser for the frontend pattern (e.g.,
**/*.{ts,tsx}) and create a separate override that adds ...globals.node only for
config files (e.g., vite config such as apps/web/vite.config.ts and other
build/config scripts), so Node globals are allowed only in files that
legitimately use process.cwd(), __dirname, etc.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/eslint-config/vite.js`:
- Around line 19-22: The current override merges globals.node into the
browser-targeted scope (globals with ...globals.browser and ...globals.node),
which lets Node identifiers like process, Buffer, and __dirname appear in
frontend files; split this into two overrides: keep ...globals.browser for the
frontend pattern (e.g., **/*.{ts,tsx}) and create a separate override that adds
...globals.node only for config files (e.g., vite config such as
apps/web/vite.config.ts and other build/config scripts), so Node globals are
allowed only in files that legitimately use process.cwd(), __dirname, etc.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90fd4693-1150-4148-9c27-5f47837793fa

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe5770 and da43079.

📒 Files selected for processing (2)
  • packages/eslint-config/package.json
  • packages/eslint-config/vite.js
✅ Files skipped from review due to trivial changes (1)
  • packages/eslint-config/package.json

…neConfig

- Refactored the ESLint configuration for Vite to utilize the defineConfig function for improved clarity and structure.
- Enhanced global definitions by separating browser and Node globals into distinct language options.
- Maintained existing rules and plugins while ensuring compatibility with TypeScript and React.
@Mohamed-Elshesheny Mohamed-Elshesheny merged commit 9d63f63 into main Apr 20, 2026
3 checks passed
@Mohamed-Elshesheny Mohamed-Elshesheny deleted the fix/lint-warnings-backend branch April 20, 2026 15:58
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