no_inner_declarations

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 NoInnerDeclarationsRule = rule.Rule{
	Name: "no-inner-declarations",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		opts := parseOptions(options)

		listeners := rule.RuleListeners{
			ast.KindFunctionDeclaration: func(node *ast.Node) {
				if opts.blockScopedFunctions == "allow" && utils.IsInStrictMode(node, ctx.SourceFile) {
					return
				}
				check(node, "function", &ctx)
			},
		}

		if opts.both {
			listeners[ast.KindVariableStatement] = func(node *ast.Node) {
				varStmt := node.AsVariableStatement()
				if varStmt == nil || varStmt.DeclarationList == nil {
					return
				}

				if varStmt.DeclarationList.Flags&ast.NodeFlagsBlockScoped != 0 {
					return
				}

				check(node, "variable", &ctx)
			}
		}

		return listeners
	},
}

https://eslint.org/docs/latest/rules/no-inner-declarations

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