@@ -39,41 +39,69 @@ pub(super) struct LintFailure {
3939pub ( super ) enum LintMessageKind {
4040 LintOnly ,
4141 LintAndTypeCheck ,
42+ // Used when lint rules are skipped but type-check still runs.
43+ #[ allow( dead_code) ]
44+ TypeCheckOnly ,
4245}
4346
4447impl LintMessageKind {
4548 pub ( super ) fn from_lint_config ( lint_config : Option < & serde_json:: Value > ) -> Self {
46- let type_check_enabled = lint_config
47- . and_then ( |config| config. get ( "options" ) )
48- . and_then ( |options| options. get ( "typeCheck" ) )
49- . and_then ( serde_json:: Value :: as_bool)
50- . unwrap_or ( false ) ;
49+ if lint_config_type_check_enabled ( lint_config) {
50+ Self :: LintAndTypeCheck
51+ } else {
52+ Self :: LintOnly
53+ }
54+ }
5155
52- if type_check_enabled { Self :: LintAndTypeCheck } else { Self :: LintOnly }
56+ // Selects a variant from the `(lint, type-check)` enabled tuple callers have
57+ // already resolved, avoiding a second config lookup inside the helper.
58+ #[ allow( dead_code) ]
59+ pub ( super ) fn from_flags ( lint_enabled : bool , type_check_enabled : bool ) -> Self {
60+ match ( lint_enabled, type_check_enabled) {
61+ ( true , true ) => Self :: LintAndTypeCheck ,
62+ ( true , false ) => Self :: LintOnly ,
63+ ( false , true ) => Self :: TypeCheckOnly ,
64+ ( false , false ) => {
65+ unreachable ! (
66+ "from_flags called with (false, false) — caller must ensure lint or type-check runs before selecting a message kind"
67+ )
68+ }
69+ }
5370 }
5471
5572 pub ( super ) fn success_label ( self ) -> & ' static str {
5673 match self {
5774 Self :: LintOnly => "Found no warnings or lint errors" ,
5875 Self :: LintAndTypeCheck => "Found no warnings, lint errors, or type errors" ,
76+ Self :: TypeCheckOnly => "Found no type errors" ,
5977 }
6078 }
6179
6280 pub ( super ) fn warning_heading ( self ) -> & ' static str {
6381 match self {
6482 Self :: LintOnly => "Lint warnings found" ,
6583 Self :: LintAndTypeCheck => "Lint or type warnings found" ,
84+ Self :: TypeCheckOnly => "Type warnings found" ,
6685 }
6786 }
6887
6988 pub ( super ) fn issue_heading ( self ) -> & ' static str {
7089 match self {
7190 Self :: LintOnly => "Lint issues found" ,
7291 Self :: LintAndTypeCheck => "Lint or type issues found" ,
92+ Self :: TypeCheckOnly => "Type errors found" ,
7393 }
7494 }
7595}
7696
97+ pub ( super ) fn lint_config_type_check_enabled ( lint_config : Option < & serde_json:: Value > ) -> bool {
98+ lint_config
99+ . and_then ( |config| config. get ( "options" ) )
100+ . and_then ( |options| options. get ( "typeCheck" ) )
101+ . and_then ( serde_json:: Value :: as_bool)
102+ . unwrap_or ( false )
103+ }
104+
77105fn parse_check_summary ( line : & str ) -> Option < CheckSummary > {
78106 let rest = line. strip_prefix ( "Finished in " ) ?;
79107 let ( duration, rest) = rest. split_once ( " on " ) ?;
0 commit comments