Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmd/rslint/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"sort"
"sync"

"github.com/microsoft/typescript-go/shim/ast"
Expand Down Expand Up @@ -219,6 +220,16 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
if diagnostics == nil {
diagnostics = []api.Diagnostic{}
}
// sort diagnostics
sort.Slice(diagnostics, func(i, j int) bool {
if diagnostics[i].FilePath != diagnostics[j].FilePath {
return diagnostics[i].FilePath < diagnostics[j].FilePath
}
if diagnostics[i].Range.Start.Line != diagnostics[j].Range.Start.Line {
return diagnostics[i].Range.Start.Line < diagnostics[j].Range.Start.Line
}
return diagnostics[i].Range.Start.Column < diagnostics[j].Range.Start.Column
})

// Create response
response := &api.LintResponse{
Expand Down
2 changes: 1 addition & 1 deletion internal/rules/dot_notation/dot_notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ var DotNotationRule = rule.CreateRule(rule.Rule{
replacement := objectText + whitespace + "." + propName

// Report on the node with the fix
ctx.ReportNodeWithFixes(node, buildUseDotMessage(), rule.RuleFixReplace(ctx.SourceFile, node, replacement))
ctx.ReportNodeWithFixes(elem.ArgumentExpression, buildUseDotMessage(), rule.RuleFixReplace(ctx.SourceFile, node, replacement))
Copy link
Preview

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagnostic is being reported on elem.ArgumentExpression but the fix is applied to the entire node. This mismatch could cause the fix to replace more than the highlighted range, potentially affecting unrelated code.

Suggested change
ctx.ReportNodeWithFixes(elem.ArgumentExpression, buildUseDotMessage(), rule.RuleFixReplace(ctx.SourceFile, node, replacement))
ctx.ReportNodeWithFixes(node, buildUseDotMessage(), rule.RuleFixReplace(ctx.SourceFile, node, replacement))

Copilot uses AI. Check for mistakes.

}
}

Expand Down
Loading
Loading