logoESLint React
Rules

context-name

Enforces the context name to be a valid component name with the suffix 'Context'.

Full Name in eslint-plugin-react-naming-convention

react-naming-convention/context-name

Full Name in @eslint-react/eslint-plugin

@eslint-react/naming-convention-context-name

Presets

recommended recommended-typescript recommended-type-checked strict strict-typescript strict-type-checked

Rule Details

Enforces that the context has a valid component name with the suffix Context.

Common Violations

Invalid

const theme = createContext("");
const Theme = createContext("");
const themecontext = createContext("");
const themeContext = createContext("");

Valid

const ThemeContext = createContext("");

Invalid

const context = createContext("");

Valid

const Context = createContext("");

Resources

Further Reading

On this page