Skip to content

feat(database): setup backend with drizzle orm and configure eslint#1

Merged
BhushanLagare7 merged 1 commit into
mainfrom
feature/setup-backend-eslint
May 4, 2026
Merged

feat(database): setup backend with drizzle orm and configure eslint#1
BhushanLagare7 merged 1 commit into
mainfrom
feature/setup-backend-eslint

Conversation

@BhushanLagare7

@BhushanLagare7 BhushanLagare7 commented May 4, 2026

Copy link
Copy Markdown
Owner
  • Initialize Drizzle ORM configuration and database schema in the backend.
  • Configure ESLint with simple-import-sort and other plugins for both backend and frontend.
  • Refactor frontend components to comply with new linting rules.

Summary by CodeRabbit

  • Chores
    • Configured PostgreSQL database schema and connection setup
    • Added ESLint linting rules and import sorting for backend and frontend
    • Added build, lint, and database management scripts to development workflow
    • Updated frontend and backend development tooling dependencies

- Initialize Drizzle ORM configuration and database schema in the backend.
- Configure ESLint with simple-import-sort and other plugins for both backend and frontend.
- Refactor frontend components to comply with new linting rules.
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Walkthrough

This PR establishes backend database infrastructure using Drizzle ORM with a PostgreSQL schema, adds ESLint configurations with import/export sorting rules to both backend and frontend codebases, and applies import/attribute reordering to frontend code to align with new linting rules.

Changes

Backend Database & ORM Setup

Layer / File(s) Summary
Drizzle Kit Configuration
backend/drizzle.config.ts
Loads DATABASE_URL from environment, validates presence, and configures Drizzle Kit to use PostgreSQL dialect with schema at ./src/db/schema.ts.
Database Connection & Instance
backend/src/db/index.ts
Creates a pg.Pool from DATABASE_URL and exports a Drizzle ORM instance wired to the schema.
Database Schema & Types
backend/src/db/schema.ts
Defines five tables (users, products, checkout_sessions, orders, order_items) with typed columns, foreign keys, cascading deletes, and Drizzle relations for type-safe joins. Exports domain types: OrderStatus, UserRole, CheckoutSessionLine.
Dependencies & Build Setup
backend/package.json
Adds drizzle-kit, pg, and related @types packages; adds db:push script.

Backend ESLint Configuration & Tooling

Layer / File(s) Summary
ESLint Flat Config
backend/eslint.config.mjs
Composes @eslint/js and typescript-eslint recommended rules, configures Node globals, registers simple-import-sort plugin, and enforces import/export ordering.
Lint Scripts & Dependencies
backend/package.json
Adds lint, lint:fix scripts and ESLint tooling (@eslint/js, eslint, eslint-plugin-simple-import-sort, globals, typescript-eslint).

Frontend ESLint Configuration, Code Quality & Cleanup

