Skip to content

Consolidate dual ESLint config to flat config - #170

Open
shazzar00ni wants to merge 2 commits into
mainfrom
feature/consolidate-eslint-config
Open

Consolidate dual ESLint config to flat config#170
shazzar00ni wants to merge 2 commits into
mainfrom
feature/consolidate-eslint-config

Conversation

@shazzar00ni

@shazzar00ni shazzar00ni commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Merge rules from legacy .eslintrc.cjs into eslint.config.js (ESLint 9+ flat config format)
  • Add react-hooks plugin and rules
  • Add @typescript-eslint/no-explicit-any: warn rule
  • Set no-unused-vars to error with argsIgnorePattern: ^_
  • Delete legacy .eslintrc.cjs file (silently ignored by ESLint 9+)
  • Fix react-hooks/set-state-in-effect violations by using lazy initializers
  • Update CONTRIBUTING.md with ESLint 9+ requirement

Acceptance Criteria

  • Single ESLint config file (eslint.config.js)
  • All legacy rules now enforced (react-hooks, typescript, react-refresh)
  • npm run lint passes with 0 errors/warnings
  • npm run build passes
  • CONTRIBUTING.md documents flat config requirement

Testing Steps

  1. Run npm run lint - should pass with 0 warnings
  2. Run npm run build - should build successfully
  3. Verify no .eslintrc* files exist at root

Open in Devin Review

- Merge .eslintrc.cjs rules into eslint.config.js (ESLint 9+ flat config)
- Add react-hooks plugin and rules
- Add @typescript-eslint/no-explicit-any rule
- Set no-unused-vars to error with argsIgnorePattern: ^_
- Delete legacy .eslintrc.cjs file
- Fix react-hooks/set-state-in-effect violations by using lazy initializers
- Update CONTRIBUTING.md with ESLint 9+ requirement

@infinitcode-ai infinitcode-ai 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.

Summary

The pull request migrates ESLint configuration from .eslintrc.cjs to eslint.config.js, consolidates globals, adds react-hooks plugin, and moves useEffect initialization logic into useState lazy initializers in CookieConsent and ThemeContext. The changes are generally positive, improving code organization and performance, but the removal of useEffect in ThemeContext introduces a potential issue where applyTheme is called during render, which may cause side effects in React's strict mode.

Review Verdict: ❌ Improvements Suggested
The PR is largely correct, but the side effect in ThemeContext's useState initializer violates React's rules and could cause issues in strict mode. This should be addressed before merging.

Changes

File Path Changes Detected
.eslintrc.cjs • Deleted the old ESLint configuration file as part of migration to flat config.
eslint.config.js • Added import for eslint-plugin-react-hooks and its recommended rules.
• Extracted browser globals into a shared browserGlobals object to reduce duplication.
• Removed the no-unused-vars rule from the JavaScript config (now handled by TypeScript config).
• Added @typescript-eslint/no-explicit-any rule set to warn.
• Updated @typescript-eslint/no-unused-vars rule to error with argsIgnorePattern.
src/components/CookieConsent.tsx • Removed useEffect and moved localStorage check into useState lazy initializer for performance improvement.
src/components/UploadDemo.tsx • Moved simulateUpload function definition above the useEffect that calls it, improving code readability and logical order.
src/lib/ThemeContext.tsx • Removed useEffect and moved getInitialTheme and applyTheme calls into useState lazy initializer.

Issues

🟠 Major Severity

1. Side effect in useState initializer in ThemeContext - src/lib/ThemeContext.tsx (lines 74-77)

Risk: Calling applyTheme inside the useState initializer is a side effect during render, which is not allowed in React. In strict mode, the initializer may be called twice, causing the theme to be applied twice and potentially leading to inconsistent UI state.
Fix: Move the applyTheme call into a useEffect or use a layout effect to apply the theme after the initial render.

-  const [theme, setTheme] = useState<Theme>(() => {
-    const initial = getInitialTheme();
-    applyTheme(initial);
-    return initial;
-  });
+  const [theme, setTheme] = useState<Theme>(getInitialTheme);
+
+  useEffect(() => {
+    applyTheme(theme);
+  }, [theme]);

