Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var JsxIndentPropsRule = BuildRule("react/jsx-indent-props")
JsxIndentPropsRule is the eslint-plugin-react variant of jsx-indent-props.
Functions ¶
func BuildRule ¶
BuildRule constructs the jsx-indent-props rule registered under name.
Ported from eslint-plugin-react's `jsx-indent-props` rule. The rule walks every JsxOpeningElement / JsxSelfClosingElement, computes the expected prop indent (either `<element-indent> + indentSize` for the numeric / tab modes, or the column of the first prop for `'first'`), and reports each attribute whose leading-whitespace count differs.
tsgo↔ESTree shape adjustments (vs the upstream JS rule):
- Self-closing `<Foo />` is `JsxSelfClosingElement` with no wrapping `JsxElement`, so both `JsxOpeningElement` and `JsxSelfClosingElement` share the same listener.
- Source-line scans (line-start, leading whitespace, first non-WS char) run against `SourceFile.Text()`; line numbers come from the ECMA line map via `scanner.ComputeLineOfPosition`.
Ternary operator handling: upstream maintains a `line.isUsingOperator` flag, updated by `getNodeIndent` from each scanned line, that grants the next first-in-line prop an extra `indentSize` bump (when `'first'` mode and `ignoreTernaryOperator` are both off). We replicate `getNodeIndent`'s per-prop side effect with the exact same precedence: a line starting with `?`/`:` after whitespace (useOperator) sets the flag and PRECEDES the `<`-contains reset (useBracket). That precedence is load-bearing for the shape where the first prop shares the opening tag's `?`/`:` line — the line both starts with the operator and contains `<`, and upstream keeps the flag set so the bump carries to the following props.
Types ¶
This section is empty.