Components Rules
Component props, folder naming, structure consistency, and SVG icons
6 rules3 auto-isFixable2 isConfigurable1 TypeScript-only
On This Page
component-props-destructure
auto-isFixable
Component props must be destructured in the function parameter
Why: Destructured props make it clear what props a component uses
Correct
javascript
export const Button = ({ label, onClick }) => ( <button onClick={onClick}>{label}</button>);Incorrect
javascript
export const Button = (props) => ( <button onClick={props.onClick}>{props.label}</button>);eslint.config.js
javascript
"code-style/component-props-destructure": "error"component-props-inline-type
auto-isFixableTypeScript only
Enforce inline type annotation for component props instead of interface reference
Why: Inline types keep prop definitions colocated with the component
Correct
javascript
export const Button = ({ label } : { label: string }) => ( <button>{label}</button>);Incorrect
javascript
export const Button = ({ label }: ButtonPropsInterface) => ( <button>{label}</button>);eslint.config.js
javascript
"code-style/component-props-inline-type": "error"folder-based-naming-convention
auto-isFixableisConfigurable
Enforce naming based on folder: suffix for views/layouts/pages/providers, camelCase for data/constants
Why: Consistent naming based on folder structure makes purpose immediately clear
Options
| Option | Type | Default | Description |
|---|---|---|---|
chainOrder | string | "child-parent" | Order of folder chain in names |
files | array | [] | Per-path chainOrder overrides |
eslint.config.js
javascript
"code-style/folder-based-naming-convention": ["error", { chainOrder: "child-parent", files: [] }]Correct
javascript
// views/dashboard.tsxexport const DashboardView = () => <div>Dashboard</div>;Incorrect
javascript
// views/dashboard.tsxexport const Dashboard = () => <div>Dashboard</div>;eslint.config.js
javascript
"code-style/folder-based-naming-convention": "error"folder-structure-consistency
isConfigurablereport only
Enforce consistent folder structure (flat vs wrapped) in module folders
Why: Mixing flat files and wrapped folders creates inconsistency
Options
| Option | Type | Default | Description |
|---|---|---|---|
moduleFolders | string[] | (built-in list) | Module folders to check |
extraModuleFolders | string[] | [] | Additional folders to check |
eslint.config.js
javascript
"code-style/folder-structure-consistency": ["error", { moduleFolders: (built-in list), extraModuleFolders: [] }]Correct
javascript
atoms/input.tsxatoms/calendar.tsxIncorrect
javascript
atoms/input.tsxatoms/calendar/index.tsxatoms/calendar/helpers.tseslint.config.js
javascript
"code-style/folder-structure-consistency": "error"no-redundant-folder-suffix
report only
Disallow file/folder names that redundantly include the parent folder name as a suffix
Why: The folder already provides context, so the name doesn't need to repeat it
Correct
javascript
layouts/main.tsxIncorrect
javascript
layouts/main-layout.tsxeslint.config.js
javascript
"code-style/no-redundant-folder-suffix": "error"svg-icon-naming-convention
report only
SVG components must end with 'Icon' suffix; 'Icon' suffix components must return SVG
Why: Consistent naming makes it clear which components render icons
Correct
javascript
export const SuccessIcon = () => ( <svg><path d="M9 12l2 2 4-4" /></svg>);Incorrect
javascript
export const Success = () => ( <svg><path d="M9 12l2 2 4-4" /></svg>);eslint.config.js
javascript
"code-style/svg-icon-naming-convention": "error"