Documentation
¶
Index ¶
- func ListenerOnAllowPattern(kind ast.Kind) ast.Kind
- func ListenerOnExit(kind ast.Kind) ast.Kind
- func ListenerOnNotAllowPattern(kind ast.Kind) ast.Kind
- func ReportNodeWithFixesOrSuggestions(ctx RuleContext, node *ast.Node, fix bool, msg RuleMessage, ...)
- type DiagnosticSeverity
- type DisableManager
- type ESLintDirective
- type ESLintDirectiveKind
- type Rule
- type RuleContext
- type RuleDiagnostic
- type RuleFix
- func RuleFixInsertAfter(node *ast.Node, text string) RuleFix
- func RuleFixInsertBefore(file *ast.SourceFile, node *ast.Node, text string) RuleFix
- func RuleFixRemove(file *ast.SourceFile, node *ast.Node) RuleFix
- func RuleFixRemoveRange(textRange core.TextRange) RuleFix
- func RuleFixReplace(file *ast.SourceFile, node *ast.Node, text string) RuleFix
- func RuleFixReplaceRange(textRange core.TextRange, text string) RuleFix
- type RuleListeners
- type RuleMessage
- type RuleSuggestion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenerOnAllowPattern ¶
TODO(port): better name
func ReportNodeWithFixesOrSuggestions ¶
func ReportNodeWithFixesOrSuggestions(ctx RuleContext, node *ast.Node, fix bool, msg RuleMessage, suggestionMsg RuleMessage, fixes ...RuleFix)
Types ¶
type DiagnosticSeverity ¶
type DiagnosticSeverity int
DiagnosticSeverity represents the severity level of a diagnostic
const ( SeverityError DiagnosticSeverity = iota SeverityWarning SeverityOff )
func ParseSeverity ¶
func ParseSeverity(level string) DiagnosticSeverity
ParseSeverity converts a string to DiagnosticSeverity
func (DiagnosticSeverity) Int ¶
func (s DiagnosticSeverity) Int() int
String returns the string representation of the severity
func (DiagnosticSeverity) String ¶
func (s DiagnosticSeverity) String() string
String returns the string representation of the severity
type DisableManager ¶
type DisableManager struct {
// contains filtered or unexported fields
}
DisableManager tracks which rules are disabled at different locations in a file
func NewDisableManager ¶
func NewDisableManager(sourceFile *ast.SourceFile, comments []*ast.CommentRange) *DisableManager
NewDisableManager creates a new DisableManager for the given source file
func (*DisableManager) IsRuleDisabled ¶
func (dm *DisableManager) IsRuleDisabled(ruleName string, pos int) bool
IsRuleDisabled checks if a rule is disabled at the given position
type ESLintDirective ¶
type ESLintDirective struct { Kind ESLintDirectiveKind Line int RuleNames []string }
ESLintDirective represents an ESLint disable/enable directive
type ESLintDirectiveKind ¶
type ESLintDirectiveKind int
const ( ESLintDirectiveDisable ESLintDirectiveKind = iota ESLintDirectiveEnable ESLintDirectiveDisableLine ESLintDirectiveDisableNextLine )
type Rule ¶
type Rule struct { Name string Run func(ctx RuleContext, options any) RuleListeners }
func CreateRule ¶
type RuleContext ¶
type RuleContext struct { SourceFile *ast.SourceFile Program *compiler.Program TypeChecker *checker.Checker DisableManager *DisableManager ReportRange func(textRange core.TextRange, msg RuleMessage) ReportRangeWithSuggestions func(textRange core.TextRange, msg RuleMessage, suggestions ...RuleSuggestion) ReportNode func(node *ast.Node, msg RuleMessage) ReportNodeWithFixes func(node *ast.Node, msg RuleMessage, fixes ...RuleFix) ReportNodeWithSuggestions func(node *ast.Node, msg RuleMessage, suggestions ...RuleSuggestion) }
type RuleDiagnostic ¶
type RuleDiagnostic struct { Range core.TextRange RuleName string Message RuleMessage // nil if no fixes were provided FixesPtr *[]RuleFix // nil if no suggestions were provided Suggestions *[]RuleSuggestion SourceFile *ast.SourceFile Severity DiagnosticSeverity }
func (RuleDiagnostic) Fixes ¶
func (d RuleDiagnostic) Fixes() []RuleFix
type RuleFix ¶
func RuleFixInsertBefore ¶
func RuleFixRemove ¶
func RuleFixRemove(file *ast.SourceFile, node *ast.Node) RuleFix
func RuleFixRemoveRange ¶
func RuleFixReplace ¶
type RuleMessage ¶
type RuleSuggestion ¶
type RuleSuggestion struct { Message RuleMessage FixesArr []RuleFix }
func (RuleSuggestion) Fixes ¶
func (s RuleSuggestion) Fixes() []RuleFix
Click to show internal directories.
Click to hide internal directories.