no-typos
no-typos rule
Keywords: React, typos, lifecycle, static properties, ESLint rule, autocorrect, LLM-optimized
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 in React lifecycle methods and static properties.
Common Typos Detected
| Typo | Correct |
|---|---|
componentDidUpate | componentDidUpdate |
componentWillUnmout | componentWillUnmount |
getDerivedStateFromProp | getDerivedStateFromProps |
propTypes (wrong case) | propTypes |
defaultProps (wrong) | defaultProps |
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
this.somePropertyConfiguration 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 following patterns are not detected due to static analysis limitations:
Dynamic Variable References
Why: Static analysis cannot trace values stored in variables or passed through function parameters.
// ❌ NOT DETECTED - Prop from variable
const propValue = computedValue;
<Component prop={propValue} /> // Computation not analyzedMitigation: Implement runtime validation and review code manually. Consider using TypeScript branded types for validated inputs.
Wrapped or Aliased Functions
Why: Custom wrapper functions or aliased methods are not recognized by the rule.
// ❌ NOT DETECTED - Custom wrapper
function myWrapper(data) {
return internalApi(data); // Wrapper not analyzed
}
myWrapper(unsafeInput);Mitigation: Apply this rule's principles to wrapper function implementations. Avoid aliasing security-sensitive functions.
Imported Values
Why: When values come from imports, the rule cannot analyze their origin or construction.
// ❌ NOT DETECTED - Value from import
import { getValue } from './helpers';
processValue(getValue()); // Cross-file not trackedMitigation: Ensure imported values follow the same constraints. Use TypeScript for type safety.