no-typos
no-typos rule
no-typos rule
Detect common typos in React component properties and lifecycle methods. This rule is part of eslint-plugin-react-features.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Error (correctness) |
| Auto-Fix | 💡 Suggests corrections |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | All React projects |
Rule Details
Detects misspellings of React's class-component API in a class component (a
class extending React's Component or PureComponent, by binding). React
calls lifecycles and reads statics by exact name, so a misspelt one silently
never runs.
Reported:
| Code | Why |
|---|---|
ComponentDidMount(), static PropTypes | React's name in another letter case |
componenDidMount(), static defaulProps | a documented dropped-letter misspelling |
Card.DefaultProps = {} (Card is the class) | the same, assigned after the class |
static componentDidMount() | React calls lifecycles on the instance |
getDerivedStateFromProps() (not static) | React calls it only as a static |
Reading a static (Card.propTypes, PropTypes.string) is never reported, and
neither is any class that is not a React component.
Examples
❌ Incorrect
class MyComponent extends React.Component {
// Typo in lifecycle
componentDidUpate() {} // Should be componentDidUpdate
componentWillUnmout() {} // Should be componentWillUnmount
// Typo in static property
static PropTypes = {}; // Should be propTypes (lowercase p)
}✅ Correct
class MyComponent extends React.Component {
static propTypes = {};
static getDerivedStateFromProps() {
return null;
}
componentDidUpdate() {}
componentWillUnmount() {}
}Configuration Examples
Basic Usage
{
rules: {
'react-features/no-typos': 'error'
}
}Related Rules
display-name- Component namingreact-class-to-hooks- Migration to hooks
Further Reading
- React Component Lifecycle - React docs
Known False Negatives
The rule reads class components only (a class extending React's Component
or PureComponent, by binding). Not detected:
- statics assigned to a function component (
Card.PropTypes = …): whether a function is a component is not decided here; - misspellings other than a different letter case and the listed dropped
letters (
componentDidMoun); - a class extending a
Componentthe file never imports or declares.
Use this rule
npm install -D oxlint-plugin-react-features{ "jsPlugins": ["oxlint-plugin-react-features"], "rules": { "react-features/no-typos": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-react-features'], rules: { 'react-features/no-typos': 'error', }, },});oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.