Skip to content

Conversation

@TheCodeDestroyer
Copy link
Owner

@TheCodeDestroyer TheCodeDestroyer commented Aug 28, 2025

Summary by CodeRabbit

  • Bug Fixes

    • React ESLint preset now recognizes Node globals, reducing false “undefined variable” lint errors in Node/SSR contexts.
  • Chores

    • Added patch release entry for the React ESLint preset.
    • Introduced a dependency to supply standard Node globals.

@changeset-bot
Copy link

changeset-bot bot commented Aug 28, 2025

🦋 Changeset detected

Latest commit: e8fde55

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tcd-devkit/eslint-preset-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 28, 2025

📝 Walkthrough

Walkthrough

Adds a changeset for a patch release, adds the "globals" dependency to the React ESLint preset package, and updates the React preset to include Node globals via languageOptions.globals.

Changes

Cohort / File(s) Summary
Release metadata
\.changeset/slick-geese-yawn.md
Adds a changeset entry describing a patch release for adding missing Node globals to the React preset.
Dependency update
packages/eslint-presets/eslint-preset-react/package.json
Adds dependency "globals": "16.3.0" to support defining Node globals in the preset.
ESLint React preset config
packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
Imports globals and adds languageOptions: { globals: { ...globals.node } } to expose Node globals in the React preset.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant CLI as ESLint CLI
  participant Loader as Config Loader
  participant ReactPreset as React ESLint Preset
  participant G as globals (package)
  participant Engine as Lint Engine

  Dev->>CLI: run eslint
  CLI->>Loader: resolve config
  Loader->>ReactPreset: load preset
  ReactPreset->>G: import node globals
  ReactPreset-->>Loader: config with languageOptions.globals (Node)
  Loader-->>Engine: finalized config
  Engine->>Engine: lint with Node globals recognized
  Engine-->>Dev: report results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot changed the title @coderabbitai Add changeset, globals dep, and Node globals to React ESLint preset Aug 28, 2025
Copy link

@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: 0

🧹 Nitpick comments (2)
packages/eslint-presets/eslint-preset-react/package.json (1)

65-66: Confirm versioning policy for new runtime dep and Renovate alignment.

Adding "globals" as a runtime dependency is correct for config-time import. Please confirm:

  • Pinning vs caret matches repo policy so Renovate can handle bumps.
  • This external dep in a preset (intended as a bundle of internal configs) is acceptable per your preset design principles.
packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts (1)

21-25: Avoid enabling Node-only globals across all React source — prefer shared browser+node or scope to non-browser files.

Enabling only globals.node at the preset root can mask accidental Node-only identifiers in client code. Two safer options:

  • Option A (broad, safe): merge browser + node.
     languageOptions: {
       globals: {
-        ...globals.node,
+        ...globals.browser,
+        ...globals.node,
       },
     },
  • Option B (strict): keep browser globals at the root, and add a separate config item with files globs for config/test/build scripts that applies Node globals only (I can draft the override if you share your typical file globs).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f7cea24 and e8fde55.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • .changeset/slick-geese-yawn.md (1 hunks)
  • packages/eslint-presets/eslint-preset-react/package.json (1 hunks)
  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/internal-utils/src/test.utils.ts:0-0
Timestamp: 2025-05-23T18:45:38.179Z
Learning: TheCodeDestroyer prefers consistent API design and likes to use unified interface names when functions share similar option patterns, even if some properties aren't used by all functions.
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-import-ts/package.json:65-67
Timestamp: 2025-05-23T19:34:31.271Z
Learning: TheCodeDestroyer prefers to use Renovate for automated dependency management rather than manual dependency version updates in package.json files.
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#7
File: renovate.json:2-4
Timestamp: 2025-05-25T09:20:16.838Z
Learning: TheCodeDestroyer prefers using local Renovate presets with the "local>" syntax to avoid external fetches, rather than GitHub-based presets.
📚 Learning: 2025-05-23T17:49:36.376Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint-presets/eslint-preset-node/src/node-preset.linter.ts:14-20
Timestamp: 2025-05-23T17:49:36.376Z
Learning: The tcd-devkit preset packages (like eslint-preset-node) are designed to be combinations of existing tcd-devkit config packages rather than introducing new external plugins or rules. They serve as "plug n play" bundles for convenience.

