jsx-indent-props
Configuration
Rule Details
This rule enforces a consistent indentation style for JSX props. The default style is 4 spaces.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Rule Options
The first option accepts:
"tab"— tab-based indentation.- a non-negative integer — N-space indentation.
"first"— align each prop with the column of the first prop.- an object with these keys:
indentMode— same value space as the positional option above ("tab","first", or an integer).ignoreTernaryOperator— boolean (defaultfalse). Whentrue, props inside a JSX element nested in a?:consequent / alternate are NOT given an extraindentModebump.
Examples of incorrect code for this rule with ["error", 2]:
Examples of correct code for this rule with ["error", 2]:
Examples of correct code for this rule with ["error", "tab"]:
Examples of correct code for this rule with ["error", 0]:
Examples of incorrect code for this rule with ["error", "first"]:
Examples of correct code for this rule with ["error", "first"]:
Examples of correct code for this rule with ["error", { "indentMode": 2, "ignoreTernaryOperator": false }] (default — props inside a ?: branch receive an extra indentMode bump):
Examples of correct code for this rule with ["error", { "indentMode": 2, "ignoreTernaryOperator": true }] (no extra bump inside ?:):
When Not To Use It
If you are not using JSX, you can disable this rule. If you use a code formatter (e.g. Prettier) that already enforces JSX prop indentation, prefer relying on the formatter instead.