Use camelCase notation.
Use PascalCase notation.
"external" modules
node "builtin" modules
"pathGroups" modules
"internal" modules
modules from a "parent" directory
"sibling" modules from the same or a sibling's directory
"index" of the current directory
"object" - imports (only available in TypeScript)
"type" imports (only available in Flow and TypeScript)
If there is more than 1 module defined per level - sort alphabetically (or by root of nesting for relative-modules
).
import ... from 'fs';
import ... from 'path';
import ... from 'react';
import ... from '@localAlias/filename';
import ... from '@localAlias/filename';
import ... from 'dirname/filename';
import ... from '../filename';
import ... from './filename';
import ... from './';
import type ... from './filename';
export const myFunction = () => {};
const myFunction = () => {};
const myFunction = (props: Props) => {};
const myFunction: ReturnType = () => {};
-
Use react functional components.
-
Type components with children using react FC.
export const MyComponent: FC<Props> = ({ label, text, children }) => { return ( <div> <h1>{label}</h1> <p>{text}</p> {children} </div> ); };
-
Type components without children using react VFC.
export const MyComponent: VFC<Props> = ({ label, text }) => { return ( <div> <h1>{label}</h1> <p>{text}</p> </div> ); };