Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var JsxPropsNoMultiSpacesRule = rule.Rule{ Name: "react/jsx-props-no-multi-spaces", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { text := ctx.SourceFile.Text() lineStarts := ctx.SourceFile.ECMALineMap() check := func(node *ast.Node) { var props []*ast.Node var tagNameEnd int var tagName *ast.Node switch node.Kind { case ast.KindJsxOpeningElement: opening := node.AsJsxOpeningElement() tagName = opening.TagName tagNameEnd = getTagNameEnd(ctx, opening.TagName, opening.TypeArguments) attrs := opening.Attributes.AsJsxAttributes() if attrs.Properties != nil { props = attrs.Properties.Nodes } case ast.KindJsxSelfClosingElement: self := node.AsJsxSelfClosingElement() tagName = self.TagName tagNameEnd = getTagNameEnd(ctx, self.TagName, self.TypeArguments) attrs := self.Attributes.AsJsxAttributes() if attrs.Properties != nil { props = attrs.Properties.Nodes } } if len(props) == 0 { return } firstTrimmed := utils.TrimNodeTextRange(ctx.SourceFile, props[0]) tagDisplayName := getTagDisplayName(ctx, tagName) checkGap(ctx, text, lineStarts, tagNameEnd, firstTrimmed.Pos(), firstTrimmed.End(), props[0], tagDisplayName, getDisplayName(props[0])) for i := 1; i < len(props); i++ { prevTrimmed := utils.TrimNodeTextRange(ctx.SourceFile, props[i-1]) currTrimmed := utils.TrimNodeTextRange(ctx.SourceFile, props[i]) checkGap(ctx, text, lineStarts, prevTrimmed.End(), currTrimmed.Pos(), currTrimmed.End(), props[i], getDisplayName(props[i-1]), getDisplayName(props[i])) } } return rule.RuleListeners{ ast.KindJsxOpeningElement: check, ast.KindJsxSelfClosingElement: check, } }, }
JsxPropsNoMultiSpacesRule disallows multiple spaces between inline JSX props.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.