Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/eslint-plugin-react-components",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/global-context",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-charts",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-dialog",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to getWindow utility files",
"packageName": "@fluentui/react-icons-compat",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-migration-v0-v9",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-migration-v8-v9",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-nav",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-overflow",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-portal",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-positioning",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-provider",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-shared-contexts",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-tag-picker",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-text",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-toast",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add missing \"use client\" directive to client components and styles",
"packageName": "@fluentui/react-utilities",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { makeStyles } from '@griffel/react';
import { tokens, typographyStyles } from '@fluentui/react-theme';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { canUseDOM } from '@fluentui/react-utilities';

let _window: Window | undefined = undefined;
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/configs/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const reactCompilerPlugin = require('eslint-plugin-react-compiler');
const { __internal } = require('../../internal');
const { createReactCrossVersionRules } = require('../../shared/react-cross-version-rules');
const { defineConfig } = require('eslint/config');
const { testFiles } = require('../../utils/configHelpers');

/** @type {import("eslint").Linter.RulesRecord} */
const typeAwareRules = {
Expand Down Expand Up @@ -105,7 +106,7 @@ module.exports = defineConfig(
},

{
files: ['**/*.test.{ts,tsx}'],
files: [...testFiles],
rules: {
'react-compiler/react-compiler': 'off',
'@fluentui/react-components/enforce-use-client': 'off',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ The rule looks for any of the following client-only features:
- Custom hooks (functions whose name starts with `use` and are not in the safe set: `use`, `useId`)
- JSX event handler props (properties starting with `on` followed by a capital letter, like `onClick`)
- Direct references to browser globals (`window`, `document`, `navigator`, `localStorage`, `sessionStorage`, `history`, `location`)
- SSR-unsafe functions that internally use browser APIs (e.g. `canUseDOM()`, `makeStyles()`, `makeResetStyles()`, `makeStaticStyles()`)

If at least one feature is present, the directive must be the very first statement in the file. If no features are found, any existing `'use client'` directive will be reported as unnecessary and auto-fixed.

Expand Down Expand Up @@ -164,6 +165,47 @@ export function add(a: number, b: number) {
}
```

#### ❌ Don't (SSR-unsafe function at module scope)

```ts
import * as React from 'react';
import { canUseDOM } from '../ssr/index';

// canUseDOM() accesses browser APIs internally
export const useIsomorphicLayoutEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;
```

#### ✅ Do (directive added for SSR-unsafe function)

```ts
'use client';
import * as React from 'react';
import { canUseDOM } from '../ssr/index';

export const useIsomorphicLayoutEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;
```

#### ❌ Don't (Griffel styling function at module scope)

```ts
import { makeStyles } from '@griffel/react';

export const useStyles = makeStyles({
root: { backgroundColor: 'red' },
});
```

#### ✅ Do (directive added for Griffel function)

```ts
'use client';
import { makeStyles } from '@griffel/react';

export const useStyles = makeStyles({
root: { backgroundColor: 'red' },
});
```

No options – enable to enforce consistent usage of the directive.

## License
Expand Down
Loading