@@ -29,7 +29,7 @@ const loader = async (moduleName: string) => {
2929 return mod as any ;
3030} ;
3131
32- type S = 'error' | 'warn' | 'suggestion' | 'off ' | 0 | 1 | 2 ;
32+ type S = 'off' | ' error' | 'warn' | 'suggestion' | 'message ' | 0 | 1 | 2 | 3 | 4 ;
3333type O < T extends any [ ] > = S | [ S , ...options : T ] ;
3434
3535/**
@@ -41,22 +41,16 @@ export async function convertRules(
4141) {
4242 const rules : TSSLint . Rules = { } ;
4343 for ( const [ rule , severityOrOptions ] of Object . entries ( rulesConfig ) ) {
44- let severity : boolean ;
44+ let severity : S ;
4545 let options : any [ ] ;
4646 if ( Array . isArray ( severityOrOptions ) ) {
47- // @ts -expect-error
4847 [ severity , ...options ] = severityOrOptions ;
4948 }
5049 else {
51- // @ts -expect-error
5250 severity = severityOrOptions ;
5351 options = [ ] ;
5452 }
55- // @ts -expect-error backward compatibility
5653 if ( severity === 'off' || severity === 0 ) {
57- severity = false ;
58- }
59- if ( ! severity ) {
6054 rules [ rule ] = noop ;
6155 continue ;
6256 }
@@ -67,6 +61,13 @@ export async function convertRules(
6761 rules [ rule ] = convertRule (
6862 ruleModule ,
6963 options ,
64+ severity === 'warn' || severity === 1
65+ ? 0
66+ : severity === 'error' || severity === 2
67+ ? 1
68+ : severity === 'suggestion' || severity === 3
69+ ? 2
70+ : 3 ,
7071 { id : rule , ...context }
7172 ) ;
7273 }
@@ -82,6 +83,7 @@ export async function convertRules(
8283 */
8384export async function defineRules (
8485 rulesConfig : { [ K in keyof ESLintRulesConfig ] : boolean | ESLintRulesConfig [ K ] } ,
86+ category : ts . DiagnosticCategory = 3 satisfies ts . DiagnosticCategory . Message ,
8587 context : Partial < ESLint . Rule . RuleContext > = { }
8688) {
8789 const rules : TSSLint . Rules = { } ;
@@ -107,6 +109,7 @@ export async function defineRules(
107109 rules [ rule ] = convertRule (
108110 ruleModule ,
109111 options ,
112+ category ,
110113 { id : rule , ...context }
111114 ) ;
112115 }
@@ -162,6 +165,7 @@ async function loadRule(pluginName: string | undefined, ruleName: string): Promi
162165export function convertRule (
163166 eslintRule : ESLint . Rule . RuleModule ,
164167 options : any [ ] = [ ] ,
168+ category : ts . DiagnosticCategory = 3 satisfies ts . DiagnosticCategory . Message ,
165169 context : Partial < ESLint . Rule . RuleContext > = { }
166170) : TSSLint . Rule {
167171 // ESLint internal scripts
@@ -249,7 +253,7 @@ export function convertRule(
249253 }
250254 }
251255 } catch { }
252- const reporter = report ( message , start , end , 2 ) ;
256+ const reporter = report ( message , start , end , category , 2 ) ;
253257 if ( descriptor . fix ) {
254258 // @ts -expect-error
255259 const textChanges = getTextChanges ( descriptor . fix ) ;
0 commit comments