Code Style & Consistency

All identifiers follow project casing conventions.

Hot Take

"This PR is like a chef who rearranges the kitchen but forgets to turn off the stove - moving applyTheme into useState initializer is a recipe for double-cooked bugs in strict mode. At least the ESLint config got a nice haircut, even if it's still wearing the same old globals."

Example Commands:

@infinitcodeai review          Trigger an instant AI PR review.
@infinitcodeai {prompt}        Ask anything about your codebase.

Note: For additional settings, navigate to Infinitcode AI.

About

Automated review powered by Infinitcode AI
Report generated at 4/23/2026, 2:16:36 PM

@vercel

vercel Bot commented Apr 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docugen Ready Ready Preview, Comment May 6, 2026 0:46am

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@shazzar00ni has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 58 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b4ea97d7-cfac-44e3-8035-62cb4c70b6bd

📥 Commits

Reviewing files that changed from the base of the PR and between dcff020 and d8c90ec.

📒 Files selected for processing (5)
  • CONTRIBUTING.md
  • eslint.config.js
  • src/components/CookieConsent.tsx
  • src/components/UploadDemo.tsx
  • src/lib/ThemeContext.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/consolidate-eslint-config

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 and usage tips.

Comment thread eslint.config.js
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';

const browserGlobals = {

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread eslint.config.js Outdated
Comment thread src/lib/ThemeContext.tsx Outdated
@codacy-production

codacy-production Bot commented Apr 23, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@shazzar00ni shazzar00ni linked an issue Apr 23, 2026 that may be closed by this pull request
5 tasks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates the repository onto ESLint’s flat-config setup by folding the old .eslintrc.cjs rules into eslint.config.js, then updates a few React components and docs to align with the stricter linting setup.

Changes:

  • Merges legacy ESLint rules into the flat config and adds react-hooks / stricter TypeScript lint rules.
  • Refactors ThemeContext and CookieConsent initialization to avoid state-setting inside effects, and rearranges UploadDemo.
  • Removes the legacy .eslintrc.cjs file and documents the flat-config migration in CONTRIBUTING.md.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib/ThemeContext.tsx Refactors theme initialization/application logic for hook-rule compliance.
src/components/UploadDemo.tsx Moves upload simulation helper within the component.
src/components/CookieConsent.tsx Switches consent visibility initialization to a lazy state initializer.
eslint.config.js Becomes the single source of ESLint configuration and adds new rules/plugins.
CONTRIBUTING.md Updates contributor prerequisites/documentation for flat config.
.eslintrc.cjs Removes the legacy ESLint config file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/ThemeContext.tsx Outdated
@@ -1,4 +1,4 @@
import { createContext, useEffect, useState, type ReactNode } from 'react';
import { createContext, useState, type ReactNode } from 'react';
Comment thread src/components/UploadDemo.tsx Outdated
Comment on lines +34 to +40
const simulateUpload = () => {
setIsUploading(true);
setTimeout(() => {
setIsUploading(false);
setIsComplete(true);
}, 2000);
};
Comment thread CONTRIBUTING.md
- Node.js 18+
- npm 9+
- Git
- ESLint 9+ (for local development, ESLint uses flat config)
Comment thread src/lib/ThemeContext.tsx Outdated
Comment on lines +76 to +79
// Apply theme to DOM after initial render (side effect belongs in useEffect)
useEffect(() => {
const initialTheme = getInitialTheme();
setTheme(initialTheme);
applyTheme(initialTheme);
}, []);
applyTheme(theme);
}, [theme]);
Resolved conflicts:
- eslint.config.js: consolidated rules with error level for no-explicit-any
- CookieConsent.tsx: use getInitialConsentState helper
- UploadDemo.tsx: useCallback for simulateUpload with proper deps
- ThemeContext.tsx: useEffect for applyTheme (fixes side effect in initializer)
@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate dual ESLint configuration (remove .eslintrc.cjs)

3 participants