Layer / File(s) Summary
ESLint Configuration
frontend/eslint.config.js
Adds react/jsx-sort-props rule for JSX prop ordering and simple-import-sort rules for deterministic import/export ordering across **/*.{js,jsx} files.
Lint Scripts & Dependencies
frontend/package.json
Adds lint:fix script and eslint-plugin-simple-import-sort dependency.
Code Formatting & Cleanup
frontend/src/App.jsx, frontend/src/main.jsx, frontend/vite.config.js
Reorders imports in main.jsx and vite.config.js; updates App.jsx with reordered JSX attributes (button className before type, SVG aria-hidden/role attributes) and simplified image attribute sets to comply with new linting rules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


🐰 A schema blooms with ordered tables true,
ESLint sorts our imports through and through,
From Drizzle's pool to props aligned with care,
The codebase dances, formatted fair!
hops away with satisfaction

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: setting up Drizzle ORM for the backend database layer and configuring ESLint for code quality across the project.
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 feature/setup-backend-eslint

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🧹 Nitpick comments (2)
backend/eslint.config.mjs (1)

6-33: ⚡ Quick win

Add ignores for compiled output to avoid linting build artifacts.

Without an ignores entry, npm run build && npm run lint will lint the compiled JavaScript in dist/, which is noisy and may produce spurious TypeScript-ESLint errors on generated code.

♻️ Proposed fix
 export default tseslint.config(
+  { ignores: ["dist/**", "drizzle/**"] },
   js.configs.recommended,
   ...tseslint.configs.recommended,
   {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/eslint.config.mjs` around lines 6 - 33, Add an ignores entry to the
exported tseslint.config so ESLint skips compiled artifacts (e.g., dist/ and
other build output) during lint runs; update the top-level config object passed
to tseslint.config (the same object that currently has languageOptions, plugins,
and rules) to include an ignores array with patterns like "dist/**" (and any
other build output directories you produce) so running npm run build && npm run
lint does not lint generated JS.
frontend/eslint.config.js (1)

11-28: ⚡ Quick win

Scope the jsx-sort-props config block to JSX files only and add settings.react.version

Two improvements for this block:

  1. Missing files filter: Without it, this config object applies globally to every file ESLint processes. Configuration objects without files or ignores are automatically applied to any file that is matched by any other configuration object. The react/jsx-sort-props rule is harmless on non-JSX files, but loading eslint-plugin-react (and its React version detection) unnecessarily against .js/non-JSX files increases the blast radius of the known ESLint v10 crash.

  2. Missing settings.react.version: Without this, eslint-plugin-react uses context.getFilename() (removed in ESLint v10) to auto-detect the React version. Setting it to an explicit version string skips that detection path entirely, and also silences the plugin's version-missing warning.

♻️ Suggested improvement
 {
+  files: ["**/*.jsx"],
   name: "custom/jsx-sort-props",
   plugins: {
     react: reactPlugin,
   },
+  settings: {
+    react: {
+      version: "19",
+    },
+  },
   rules: {
     "react/jsx-sort-props": [
       "error",
       {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/eslint.config.js` around lines 11 - 28, Scope the
custom/jsx-sort-props config so it only applies to JSX-containing files by
adding a files filter (e.g., matching *.jsx, *.tsx, *.tsx? and *.jsx? patterns)
around the config object that currently declares the "react/jsx-sort-props"
rule, and add an explicit settings.react.version entry (for example "detect"
replaced with a concrete version string like "18.0") in that same config object
so eslint-plugin-react won’t try to auto-detect via context.getFilename();
update the config block that defines name: "custom/jsx-sort-props" and plugins:
{ react: reactPlugin } accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/db/index.ts`:
- Line 12: The pg.Pool instance (pool) created with new pg.Pool({
connectionString: databaseUrl }) needs an 'error' event listener to prevent
unhandled exceptions; add a listener on the pool object (e.g., pool.on('error',
...)) that logs the error via your logger and handles or re-throws appropriately
(or gracefully shuts down) so network-level client errors do not crash the
process; update any initialization/teardown logic to ensure the listener is
registered immediately after creating pool and removed on pool.end() if
necessary.
- Around line 2-5: Reorder and group the imports to satisfy simple-import-sort:
combine external package imports without a blank line and alphabetize them, e.g.
move import "dotenv/config" above import pg from "pg" (so external block is:
import "dotenv/config"; import pg from "pg";), then keep a single blank line
before the local import import * as schema from "./schema"; to separate external
and internal modules.

In `@backend/src/db/schema.ts`:
- Around line 130-137: The updatedAt column definitions in
backend/src/db/schema.ts (the updatedAt column on the users and orders tables)
only use .defaultNow() so they never change after INSERT; update each updatedAt
column definition to include Drizzle's on-update hook (use .$onUpdate() or
.$onUpdateFn(...) as appropriate) so the timestamp is recalculated automatically
on row updates while keeping .defaultNow() and .notNull(); locate the updatedAt
symbol in the users and orders table definitions and add the on-update handler
to ensure updatedAt auto-updates on UPDATEs.
- Around line 438-440: usersRelations currently only includes orders and omits
checkoutSessions, and there is no checkoutSessionsRelations declared; add
checkoutSessions: many(checkoutSessions) to the usersRelations relations object
and create a new export named checkoutSessionsRelations =
relations(checkoutSessions, ({ one }) => ({ user: one(users) })) so Drizzle can
resolve with: { checkoutSessions: true } on users and with: { user: true } on
checkout sessions; reference the relations(...) call that defines usersRelations
and the checkoutSessions table symbol when adding the new relations export.

In `@frontend/package.json`:
- Around line 22-23: The installed eslint-plugin-react@7.37.5 is incompatible
with eslint@10.2.1 and will crash runtime; fix by either pinning the "eslint"
dependency in package.json to a 9.x range (e.g., ^9.7) to match
eslint-plugin-react, or upgrade to a future eslint-plugin-react@8+ when
available; as an interim workaround, modify eslint.config.js to add settings: {
react: { version: "detect" } } inside the config object where the jsx-sort-props
rule is declared (this bypasses the plugin's dynamic version detection that
calls the removed context.getFilename API).

---

Nitpick comments:
In `@backend/eslint.config.mjs`:
- Around line 6-33: Add an ignores entry to the exported tseslint.config so
ESLint skips compiled artifacts (e.g., dist/ and other build output) during lint
runs; update the top-level config object passed to tseslint.config (the same
object that currently has languageOptions, plugins, and rules) to include an
ignores array with patterns like "dist/**" (and any other build output
directories you produce) so running npm run build && npm run lint does not lint
generated JS.

In `@frontend/eslint.config.js`:
- Around line 11-28: Scope the custom/jsx-sort-props config so it only applies
to JSX-containing files by adding a files filter (e.g., matching *.jsx, *.tsx,
*.tsx? and *.jsx? patterns) around the config object that currently declares the
"react/jsx-sort-props" rule, and add an explicit settings.react.version entry
(for example "detect" replaced with a concrete version string like "18.0") in
that same config object so eslint-plugin-react won’t try to auto-detect via
context.getFilename(); update the config block that defines name:
"custom/jsx-sort-props" and plugins: { react: reactPlugin } accordingly.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64172e49-d8d5-4831-b816-dc1d4f75efa6

📥 Commits

Reviewing files that changed from the base of the PR and between dea99a9 and 176fe13.

⛔ Files ignored due to path filters (2)
  • backend/package-lock.json is excluded by !**/package-lock.json
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • backend/drizzle.config.ts
  • backend/eslint.config.mjs
  • backend/package.json
  • backend/src/db/index.ts
  • backend/src/db/schema.ts
  • frontend/eslint.config.js
  • frontend/package.json
  • frontend/src/App.jsx
  • frontend/src/main.jsx
  • frontend/vite.config.js

Comment thread backend/src/db/index.ts
Comment on lines +2 to +5
import pg from "pg";

import "dotenv/config";
import * as schema from "./schema";

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 | 🟡 Minor | ⚡ Quick win

Import ordering violates the newly configured simple-import-sort rules.

dotenv/config, drizzle-orm/node-postgres, and pg all belong to the same group (^@?\\w). The blank line between pg and dotenv/config breaks that group, and the alphabetical order within the group is wrong. npm run lint will fail on this file.

✏️ Proposed fix
-import { drizzle } from "drizzle-orm/node-postgres";
-import pg from "pg";
-
-import "dotenv/config";
-import * as schema from "./schema";
+import "dotenv/config";
+import { drizzle } from "drizzle-orm/node-postgres";
+import pg from "pg";
+
+import * as schema from "./schema";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/db/index.ts` around lines 2 - 5, Reorder and group the imports to
satisfy simple-import-sort: combine external package imports without a blank
line and alphabetize them, e.g. move import "dotenv/config" above import pg from
"pg" (so external block is: import "dotenv/config"; import pg from "pg";), then
keep a single blank line before the local import import * as schema from
"./schema"; to separate external and internal modules.

Comment thread backend/src/db/index.ts
throw new Error("Missing DATABASE_URL");
}

const pool = new pg.Pool({ connectionString: databaseUrl });

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 | 🟠 Major | ⚡ Quick win

Unhandled pg.Pool error event can crash the process.

When an idle client in the pool encounters a network-level error, pg emits an 'error' event on the pool itself. Without a listener, Node.js treats this as an unhandled exception and will terminate the process.

🛡️ Proposed fix
 const pool = new pg.Pool({ connectionString: databaseUrl });
+pool.on("error", (err) => {
+  console.error("Unexpected error on idle database client", err);
+});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/db/index.ts` at line 12, The pg.Pool instance (pool) created with
new pg.Pool({ connectionString: databaseUrl }) needs an 'error' event listener
to prevent unhandled exceptions; add a listener on the pool object (e.g.,
pool.on('error', ...)) that logs the error via your logger and handles or
re-throws appropriately (or gracefully shuts down) so network-level client
errors do not crash the process; update any initialization/teardown logic to
ensure the listener is registered immediately after creating pool and removed on
pool.end() if necessary.

Comment thread backend/src/db/schema.ts
Comment on lines +130 to +137
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),

/** Timestamp (with time zone) when this record was last updated. */
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),

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 | 🟠 Major | ⚡ Quick win

