utils

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternalModuleFolders added in v0.22.0

func ExternalModuleFolders(settings map[string]interface{}) []string

ExternalModuleFolders returns eslint-plugin-import's configured external module folders, defaulting to node_modules.

func HasDefaultExport added in v0.22.0

func HasDefaultExport(ctx rule.RuleContext, moduleSpecifier *ast.Node) (bool, bool)

HasDefaultExport resolves moduleSpecifier from ctx.SourceFile and reports whether the resolved module has a statically visible default export. The second result is false when no export map is available, matching eslint-plugin-import's "imports == null" branch.

func HasExport added in v0.22.0

func HasExport(ctx rule.RuleContext, moduleSpecifier *ast.Node, exportName string) (bool, bool)

HasExport resolves moduleSpecifier from ctx.SourceFile and reports whether the resolved module statically exports exportName. The second result is false when the target is unresolved or is not an ES module.

func IsExternalModulePath added in v0.22.0

func IsExternalModulePath(settings map[string]interface{}, specifier string, resolvedPath string) bool

IsExternalModulePath reports whether a resolved path or unresolved bare specifier should be treated as external by eslint-plugin-import rules.

func IsImportPathIgnored added in v0.22.0

func IsImportPathIgnored(settings map[string]interface{}, fileName string) bool

IsImportPathIgnored matches eslint-plugin-import's shared `import/ignore` setting for resolved import target paths.

func Resolve

func Resolve(moduleSpecifier *ast.StringLiteralLike, ctx rule.RuleContext) (string, bool)

func ResolveFromSourceFile added in v0.22.0

func ResolveFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, moduleSpecifier *ast.StringLiteralLike) (string, bool)

ResolveFromSourceFile resolves a module specifier using TypeScript's cached resolution result for the provided origin file.

func ResolveModuleReferenceFromSourceFile added in v0.22.0

func ResolveModuleReferenceFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, moduleSpecifier *ast.StringLiteralLike) (string, *ast.SourceFile, bool)

ResolveModuleReferenceFromSourceFile resolves lint graph edges. It first uses TypeScript resolution, then falls back to already-loaded relative source files for extension-substitution cases eslint-plugin-import still treats as edges.

func ResolveSourceFileFromSourceFile added in v0.22.0

func ResolveSourceFileFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, moduleSpecifier *ast.StringLiteralLike) (string, *ast.SourceFile, bool)

ResolveSourceFileFromSourceFile resolves a module specifier and returns the source file TypeScript associated with the resolved path.

Types

type ExportMap added in v0.22.0

type ExportMap struct {
	// contains filtered or unexported fields
}

ExportMap records the statically visible exports of an ES module. It does not synthesize default exports from compiler interop settings; HasExport keeps that looser existence check for rules that need it.

func GetExportMap added in v0.22.0

func GetExportMap(ctx rule.RuleContext, moduleSpecifier *ast.Node) (*ExportMap, bool)

GetExportMap resolves moduleSpecifier from ctx.SourceFile and returns a recursive export map. The second result is false when no export map is available, matching eslint-plugin-import's "imports == null" branch.

func NewExportMap added in v0.22.0

func NewExportMap() *ExportMap

func (*ExportMap) AddUnknown added in v0.22.0

func (m *ExportMap) AddUnknown()

func (*ExportMap) Get added in v0.22.0

func (m *ExportMap) Get(name string) *ExportMeta

func (*ExportMap) Has added in v0.22.0

func (m *ExportMap) Has(name string) bool

func (*ExportMap) MergeFrom added in v0.22.0

func (m *ExportMap) MergeFrom(other *ExportMap, includeDefault bool)

func (*ExportMap) Set added in v0.22.0

func (m *ExportMap) Set(name string, meta *ExportMeta)

func (*ExportMap) Size added in v0.22.0

func (m *ExportMap) Size() int

type ExportMeta added in v0.22.0

type ExportMeta struct {
	Namespace *ExportMap
}

type ModuleReference added in v0.22.0

type ModuleReference struct {
	Source       *ast.Node
	Importer     *ast.Node
	SourceFile   *ast.SourceFile
	Target       *ast.SourceFile
	ResolvedPath string
	Specifier    string
	Dynamic      bool
	OnlyTypes    bool
}

func CollectModuleReferences added in v0.22.0

func CollectModuleReferences(ctx rule.RuleContext, sourceFile *ast.SourceFile, options ModuleReferenceOptions) []ModuleReference

type ModuleReferenceOptions added in v0.22.0

type ModuleReferenceOptions struct {
	ESModule bool
	CommonJS bool
	AMD      bool
}

type VisitModulesOptions

type VisitModulesOptions struct {
	Commonjs bool
	AMD      bool
	ESModule bool
}

Jump to

Keyboard shortcuts

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