no_bitwise

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoBitwiseRule = rule.Rule{
	Name: "no-bitwise",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		opts := parseOptions(options)

		report := func(node *ast.Node, opKind ast.Kind, rightOperand *ast.Node) {
			if !bitwiseOperatorKinds[opKind] {
				return
			}
			op := scanner.TokenToString(opKind)
			if opts.allow[op] {
				return
			}

			if opts.int32Hint && opKind == ast.KindBarToken && isZeroNumericLiteral(rightOperand) {
				return
			}
			ctx.ReportNode(node, buildUnexpectedMessage(op))
		}

		return rule.RuleListeners{
			ast.KindBinaryExpression: func(node *ast.Node) {
				binary := node.AsBinaryExpression()
				if binary == nil || binary.OperatorToken == nil {
					return
				}
				report(node, binary.OperatorToken.Kind, binary.Right)
			},
			ast.KindPrefixUnaryExpression: func(node *ast.Node) {
				prefix := node.AsPrefixUnaryExpression()
				if prefix == nil {
					return
				}

				report(node, prefix.Operator, nil)
			},
		}
	},
}

NoBitwiseRule disallows bitwise operators. https://eslint.org/docs/latest/rules/no-bitwise

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL