Skip to content

Commit 2be5909

Browse files
authored
chore: add cli tests (#120)
1 parent 0856761 commit 2be5909

File tree

5 files changed

+432
-20
lines changed

5 files changed

+432
-20
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ After building, you can test the rslint CLI:
4444
# Test the binary
4545
./packages/rslint/bin/rslint --help
4646

47-
# List files that would be linted
48-
./packages/rslint/bin/rslint --list-files
4947

5048
# Lint the project itself
5149
./packages/rslint/bin/rslint --config rslint.json

cmd/rslint/cmd.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ Usage:
316316
317317
Options:
318318
--config PATH Which rslint config file to use. Defaults to rslint.json.
319-
--list-files List matched files
320319
--format FORMAT Output format: default | jsonline
321320
--fix Automatically fix problems
322321
--no-color Disable colored output
@@ -330,10 +329,9 @@ func runCMD() int {
330329
flag.Usage = func() { fmt.Fprint(os.Stderr, usage) }
331330

332331
var (
333-
help bool
334-
config string
335-
listFiles bool
336-
fix bool
332+
help bool
333+
config string
334+
fix bool
337335

338336
traceOut string
339337
cpuprofOut string
@@ -346,7 +344,6 @@ func runCMD() int {
346344
)
347345
flag.StringVar(&format, "format", "default", "output format")
348346
flag.StringVar(&config, "config", "", "which rslint config to use")
349-
flag.BoolVar(&listFiles, "list-files", false, "list matched files")
350347
flag.BoolVar(&fix, "fix", false, "automatically fix problems")
351348
flag.BoolVar(&help, "help", false, "show help")
352349
flag.BoolVar(&help, "h", false, "show help")
@@ -438,24 +435,15 @@ func runCMD() int {
438435
files := []*ast.SourceFile{}
439436
for _, program := range programs {
440437
cwdPath := string(tspath.ToPath("", currentDirectory, program.Host().FS().UseCaseSensitiveFileNames()).EnsureTrailingDirectorySeparator())
441-
var matchedFiles strings.Builder
442438
for _, file := range program.SourceFiles() {
443439
p := string(file.Path())
444440
if strings.Contains(p, "/node_modules/") {
445441
continue
446442
}
447-
if fileName, matched := strings.CutPrefix(p, cwdPath); matched {
448-
if listFiles {
449-
matchedFiles.WriteString("Found file: ")
450-
matchedFiles.WriteString(fileName)
451-
matchedFiles.WriteByte('\n')
452-
}
443+
if _, matched := strings.CutPrefix(p, cwdPath); matched {
453444
files = append(files, file)
454445
}
455446
}
456-
if listFiles {
457-
os.Stdout.WriteString(matchedFiles.String())
458-
}
459447
slices.SortFunc(files, func(a *ast.SourceFile, b *ast.SourceFile) int {
460448
return len(b.Text()) - len(a.Text())
461449
})

0 commit comments

Comments
 (0)