Documentation
¶
Index ¶
- func ExternalModuleFolders(settings map[string]interface{}) []string
- func GetPhysicalFilename(ctx rule.RuleContext) string
- func HasDefaultExport(ctx rule.RuleContext, moduleSpecifier *ast.Node) (bool, bool)
- func HasExport(ctx rule.RuleContext, moduleSpecifier *ast.Node, exportName string) (bool, bool)
- func IsExternalModulePath(settings map[string]interface{}, specifier string, resolvedPath string) bool
- func IsImportPathIgnored(settings map[string]interface{}, fileName string) bool
- func Resolve(moduleSpecifier *ast.StringLiteralLike, ctx rule.RuleContext) (string, bool)
- func ResolveFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, ...) (string, bool)
- func ResolveModuleReferenceFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, ...) (string, *ast.SourceFile, bool)
- func ResolveSourceFileFromSourceFile(ctx rule.RuleContext, sourceFile *ast.SourceFile, ...) (string, *ast.SourceFile, bool)
- func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), ...) rule.RuleListeners
- type ExportMap
- type ExportMeta
- type ModuleReference
- type ModuleReferenceOptions
- type VisitModulesOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExternalModuleFolders ¶ added in v0.22.0
ExternalModuleFolders returns eslint-plugin-import's configured external module folders, defaulting to node_modules.
func GetPhysicalFilename ¶
func GetPhysicalFilename(ctx rule.RuleContext) string
func HasDefaultExport ¶ added in v0.22.0
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
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
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.
func VisitModules ¶
func VisitModules(visitor func(source *ast.StringLiteralLike, node *ast.Node), options VisitModulesOptions) rule.RuleListeners
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
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) Set ¶ added in v0.22.0
func (m *ExportMap) Set(name string, meta *ExportMeta)
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