updatedAt columns will never auto-update — add .$onUpdate().

.defaultNow() only sets the value at INSERT time. When using $onUpdate() or $onUpdateFn(), Drizzle adds a dynamic update value to the column; the function is called when the row is updated, and the returned value is used as the column value if none is provided. Without it, both users.updatedAt and orders.updatedAt will permanently equal their original createdAt value unless the application manually sets them.

This applies identically to orders.updatedAt at Lines 360–362.

🛠️ Proposed fix (applies to both `users.updatedAt` and `orders.updatedAt`)
   updatedAt: timestamp("updated_at", { withTimezone: true })
     .defaultNow()
-    .notNull(),
+    .notNull()
+    .$onUpdate(() => new Date()),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
/** Timestamp (with time zone) when this record was last updated. */
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
/** Timestamp (with time zone) when this record was last updated. */
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull()
.$onUpdate(() => new Date()),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/db/schema.ts` around lines 130 - 137, The updatedAt column
definitions in backend/src/db/schema.ts (the updatedAt column on the users and
orders tables) only use .defaultNow() so they never change after INSERT; update
each updatedAt column definition to include Drizzle's on-update hook (use
.$onUpdate() or .$onUpdateFn(...) as appropriate) so the timestamp is
recalculated automatically on row updates while keeping .defaultNow() and
.notNull(); locate the updatedAt symbol in the users and orders table
definitions and add the on-update handler to ensure updatedAt auto-updates on
UPDATEs.

Comment thread backend/src/db/schema.ts
Comment on lines +438 to +440
export const usersRelations = relations(users, ({ many }) => ({
orders: many(orders),
}));

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 | 🟠 Major | ⚡ Quick win

checkoutSessions is absent from both usersRelations and has no relation object of its own.

usersRelations only declares orders: many(orders), leaving out checkoutSessions. Additionally, there is no checkoutSessionsRelations export declaring the user: one(users, …) side. Any Drizzle query using with: { checkoutSessions: true } on a user, or with: { user: true } on a checkout session, will throw a runtime error.

🛠️ Proposed fix
 export const usersRelations = relations(users, ({ many }) => ({
   orders: many(orders),
+  checkoutSessions: many(checkoutSessions),
 }));

Add a new export after productsRelations:

+export const checkoutSessionsRelations = relations(checkoutSessions, ({ one }) => ({
+  user: one(users, { fields: [checkoutSessions.userId], references: [users.id] }),
+}));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/db/schema.ts` around lines 438 - 440, usersRelations currently
only includes orders and omits checkoutSessions, and there is no
checkoutSessionsRelations declared; add checkoutSessions: many(checkoutSessions)
to the usersRelations relations object and create a new export named
checkoutSessionsRelations = relations(checkoutSessions, ({ one }) => ({ user:
one(users) })) so Drizzle can resolve with: { checkoutSessions: true } on users
and with: { user: true } on checkout sessions; reference the relations(...) call
that defines usersRelations and the checkoutSessions table symbol when adding
the new relations export.

