no_useless_empty_export

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoUselessEmptyExportRule = rule.CreateRule(rule.Rule{
	Name: "no-useless-empty-export",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {

		if isDefinitionFile(ctx.SourceFile.FileName()) {
			return rule.RuleListeners{}
		}

		// First pass: collect all statements to check for exports
		var emptyExports []*ast.Node
		hasOtherExports := false

		for _, statement := range ctx.SourceFile.Statements.Nodes {
			if isEmptyExport(statement) {
				emptyExports = append(emptyExports, statement)
			} else if isExportOrImportStatement(statement) {
				hasOtherExports = true
			}
		}

		if hasOtherExports {
			for _, emptyExport := range emptyExports {
				ctx.ReportNodeWithFixes(emptyExport, rule.RuleMessage{
					Id:          "uselessExport",
					Description: "Empty export does nothing and can be removed.",
				}, rule.RuleFixRemove(ctx.SourceFile, emptyExport))
			}
		}

		return rule.RuleListeners{}
	},
})

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