
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@fluentui/eslint-plugin
Advanced tools
ESLint configuration and custom rules for Fluent UI
Usage: in your ESLint config file, add { "extends": ["plugin:@fluentui/<name>"] } or { "extends": ["plugin:@fluentui/eslint-plugin/<name>"] } (the two are equivalent).
react: react specific configuration for fluentui vNextnode: node specific configuration for fluentui vNextreact--legacy: react specific configuration for fluentui v7,8node--legacy: node specific configuration for fluentui v7,8react-northstar: For @fluentui/react-northstar and related packagesimports: auto import statements sorting configurationHelpers for customizing configuration are exported under a configHelpers object.
ban-context-exportExporting context objects as a part of the public API can lead to unexpected usages of context by customers and might impede future refactoring. To allow customers use context while encapsulating our internals correctly, the developer should export a provider and hook.
❌ Don't
// src/context.ts
import * as React from 'react';
export const MyContext = React.createContext();
// src/index.ts
export { MyContext } from './context';
âś… Do
// src/context.ts
import * as React from 'react';
const MyContext = React.createContext();
export const MyContextProvider = MyContext.Provider;
export const useMyContext = () => React.useContext(MyContext);
// src/index.ts
export { MyContextProvider, useMyContext } from './context';
ban-importsBan importing or re-exporting from certain paths or modules. You can either ban the entire path, or only certain names. (Inspired by TSLint's import-blacklist.)
Requires one or more options objects. Either path or pathRegex is required.
path (string): Path or module to ban importing from (non-regex)pathRegex (string): Regex for path or module to ban importing fromnames ((string | { regex: string })[], optional): If provided, only ban imports of these names and/or regular expressions. Otherwise, ban all imports from the path.message (string[], optional): Custom message to show with errorsExample:
"@fluentui/ban-imports": [
"error",
{ "path": "lodash" },
{ "path": "foo", "names": ["bar", { "regex": "^baz" }] },
{ "pathRegex": "^\.", message: "no relative imports" },
{ "pathRegex": "^\.\./(foo|bar)$", "names": ["baz"] }
]
deprecated-keyboard-event-propsPrevent using deprecated KeyboardEvent props which and keyCode, and recommend using @fluentui/keyboard-key instead.
max-lenEnforces max line length, more performantly than ESLint's max-len.
This rule is significantly faster than the default max-len rule because it does not support:
(Skipping these extra features lets us do a basic string length check before running any regular expressions or other extra logic, which makes the huge majority of line length checks very fast.)
The rule requires an options object containing:
max (required): the maximum line lengthignorePatterns (optional): ignore the line if it matches any of these regular expressionsno-global-reactBan references to the React global namespace (in favor of explicitly importing React). Implicit global references cause problems for API Extractor and potentially other tools.
no-restricted-importsPrevents imports from forbidden packages. If a corresponding preferred import is provided, the lint error will be automatically fixable.
Example Configuration:
"@fluentui/no-restricted-imports": [
'error',
{
paths: [
{
forbidden: ['@fluentui/react-theme', '@griffel/react`],
preferred: '@fluentui/react-components',
},
],
},
],
❌ Don't
import * as React from 'react';
import { webDarkTheme } from '@fluentui/react-theme';
import { makeStyles } from '@griffel/react';
âś… Do
import * as React from 'react';
import { makeStyles, webDarkTheme } from '@fluentui/react-components';
no-tslint-commentsBan tslint:disable and tslint:enable comments.
no-visibility-modifiersPrevent visibility modifiers (public, protected, private) from being specified on class members/methods.
Used in Fluent UI only by @fluentui/react-northstar, not @fluentui/react.
no-context-default-valueRestricts usage of default values on React context creation. Imports should be provided to declare where the createContext function is coming from. For more information why this is necessary please consult #23624
Example Configuration:
"@fluentui/no-context-default-value": [
"error",
{
imports: ["react", "@fluentui/react-context-selector"]
}
]
❌ Don't
import * as React from 'react';
const context = React.createContext({ someValue: undefined });
âś… Do
import * as React from 'react';
const context = React.createContext(undefined);
ban-instanceof-html-elementBans usage of instanceof HTMLElement binary expressions as they might cause problems on multiple realms environments.
The alternative is to use isHTMLElement helper method provided by @fluentui/react-utilities packages, since that method does the proper verifications to ensure proper instance comparison.
❌ Don't
event.target instanceof HTMLElement;
event.target instanceof HTMLInputElement;
âś… Do
import { isHTMLElement } from '@fluentui/react-components';
isHTMLElement(event.target);
isHTMLElement(event.target, { constructorName: 'HTMLInputElement' });
FAQs
ESLint configuration and custom rules for Fluent UI
The npm package @fluentui/eslint-plugin receives a total of 37 weekly downloads. As such, @fluentui/eslint-plugin popularity was classified as not popular.
We found that @fluentui/eslint-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.