Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 1.59 KB

jsx-pascal-case.md

File metadata and controls

72 lines (50 loc) · 1.59 KB

Enforce PascalCase for user-defined JSX components (react/jsx-pascal-case)

Enforces coding style that user-defined JSX components are defined and referenced in PascalCase.

Note that since React's JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags this rule will not warn on components that start with a lower case letter.

Rule Details

Examples of incorrect code for this rule:

<Test_component />
<TEST_COMPONENT />

Examples of correct code for this rule:

<div />
<TestComponent />
<TestComponent>
  <div />
</TestComponent>
<CSSTransitionGroup />

Rule Options

...
"react/jsx-pascal-case": [<enabled>, { allowAllCaps: <allowAllCaps>, allowNamespace: <allowNamespace>, ignore: <ignore> }]
...
  • enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
  • allowAllCaps: optional boolean set to true to allow components name in all caps (default to false).
  • allowNamespace: optional boolean set to true to ignore namespaced components (default to false).
  • ignore: optional string-array of component names to ignore during validation (supports minimatch-style globs).

allowAllCaps

Examples of correct code for this rule, when allowAllCaps is true:

<ALLOWED />
<TEST_COMPONENT />

allowNamespace

Examples of correct code for this rule, when allowNamespace is true:

<Allowed.div />
<TestComponent.p />

When Not To Use It

If you are not using JSX.