Skip to content

Commit 143a8f8

Browse files
authored
fix: only lint input code for api mode (#219)
1 parent d1644df commit 143a8f8

16 files changed

+25
-455
lines changed

cmd/rslint/api.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
56
"os"
67
"sync"
78

@@ -95,9 +96,14 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
9596

9697
// Create filesystem
9798
fs := bundled.WrapFS(cachedvfs.From(osvfs.FS()))
99+
allowedFiles := []string{}
98100
// Apply file contents if provided
99101
if len(req.FileContents) > 0 {
100102
fs = utils.NewOverlayVFS(fs, req.FileContents)
103+
for file := range req.FileContents {
104+
105+
allowedFiles = append(allowedFiles, file) // Collect allowed files from request
106+
}
101107
}
102108

103109
// Initialize rule registry with all available rules
@@ -236,7 +242,7 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
236242
lintedFilesCount, err := linter.RunLinter(
237243
programs,
238244
false, // Don't use single-threaded mode for IPC
239-
nil,
245+
allowedFiles,
240246
func(sourceFile *ast.SourceFile) []linter.ConfiguredRule {
241247
return utils.Map(rulesWithOptions, func(r RuleWithOption) linter.ConfiguredRule {
242248

packages/rslint-test-tools/tests/typescript-eslint/fixtures/rslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"languageOptions": {
66
"parserOptions": {
77
"projectService": false,
8-
"project": ["./tsconfig.virtual.json"]
8+
"project": ["./tsconfig.json"]
99
}
1010
},
1111
"rules": {},

packages/rslint-test-tools/tests/typescript-eslint/fixtures/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"experimentalDecorators": true
1414
},
1515
"include": [
16+
"virtual.tsx",
17+
"virtual.ts",
1618
"file.ts",
1719
"consistent-type-exports.ts",
1820
"deprecated.ts",

packages/rslint-test-tools/tests/typescript-eslint/fixtures/tsconfig.virtual.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/rslint-test-tools/tests/typescript-eslint/rules/__snapshots__/adjacent-overload-signatures.test.ts.snap

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports[`adjacent-overload-signatures > invalid 1`] = `
44
{
55
"diagnostics": [
66
{
7-
"filePath": "src/virtual.ts",
87
"message": "All foo signatures should be adjacent.",
98
"messageId": "adjacentSignature",
109
"range": {
@@ -30,7 +29,6 @@ exports[`adjacent-overload-signatures > invalid 2`] = `
3029
{
3130
"diagnostics": [
3231
{
33-
"filePath": "src/virtual.ts",
3432
"message": "All foo signatures should be adjacent.",
3533
"messageId": "adjacentSignature",
3634
"range": {
@@ -56,7 +54,6 @@ exports[`adjacent-overload-signatures > invalid 3`] = `
5654
{
5755
"diagnostics": [
5856
{
59-
"filePath": "src/virtual.ts",
6057
"message": "All foo signatures should be adjacent.",
6158
"messageId": "adjacentSignature",
6259
"range": {
@@ -82,7 +79,6 @@ exports[`adjacent-overload-signatures > invalid 4`] = `
8279
{
8380
"diagnostics": [
8481
{
85-
"filePath": "src/virtual.ts",
8682
"message": "All foo signatures should be adjacent.",
8783
"messageId": "adjacentSignature",
8884
"range": {
@@ -108,7 +104,6 @@ exports[`adjacent-overload-signatures > invalid 5`] = `
108104
{
109105
"diagnostics": [
110106
{
111-
"filePath": "src/virtual.ts",
112107
"message": "All foo signatures should be adjacent.",
113108
"messageId": "adjacentSignature",
114109
"range": {
@@ -134,7 +129,6 @@ exports[`adjacent-overload-signatures > invalid 6`] = `
134129
{
135130
"diagnostics": [
136131
{
137-
"filePath": "src/virtual.ts",
138132
"message": "All foo signatures should be adjacent.",
139133
"messageId": "adjacentSignature",
140134
"range": {
@@ -160,7 +154,6 @@ exports[`adjacent-overload-signatures > invalid 7`] = `
160154
{
161155
"diagnostics": [
162156
{
163-
"filePath": "src/virtual.ts",
164157
"message": "All foo signatures should be adjacent.",
165158
"messageId": "adjacentSignature",
166159
"range": {
@@ -186,7 +179,6 @@ exports[`adjacent-overload-signatures > invalid 8`] = `
186179
{
187180
"diagnostics": [
188181
{
189-
"filePath": "src/virtual.ts",
190182
"message": "All foo signatures should be adjacent.",
191183
"messageId": "adjacentSignature",
192184
"range": {
@@ -212,7 +204,6 @@ exports[`adjacent-overload-signatures > invalid 9`] = `
212204
{
213205
"diagnostics": [
214206
{
215-
"filePath": "src/virtual.ts",
216207
"message": "All foo signatures should be adjacent.",
217208
"messageId": "adjacentSignature",
218209
"range": {
@@ -238,7 +229,6 @@ exports[`adjacent-overload-signatures > invalid 10`] = `
238229
{
239230
"diagnostics": [
240231
{
241-
"filePath": "src/virtual.ts",
242232
"message": "All foo signatures should be adjacent.",
243233
"messageId": "adjacentSignature",
244234
"range": {
@@ -264,7 +254,6 @@ exports[`adjacent-overload-signatures > invalid 11`] = `
264254
{
265255
"diagnostics": [
266256
{
267-
"filePath": "src/virtual.ts",
268257
"message": "All foo signatures should be adjacent.",
269258
"messageId": "adjacentSignature",
270259
"range": {
@@ -290,7 +279,6 @@ exports[`adjacent-overload-signatures > invalid 12`] = `
290279
{
291280
"diagnostics": [
292281
{
293-
"filePath": "src/virtual.ts",
294282
"message": "All foo signatures should be adjacent.",
295283
"messageId": "adjacentSignature",
296284
"range": {
@@ -316,7 +304,6 @@ exports[`adjacent-overload-signatures > invalid 13`] = `
316304
{
317305
"diagnostics": [
318306
{
319-
"filePath": "src/virtual.ts",
320307
"message": "All baz signatures should be adjacent.",
321308
"messageId": "adjacentSignature",
322309
"range": {
@@ -342,7 +329,6 @@ exports[`adjacent-overload-signatures > invalid 14`] = `
342329
{
343330
"diagnostics": [
344331
{
345-
"filePath": "src/virtual.ts",
346332
"message": "All foo signatures should be adjacent.",
347333
"messageId": "adjacentSignature",
348334
"range": {
@@ -368,7 +354,6 @@ exports[`adjacent-overload-signatures > invalid 15`] = `
368354
{
369355
"diagnostics": [
370356
{
371-
"filePath": "src/virtual.ts",
372357
"message": "All baz signatures should be adjacent.",
373358
"messageId": "adjacentSignature",
374359
"range": {
@@ -394,7 +379,6 @@ exports[`adjacent-overload-signatures > invalid 16`] = `
394379
{
395380
"diagnostics": [
396381
{
397-
"filePath": "src/virtual.ts",
398382
"message": "All foo signatures should be adjacent.",
399383
"messageId": "adjacentSignature",
400384
"range": {
@@ -420,7 +404,6 @@ exports[`adjacent-overload-signatures > invalid 17`] = `
420404
{
421405
"diagnostics": [
422406
{
423-
"filePath": "src/virtual.ts",
424407
"message": "All foo signatures should be adjacent.",
425408
"messageId": "adjacentSignature",
426409
"range": {
@@ -446,7 +429,6 @@ exports[`adjacent-overload-signatures > invalid 18`] = `
446429
{
447430
"diagnostics": [
448431
{
449-
"filePath": "src/virtual.ts",
450432
"message": "All foo signatures should be adjacent.",
451433
"messageId": "adjacentSignature",
452434
"range": {
@@ -472,7 +454,6 @@ exports[`adjacent-overload-signatures > invalid 19`] = `
472454
{
473455
"diagnostics": [
474456
{
475-
"filePath": "src/virtual.ts",
476457
"message": "All call signatures should be adjacent.",
477458
"messageId": "adjacentSignature",
478459
"range": {
@@ -498,7 +479,6 @@ exports[`adjacent-overload-signatures > invalid 20`] = `
498479
{
499480
"diagnostics": [
500481
{
501-
"filePath": "src/virtual.ts",
502482
"message": "All foo signatures should be adjacent.",
503483
"messageId": "adjacentSignature",
504484
"range": {
@@ -524,7 +504,6 @@ exports[`adjacent-overload-signatures > invalid 21`] = `
524504
{
525505
"diagnostics": [
526506
{
527-
"filePath": "src/virtual.ts",
528507
"message": "All foo signatures should be adjacent.",
529508
"messageId": "adjacentSignature",
530509
"range": {
@@ -550,7 +529,6 @@ exports[`adjacent-overload-signatures > invalid 22`] = `
550529
{
551530
"diagnostics": [
552531
{
553-
"filePath": "src/virtual.ts",
554532
"message": "All foo signatures should be adjacent.",
555533
"messageId": "adjacentSignature",
556534
"range": {
@@ -576,7 +554,6 @@ exports[`adjacent-overload-signatures > invalid 23`] = `
576554
{
577555
"diagnostics": [
578556
{
579-
"filePath": "src/virtual.ts",
580557
"message": "All foo signatures should be adjacent.",
581558
"messageId": "adjacentSignature",
582559
"range": {
@@ -602,7 +579,6 @@ exports[`adjacent-overload-signatures > invalid 24`] = `
602579
{
603580
"diagnostics": [
604581
{
605-
"filePath": "src/virtual.ts",
606582
"message": "All baz signatures should be adjacent.",
607583
"messageId": "adjacentSignature",
608584
"range": {
@@ -628,7 +604,6 @@ exports[`adjacent-overload-signatures > invalid 25`] = `
628604
{
629605
"diagnostics": [
630606
{
631-
"filePath": "src/virtual.ts",
632607
"message": "All new signatures should be adjacent.",
633608
"messageId": "adjacentSignature",
634609
"range": {
@@ -654,7 +629,6 @@ exports[`adjacent-overload-signatures > invalid 26`] = `
654629
{
655630
"diagnostics": [
656631
{
657-
"filePath": "src/virtual.ts",
658632
"message": "All new signatures should be adjacent.",
659633
"messageId": "adjacentSignature",
660634
"range": {
@@ -670,7 +644,6 @@ exports[`adjacent-overload-signatures > invalid 26`] = `
670644
"ruleName": "@typescript-eslint/adjacent-overload-signatures",
671645
},
672646
{
673-
"filePath": "src/virtual.ts",
674647
"message": "All new signatures should be adjacent.",
675648
"messageId": "adjacentSignature",
676649
"range": {
@@ -696,7 +669,6 @@ exports[`adjacent-overload-signatures > invalid 27`] = `
696669
{
697670
"diagnostics": [
698671
{
699-
"filePath": "src/virtual.ts",
700672
"message": "All constructor signatures should be adjacent.",
701673
"messageId": "adjacentSignature",
702674
"range": {
@@ -722,7 +694,6 @@ exports[`adjacent-overload-signatures > invalid 28`] = `
722694
{
723695
"diagnostics": [
724696
{
725-
"filePath": "src/virtual.ts",
726697
"message": "All foo signatures should be adjacent.",
727698
"messageId": "adjacentSignature",
728699
"range": {
@@ -748,7 +719,6 @@ exports[`adjacent-overload-signatures > invalid 29`] = `
748719
{
749720
"diagnostics": [
750721
{
751-
"filePath": "src/virtual.ts",
752722
"message": "All foo signatures should be adjacent.",
753723
"messageId": "adjacentSignature",
754724
"range": {
@@ -774,7 +744,6 @@ exports[`adjacent-overload-signatures > invalid 30`] = `
774744
{
775745
"diagnostics": [
776746
{
777-
"filePath": "src/virtual.ts",
778747
"message": "All foo signatures should be adjacent.",
779748
"messageId": "adjacentSignature",
780749
"range": {
@@ -800,7 +769,6 @@ exports[`adjacent-overload-signatures > invalid 31`] = `
800769
{
801770
"diagnostics": [
802771
{
803-
"filePath": "src/virtual.ts",
804772
"message": "All constructor signatures should be adjacent.",
805773
"messageId": "adjacentSignature",
806774
"range": {
@@ -826,7 +794,6 @@ exports[`adjacent-overload-signatures > invalid 32`] = `
826794
{
827795
"diagnostics": [
828796
{
829-
"filePath": "src/virtual.ts",
830797
"message": "All foo signatures should be adjacent.",
831798
"messageId": "adjacentSignature",
832799
"range": {
@@ -852,7 +819,6 @@ exports[`adjacent-overload-signatures > invalid 33`] = `
852819
{
853820
"diagnostics": [
854821
{
855-
"filePath": "src/virtual.ts",
856822
"message": "All static foo signatures should be adjacent.",
857823
"messageId": "adjacentSignature",
858824
"range": {
@@ -878,7 +844,6 @@ exports[`adjacent-overload-signatures > invalid 34`] = `
878844
{
879845
"diagnostics": [
880846
{
881-
"filePath": "src/virtual.ts",
882847
"message": "All #private signatures should be adjacent.",
883848
"messageId": "adjacentSignature",
884849
"range": {
@@ -894,7 +859,6 @@ exports[`adjacent-overload-signatures > invalid 34`] = `
894859
"ruleName": "@typescript-eslint/adjacent-overload-signatures",
895860
},
896861
{
897-
"filePath": "src/virtual.ts",
898862
"message": "All '#private' signatures should be adjacent.",
899863
"messageId": "adjacentSignature",
900864
"range": {

0 commit comments

Comments
 (0)