component-name
Full Name in eslint-plugin-react-naming-convention
react-naming-convention/component-nameFull Name in @eslint-react/eslint-plugin
@eslint-react/naming-convention/component-nameFeatures
🔍
What it does
Enforces naming conventions for components.
Examples
This rule enforces naming conventions for components. Can be used to enforce PascalCase and CONSTANT_CASE. By default, it enforces PascalCase.
Failing
import React from "react";
function Example_Component() {
// ^^^^^^^^^^^^^^^^^
// - Expected component name to be in 'PascalCase'.
return null;
}Passing
import React from "react";
function ExampleComponent() {
return null;
}Rule Options
rule: The rule to apply to the file name. Default is"PascalCase". Possible values:PascalCase: PascalCaseCONSTANT_CASE: CONSTANT_CASE
excepts: (optional) An array of component names that are allowed to not follow the rule.allowAllCaps: (optional) Iftrue, allows all caps file names. Default isfalse.allowNamespace: (optional) Iftrue, allows namespace in JSX elements. Default isfalse.allowLeadingUnderscore: (optional) Iftrue, allows leading underscore in file names. Default isfalse.
{
"@eslint-react/naming-convention/component-name": ["warn", "PascalCase"]
}{
"@eslint-react/naming-convention/component-name": [
"warn",
{ "rule": "PascalCase", "excepts": ["MyComponent"] }
]
}