react/function-component-definition Style
What it does
Enforces a consistent function form for React function components.
Why is this bad?
Mixing declarations, function expressions, and arrow functions makes component definitions less predictable and harder to scan.
Examples
Examples of incorrect code for this rule:
jsx
const Component = () => <div />;Examples of correct code for this rule:
jsx
function Component() {
return <div />;
}Configuration
namedComponents
type: array | "function-declaration" | "arrow-function" | "function-expression"
namedComponents[n]
type: "function-declaration" | "arrow-function" | "function-expression"
unnamedComponents
type: array | "arrow-function" | "function-expression"
unnamedComponents[n]
type: "arrow-function" | "function-expression"
How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["react"],
"rules": {
"react/function-component-definition": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["react"],
rules: {
"react/function-component-definition": "error",
},
});bash
oxlint --deny react/function-component-definition --react-pluginVersion
This rule was added in vnext.
