Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 12, 2025

Successfully propagated the enforce-use-client workspace rule to the public @fluentui/eslint-plugin-react-components package. The rule is now available for external users and provides the same functionality as the internal version.

📦 What was implemented:

Rule Features:

  • Detects React hooks (useState, useEffect, useContext, etc.)
  • Detects React APIs (createContext, forwardRef, memo, etc.)
  • Detects browser APIs (window, document, localStorage, etc.)
  • Detects event handlers in JSX (onClick, onChange, etc.)
  • Detects custom hooks (functions starting with "use")
  • Automatically adds/removes "use client" directive as needed
  • Server-safe exceptions (useId, utility functions)

Implementation Details:

  • ✅ Converted from internal workspace TypeScript rule to public plugin TypeScript format
  • ✅ Added to @fluentui/eslint-plugin-react-components (the public v9 plugin, not the private v8 plugin)
  • ✅ Follows v9 plugin patterns using createRule utility
  • ✅ 89 comprehensive test cases covering all scenarios (87 for enforce-use-client rule)
  • ✅ Auto-fix capability with edge case handling
  • ✅ Complete documentation with examples and usage guidelines in README.md
  • ✅ API documentation updated
  • ✅ No breaking changes to existing functionality

Testing Results:

  • ✅ All 89 tests pass (87 enforce-use-client tests + 2 prefer-fluentui-v9 tests)
  • ✅ Build succeeds without errors
  • ✅ Rule properly exported and accessible via @fluentui/react-components/enforce-use-client

🚀 Usage:

External users can now add the rule to their ESLint config:

{
  "plugins": ["@fluentui/react-components"],
  "rules": {
    "@fluentui/react-components/enforce-use-client": "error"
  }
}

📍 Package Location:

The rule is published in @fluentui/eslint-plugin-react-components, which is:

  • The public ESLint plugin for Fluent UI v9 React Components
  • Published to npm for external consumption
  • The appropriate location for modern React Server Components (RSC) tooling

Fixes #35189.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@dmytrokirpa
Copy link
Contributor

@copilot the rule should go to @fluentui/eslint-plugin-react-components instead of @fluentui/eslint-plugin

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot the rule should go to @fluentui/eslint-plugin-react-components instead of @fluentui/eslint-plugin

Done! Moved the rule from @fluentui/eslint-plugin to @fluentui/eslint-plugin-react-components as requested.

The rule is now:

  • Located in the v9 React components plugin (the public, non-private plugin)
  • Converted to TypeScript following v9 plugin patterns
  • Fully tested with 89 passing tests
  • Documented in the README with comprehensive examples

Changes in commit d0371fa.

Copilot AI changed the title [WIP] [Feature]: propagate enforce-use-client workspace rule to public [Feature]: Propagate enforce-use-client workspace rule to public @fluentui/eslint-plugin-react-components Oct 2, 2025
Copilot finished work on behalf of dmytrokirpa October 2, 2025 13:20
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

github-actions bot commented Oct 2, 2025

Pull request demo site: URL

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Feature]: propagate enforce-use-client workspace rule to public

2 participants