Comment thread frontend/package.json
Comment on lines 22 to +23
"eslint": "^10.2.1",
"eslint-plugin-react": "^7.37.5",

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 | 🟠 Major | ⚡ Quick win

❓ Verification inconclusive

Script executed:

#!/bin/bash
# Confirm the installed eslint-plugin-react peerDependencies for eslint
# and check if version.js uses context.getFilename
fd -i "package.json" --search-path node_modules/eslint-plugin-react -d 1 --exec cat {}
rg -n "getFilename" node_modules/eslint-plugin-react/lib/util/version.js

Repository: BhushanLagare7/northwind


Repository: BhushanLagare7/northwind
Exit code: 2

stderr:

[fd error]: Search path 'node_modules/eslint-plugin-react' is not a directory.
[fd error]: No valid search paths given.
node_modules/eslint-plugin-react/lib/util/version.js: No such file or directory (os error 2)


Script executed:

# Check if node_modules exists and explore repo structure
ls -la | head -20

Repository: BhushanLagare7/northwind


Repository: BhushanLagare7/northwind
Exit code: 0

stdout:

total 8
drwxr-xr-x 5 jailuser jailuser  140 May  4 17:50 .
drwxr-xr-x 1 jailuser jailuser  220 May  4 17:50 ..
drwxr-xr-x 6 jailuser jailuser  240 May  4 17:56 .git
-rw-r--r-- 1 jailuser jailuser  259 May  4 17:50 .gitignore
drwxr-xr-x 3 jailuser jailuser  180 May  4 17:50 backend
-rw-r--r-- 1 root     root     1259 May  4 17:50 biome.json
drwxr-xr-x 4 jailuser jailuser  220 May  4 17:50 frontend


Script executed:

# Read the actual package.json to confirm the versions at lines 22-23
head -30 frontend/package.json

Repository: BhushanLagare7/northwind


Repository: BhushanLagare7/northwind
Exit code: 0

stdout:

{
  "name": "frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint .",
    "lint:fix": "eslint . --fix",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^19.2.5",
    "react-dom": "^19.2.5"
  },
  "devDependencies": {
    "@eslint/js": "^10.0.1",
    "@types/react": "^19.2.14",
    "@types/react-dom": "^19.2.3",
    "@vitejs/plugin-react": "^6.0.1",
    "eslint": "^10.2.1",
    "eslint-plugin-react": "^7.37.5",
    "eslint-plugin-react-hooks": "^7.1.1",
    "eslint-plugin-react-refresh": "^0.5.2",
    "eslint-plugin-simple-import-sort": "^13.0.0",
    "globals": "^17.5.0",
    "vite": "^8.0.10"
  }
}


Script executed:

# Check git status to understand the repository state
git ls-files | grep -E "(package\.json|node_modules)" | head -20

Repository: BhushanLagare7/northwind


Repository: BhushanLagare7/northwind
Exit code: 0

stdout:

backend/package.json
frontend/package.json


eslint v10 removed context.getFilename breaking changes


Yes. ESLint v10.0.0 removed the deprecated rule context APIs including context.getFilename. In custom rules (and any ecosystem plugins still using the old API), you must use context.filename instead. What changed (ESLint v10): - context.getFilename → context.filename - context.getCwd → context.cwd - context.getPhysicalFilename → context.physicalFilename - context.getSourceCode → context.sourceCode - context.parserOptions → context.languageOptions or context.languageOptions.parserOptions - context.parserPath → no replacement This removal is part of the official ESLint v10 migration guidance and release notes. For example, the “Migrate to v10.x” doc states that in ESLint v10.0.0 “all of these members have been removed” and provides the replacement mapping for context.getFilename.

Citations:


eslint-plugin-react 7.37.5 incompatible eslint 10