Applied to files:

  • .changeset/slick-geese-yawn.md
  • packages/eslint-presets/eslint-preset-react/package.json
  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-23T18:25:39.851Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-react/package.json:80-80
Timestamp: 2025-05-23T18:25:39.851Z
Learning: The tcd-devkit ESLint configuration packages (like eslint-config-react) are built from scratch specifically for ESLint v9+ using the flat config format, not migrated from older ESLint versions.

Applied to files:

  • .changeset/slick-geese-yawn.md
  • packages/eslint-presets/eslint-preset-react/package.json
  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-23T19:29:58.142Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-next/package.json:68-68
Timestamp: 2025-05-23T19:29:58.142Z
Learning: In packages/eslint/eslint-config-next/package.json, the dependency "next/eslint-plugin-next": "15.4.0-canary.45" is intentionally using a canary version for enhanced types support that isn't available in stable versions yet. The maintainer plans to switch to stable once these features are officially released.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/package.json
📚 Learning: 2025-05-23T17:50:17.181Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-react/src/react.linter.ts:20-20
Timestamp: 2025-05-23T17:50:17.181Z
Learning: ESLint configuration packages in the tcd-devkit ecosystem are designed to be consumed by external projects, so they may include file patterns and extensions (like mjsx, mtsx) that aren't used in the current monorepo but might be needed by consuming projects.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/package.json
  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-23T19:27:10.314Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/internal-utils/package.json:55-55
Timestamp: 2025-05-23T19:27:10.314Z
Learning: Each individual ESLint config package in the tcd-devkit monorepo has its own "imports" field that maps "#*" to their source files, enabling alias imports like #react.linter within their own package scope. The internal-utils package doesn't need an "imports" field when it only contains one source file.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/package.json
  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-23T19:30:46.588Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-ts/src/ts.linter.ts:19-19
Timestamp: 2025-05-23T19:30:46.588Z
Learning: In the tcd-devkit codebase, TypeScript ESLint configurations use double type assertion `as unknown as Linter.Config[]` to convert from typescript-eslint's ConfigArray type to standard ESLint Linter.Config[] type for maintaining type consistency across all ESLint configurations.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-23T19:25:15.891Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#5
File: packages/eslint/eslint-config-a11y/src/typings/eslint-plugin-jsx-a11y.d.ts:1-14
Timestamp: 2025-05-23T19:25:15.891Z
Learning: In TypeScript module declaration files (.d.ts) using `declare module`, adding explicit import statements for types can cause TypeScript compilation crashes and prevent module declarations from being detected. Types like Linter.Config and Linter.LegacyConfig from ESLint are typically available as ambient types without explicit imports in this context.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
📚 Learning: 2025-05-31T20:36:11.700Z
Learnt from: TheCodeDestroyer
PR: TheCodeDestroyer/devkit#32
File: eslint.config.mjs:5-10
Timestamp: 2025-05-31T20:36:11.700Z
Learning: The NextJS ESLint plugin (next/eslint-plugin-next) exports a default named plugin that requires importing as a default export and then destructuring the needed configuration (e.g., flatConfig). This pattern triggers the `import-x/no-rename-default` rule, necessitating a global disable of this rule when using NextJS ESLint configurations.

Applied to files:

  • packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts
🔇 Additional comments (2)
.changeset/slick-geese-yawn.md (1)

1-6: Changeset reads well and matches the code changes.

Patch note is clear and scoped.

packages/eslint-presets/eslint-preset-react/src/react-preset.linter.ts (1)

4-4: LGTM on importing globals.

Usage matches the ESM default export.

@TheCodeDestroyer TheCodeDestroyer merged commit 3a3db90 into main Aug 28, 2025
3 checks passed
@TheCodeDestroyer TheCodeDestroyer deleted the fix-react-preset branch August 28, 2025 16:45
@github-actions github-actions bot mentioned this pull request Aug 28, 2025
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.

2 participants