@@ -64,7 +64,6 @@ type lintModel struct {
6464 error error
6565 watching bool
6666 skipped bool
67- canSkip bool
6867 ctx context.Context
6968 cmd * cli.Command
7069 client stainless.Client
@@ -97,11 +96,6 @@ func (m lintModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9796 m .cmd = msg .cmd
9897 m .client = msg .client
9998
100- if m .canSkip && ! hasBlockingDiagnostic (m .diagnostics ) {
101- m .watching = false
102- return m , tea .Quit
103- }
104-
10599 if m .watching {
106100 return m , func () tea.Msg {
107101 if err := waitTillConfigChanges (m .ctx , m .cmd , m .wc ); err != nil {
@@ -231,26 +225,28 @@ func getDiagnostics(ctx context.Context, cmd *cli.Command, client stainless.Clie
231225 return diagnostics , nil
232226}
233227
234- func (m lintModel ) ShortHelp () []key.Binding {
235- if m .canSkip {
236- return []key.Binding {
237- key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" )),
238- key .NewBinding (key .WithKeys ("enter" ), key .WithHelp ("enter" , "skip diagnostics" )),
228+ func hasBlockingDiagnostic (diagnostics []stainless.BuildDiagnostic ) bool {
229+ for _ , d := range diagnostics {
230+ if ! d .Ignored {
231+ switch d .Level {
232+ case stainless .BuildDiagnosticLevelFatal :
233+ case stainless .BuildDiagnosticLevelError :
234+ case stainless .BuildDiagnosticLevelWarning :
235+ return true
236+ case stainless .BuildDiagnosticLevelNote :
237+ continue
238+ }
239239 }
240- } else {
241- return []key.Binding {key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" ))}
242240 }
241+ return false
242+ }
243+
244+ func (m lintModel ) ShortHelp () []key.Binding {
245+ return []key.Binding {key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" ))}
243246}
244247
245248func (m lintModel ) FullHelp () [][]key.Binding {
246- if m .canSkip {
247- return [][]key.Binding {{
248- key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" )),
249- key .NewBinding (key .WithKeys ("enter" ), key .WithHelp ("enter" , "skip diagnostics" )),
250- }}
251- } else {
252- return [][]key.Binding {{key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" ))}}
253- }
249+ return [][]key.Binding {{key .NewBinding (key .WithKeys ("ctrl+c" ), key .WithHelp ("ctrl-c" , "quit" ))}}
254250}
255251
256252func runLinter (ctx context.Context , cmd * cli.Command , canSkip bool ) error {
@@ -265,7 +261,6 @@ func runLinter(ctx context.Context, cmd *cli.Command, canSkip bool) error {
265261 m := lintModel {
266262 spinner : s ,
267263 watching : cmd .Bool ("watch" ),
268- canSkip : canSkip ,
269264 ctx : ctx ,
270265 cmd : cmd ,
271266 client : client ,
@@ -297,7 +292,7 @@ func runLinter(ctx context.Context, cmd *cli.Command, canSkip bool) error {
297292 }
298293
299294 // If not in watch mode and we have blocking diagnostics, exit with error code
300- if ! cmd .Bool ("watch" ) && hasBlockingDiagnostic ( finalModel . diagnostics ) {
295+ if ! cmd .Bool ("watch" ) {
301296 os .Exit (1 )
302297 }
303298
0 commit comments