@@ -5,6 +5,7 @@ import { DEFAULT_EXTENSIONS, MARKDOWN_EXTENSIONS } from 'eslint-mdx'
5
5
import vfile from 'vfile'
6
6
7
7
import { getRemarkProcessor } from './helper'
8
+ import { RemarkLintMessage } from './types'
8
9
9
10
export const remark : Rule . RuleModule = {
10
11
meta : {
@@ -14,9 +15,6 @@ export const remark: Rule.RuleModule = {
14
15
category : 'Stylistic Issues' ,
15
16
recommended : true ,
16
17
} ,
17
- messages : {
18
- remarkReport : '{{ source }}:{{ ruleId }} - {{ reason }}' ,
19
- } ,
20
18
fixable : 'code' ,
21
19
} ,
22
20
create ( context ) {
@@ -34,6 +32,7 @@ export const remark: Rule.RuleModule = {
34
32
options . markdownExtensions || [ ] ,
35
33
) . includes ( extname )
36
34
return {
35
+ // eslint-disable-next-line sonarjs/cognitive-complexity
37
36
Program ( node ) {
38
37
/* istanbul ignore if */
39
38
if ( ! isMdx && ! isMarkdown ) {
@@ -59,15 +58,26 @@ export const remark: Rule.RuleModule = {
59
58
source,
60
59
reason,
61
60
ruleId,
61
+ fatal,
62
62
location : { start, end } ,
63
63
} of file . messages ) {
64
+ // https://github.com/remarkjs/remark-lint/issues/65#issuecomment-220800231
65
+ /* istanbul ignore next */
66
+ const severity = fatal ? 2 : fatal == null ? 0 : 1
67
+ /* istanbul ignore if */
68
+ if ( ! severity ) {
69
+ // should never happen, just for robustness
70
+ continue
71
+ }
72
+ const message : RemarkLintMessage = {
73
+ reason,
74
+ source,
75
+ ruleId,
76
+ severity,
77
+ }
64
78
context . report ( {
65
- messageId : 'remarkReport' ,
66
- data : {
67
- reason,
68
- source,
69
- ruleId,
70
- } ,
79
+ // related to https://github.com/eslint/eslint/issues/14198
80
+ message : JSON . stringify ( message ) ,
71
81
loc : {
72
82
// ! eslint ast column is 0-indexed, but unified is 1-indexed
73
83
start : {
0 commit comments