@@ -29,7 +29,7 @@ const loader = async (moduleName: string) => {
29
29
return mod as any ;
30
30
} ;
31
31
32
- type S = 'error' | 'warn' | 'suggestion' | 'off ' | 0 | 1 | 2 ;
32
+ type S = 'off' | ' error' | 'warn' | 'suggestion' | 'message ' | 0 | 1 | 2 | 3 | 4 ;
33
33
type O < T extends any [ ] > = S | [ S , ...options : T ] ;
34
34
35
35
/**
@@ -41,22 +41,16 @@ export async function convertRules(
41
41
) {
42
42
const rules : TSSLint . Rules = { } ;
43
43
for ( const [ rule , severityOrOptions ] of Object . entries ( rulesConfig ) ) {
44
- let severity : boolean ;
44
+ let severity : S ;
45
45
let options : any [ ] ;
46
46
if ( Array . isArray ( severityOrOptions ) ) {
47
- // @ts -expect-error
48
47
[ severity , ...options ] = severityOrOptions ;
49
48
}
50
49
else {
51
- // @ts -expect-error
52
50
severity = severityOrOptions ;
53
51
options = [ ] ;
54
52
}
55
- // @ts -expect-error backward compatibility
56
53
if ( severity === 'off' || severity === 0 ) {
57
- severity = false ;
58
- }
59
- if ( ! severity ) {
60
54
rules [ rule ] = noop ;
61
55
continue ;
62
56
}
@@ -67,6 +61,13 @@ export async function convertRules(
67
61
rules [ rule ] = convertRule (
68
62
ruleModule ,
69
63
options ,
64
+ severity === 'warn' || severity === 1
65
+ ? 0
66
+ : severity === 'error' || severity === 2
67
+ ? 1
68
+ : severity === 'suggestion' || severity === 3
69
+ ? 2
70
+ : 3 ,
70
71
{ id : rule , ...context }
71
72
) ;
72
73
}
@@ -82,6 +83,7 @@ export async function convertRules(
82
83
*/
83
84
export async function defineRules (
84
85
rulesConfig : { [ K in keyof ESLintRulesConfig ] : boolean | ESLintRulesConfig [ K ] } ,
86
+ category : ts . DiagnosticCategory = 3 satisfies ts . DiagnosticCategory . Message ,
85
87
context : Partial < ESLint . Rule . RuleContext > = { }
86
88
) {
87
89
const rules : TSSLint . Rules = { } ;
@@ -107,6 +109,7 @@ export async function defineRules(
107
109
rules [ rule ] = convertRule (
108
110
ruleModule ,
109
111
options ,
112
+ category ,
110
113
{ id : rule , ...context }
111
114
) ;
112
115
}
@@ -162,6 +165,7 @@ async function loadRule(pluginName: string | undefined, ruleName: string): Promi
162
165
export function convertRule (
163
166
eslintRule : ESLint . Rule . RuleModule ,
164
167
options : any [ ] = [ ] ,
168
+ category : ts . DiagnosticCategory = 3 satisfies ts . DiagnosticCategory . Message ,
165
169
context : Partial < ESLint . Rule . RuleContext > = { }
166
170
) : TSSLint . Rule {
167
171
// ESLint internal scripts
@@ -249,7 +253,7 @@ export function convertRule(
249
253
}
250
254
}
251
255
} catch { }
252
- const reporter = report ( message , start , end , 2 ) ;
256
+ const reporter = report ( message , start , end , category , 2 ) ;
253
257
if ( descriptor . fix ) {
254
258
// @ts -expect-error
255
259
const textChanges = getTextChanges ( descriptor . fix ) ;
0 commit comments