eslint-plugin-react@7.37.5 is incompatible with ESLint 10 (both for installation/peer-dependency constraints and at runtime in some cases). Evidence: 1) Installation/peer dependency conflicts: users reported npm resolution failures when pairing eslint-plugin-react@7.37.5 with eslint@10.x (peer range not including v10). 2) Runtime incompatibility: reports show crashes like “contextOrFilename.getFilename is not a function” when ESLint 10 tries to run rules such as react/no-render-return-value. 3) The plugin’s published peer dependency range on npm includes eslint up to the 9.x line (peerDependencies show ^3 || … || ^9.7, not ^10). What to do: - If you need ESLint 10 now: pin eslint to a supported version (e.g., ESLint 9.x) until eslint-plugin-react officially supports ESLint 10. - If/when a future eslint-plugin-react release adds ESLint 10 support (updates peerDependencies / fixes for ESLint 10 rule-context API changes), upgrade to that version. Note: A related React lint plugin (eslint-plugin-react-hooks) had ESLint 10 peer-dependency support work merged into the project and later released versions with ESLint 10 support; this does not automatically mean eslint-plugin-react (the main plugin) is compatible at v7.37.5.

Citations:


"contextOrFilename.getFilename is not a function" eslint-plugin-react


The error "contextOrFilename.getFilename is not a function" occurs when using eslint-plugin-react with ESLint v10. ESLint v10 removed the legacy context.getFilename API that eslint-plugin-react relies on for React version auto-detection in rules like react/display-name. This is a known compatibility issue, primarily affecting Next.js projects via eslint-config-next which depends on eslint-plugin-react ~7.37.x. Workarounds: 1. Downgrade ESLint to v9.x: "eslint": "^9.0.0" 2. Explicitly set React version in eslint config to bypass auto-detection: settings: { react: { version: "detect" } // or "18.x", "19.x" etc. } For flat config (eslint.config.js): { settings: { react: { version: "detect" } } } 3. Use @eslint/compat to polyfill legacy APIs if using flat config. 4. Switch to modern alternatives like @eslint-react/eslint-plugin (native ESLint 10 support). eslint-plugin-react-hooks has ESLint v10 support since v7+. Long-term: Update eslint-plugin-react when v8+ releases with full ESLint v10 compatibility (PRs in progress).

Citations:


eslint-plugin-react@7.37.5 is incompatible with eslint@10.2.1 — linting will crash at runtime

ESLint v10.0.0 removed deprecated rule context methods including context.getFilename(). When using eslint-plugin-react@7.37.5 with ESLint 10, it throws TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function because the plugin's internal version.js utility (used by every react/* rule) still calls this removed API. The plugin's peer dependencies explicitly exclude ESLint 10 support (capped at ^9.7), causing runtime failures for any React rules that trigger version detection.

Both npm run lint and npm run lint:fix will fail before any rule is applied.

Options:

  1. Downgrade ESLint to ^9.xeslint-plugin-react@7.37.5 is compatible with ESLint v9.
  2. Wait for eslint-plugin-react@8+ — work is in progress upstream to add ESLint v10 support.

Interim workaround (if staying on ESLint v10): add settings: { react: { version: "detect" } } to the jsx-sort-props config block in eslint.config.js. This bypasses the dynamic version auto-detection code path that calls the removed API.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/package.json` around lines 22 - 23, The installed
eslint-plugin-react@7.37.5 is incompatible with eslint@10.2.1 and will crash
runtime; fix by either pinning the "eslint" dependency in package.json to a 9.x
range (e.g., ^9.7) to match eslint-plugin-react, or upgrade to a future
eslint-plugin-react@8+ when available; as an interim workaround, modify
eslint.config.js to add settings: { react: { version: "detect" } } inside the
config object where the jsx-sort-props rule is declared (this bypasses the
plugin's dynamic version detection that calls the removed context.getFilename
API).

@BhushanLagare7 BhushanLagare7 merged commit be69640 into main May 4, 2026
1 check passed
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