no-unknown-property
no-unknown-property rule
Keywords: React, JSX, props, HTML attributes, className, ESLint rule, DOM, LLM-optimized
Prevent unknown DOM properties in JSX. This rule is part of eslint-plugin-react-features.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Error (correctness) |
| Auto-Fix | ✅ Yes (converts to correct prop) |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | All React/JSX projects |
Rule Details
React uses camelCase for DOM attributes and has some renamed attributes (e.g., className instead of class).
Common Corrections
| HTML Attribute | JSX Property |
|---|---|
class | className |
for | htmlFor |
tabindex | tabIndex |
colspan | colSpan |
rowspan | rowSpan |
readonly | readOnly |
maxlength | maxLength |
cellpadding | cellPadding |
cellspacing | cellSpacing |
frameborder | frameBorder |
Examples
❌ Incorrect
<div class="container">Content</div>
<label for="input">Label</label>
<input tabindex="1" readonly />
<table cellpadding="5" cellspacing="0"></table>✅ Correct
<div className="container">Content</div>
<label htmlFor="input">Label</label>
<input tabIndex={1} readOnly />
<table cellPadding={5} cellSpacing={0}></table>Configuration Examples
Basic Usage
{
rules: {
'react-features/no-unknown-property': 'error'
}
}Related Rules
no-invalid-html-attribute- Validate attribute values
Further Reading
- DOM Elements - React docs
- JSX Differences - HTML vs JSX
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.