Skip to content

Commit a14ed3d

Browse files
authored
fix(cli): exclude cwd from input path resolution (#1466)
1 parent ecc28f0 commit a14ed3d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

cmd/api-linter/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func newCli(args []string) *cli {
9494
FormatType: fmtFlag,
9595
OutputPath: outFlag,
9696
ExitStatusOnLintFailure: setExitStatusOnLintFailure,
97-
ProtoImportPaths: append(protoImportFlag, "."),
97+
ProtoImportPaths: protoImportFlag,
9898
ProtoDescPath: protoDescFlag,
9999
EnabledRules: ruleEnableFlag,
100100
DisabledRules: ruleDisableFlag,
@@ -152,7 +152,7 @@ func (c *cli) lint(rules lint.RuleRegistry, configs lint.Configs) error {
152152
var lock sync.Mutex
153153
// Parse proto files into `protoreflect` file descriptors.
154154
p := protoparse.Parser{
155-
ImportPaths: c.ProtoImportPaths,
155+
ImportPaths: append(c.ProtoImportPaths, "."),
156156
IncludeSourceCodeInfo: true,
157157
LookupImport: lookupImport,
158158
ErrorReporter: func(errorWithPos protoparse.ErrorWithPos) error {

cmd/api-linter/cli_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestNewCli(t *testing.T) {
3030
OutputPath: "out",
3131
FormatType: "json",
3232
ProtoDescPath: []string{"proto_desc1", "proto_desc2"},
33-
ProtoImportPaths: []string{"proto_path_a", "proto_path_b", "."},
33+
ProtoImportPaths: []string{"proto_path_a", "proto_path_b"},
3434
ProtoFiles: []string{"a.proto", "b.proto"},
3535
},
3636
},
@@ -41,7 +41,6 @@ func TestNewCli(t *testing.T) {
4141
},
4242
wantCli: &cli{
4343
ExitStatusOnLintFailure: true,
44-
ProtoImportPaths: []string{"."},
4544
ProtoFiles: []string{},
4645
},
4746
},

0 commit comments

Comments
 (0)