Skip to content

Commit 852de8f

Browse files
authored
fix(playground): show ast when lint pass (#323)
1 parent 07e2690 commit 852de8f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cmd/rslint/api.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
132132
var diagnostics []api.Diagnostic
133133
var diagnosticsLock sync.Mutex
134134
errorsCount := 0
135-
135+
136136
// Track source files for encoding
137137
sourceFiles := make(map[string]*ast.SourceFile)
138138
var sourceFilesLock sync.Mutex
@@ -185,12 +185,7 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
185185

186186
diagnostics = append(diagnostics, diagnostic)
187187
errorsCount++
188-
189-
// Track source file for encoding
190-
sourceFilesLock.Lock()
191-
filePath := tspath.ConvertToRelativePath(d.SourceFile.FileName(), comparePathOptions)
192-
sourceFiles[filePath] = d.SourceFile
193-
sourceFilesLock.Unlock()
188+
194189
}
195190

196191
// Run linter
@@ -200,6 +195,11 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
200195
allowedFiles,
201196
utils.ExcludePaths,
202197
func(sourceFile *ast.SourceFile) []linter.ConfiguredRule {
198+
// Track source file for encoding
199+
sourceFilesLock.Lock()
200+
filePath := tspath.ConvertToRelativePath(sourceFile.FileName(), comparePathOptions)
201+
sourceFiles[filePath] = sourceFile
202+
sourceFilesLock.Unlock()
203203
return utils.Map(rulesWithOptions, func(r RuleWithOption) linter.ConfiguredRule {
204204

205205
return linter.ConfiguredRule{
@@ -219,7 +219,7 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
219219
if diagnostics == nil {
220220
diagnostics = []api.Diagnostic{}
221221
}
222-
222+
223223
// Create response
224224
response := &api.LintResponse{
225225
Diagnostics: diagnostics,
@@ -232,7 +232,7 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
232232
encodedSourceFiles := make(map[string]api.ByteArray)
233233
for filePath, sourceFile := range sourceFiles {
234234
encoded, err := api.EncodeAST(sourceFile, filePath)
235-
235+
236236
if err != nil {
237237
// Log error but don't fail the entire request
238238
fmt.Fprintf(os.Stderr, "warning: failed to encode source file %s: %v\n", filePath, err)

0 commit comments

Comments
 (0)