@@ -5,6 +5,7 @@ import { DEFAULT_EXTENSIONS, MARKDOWN_EXTENSIONS } from 'eslint-mdx'
55import vfile from 'vfile'
66
77import { getRemarkProcessor } from './helper'
8+ import { RemarkLintMessage } from './types'
89
910export const remark : Rule . RuleModule = {
1011 meta : {
@@ -14,9 +15,6 @@ export const remark: Rule.RuleModule = {
1415 category : 'Stylistic Issues' ,
1516 recommended : true ,
1617 } ,
17- messages : {
18- remarkReport : '{{ source }}:{{ ruleId }} - {{ reason }}' ,
19- } ,
2018 fixable : 'code' ,
2119 } ,
2220 create ( context ) {
@@ -34,6 +32,7 @@ export const remark: Rule.RuleModule = {
3432 options . markdownExtensions || [ ] ,
3533 ) . includes ( extname )
3634 return {
35+ // eslint-disable-next-line sonarjs/cognitive-complexity
3736 Program ( node ) {
3837 /* istanbul ignore if */
3938 if ( ! isMdx && ! isMarkdown ) {
@@ -59,15 +58,26 @@ export const remark: Rule.RuleModule = {
5958 source,
6059 reason,
6160 ruleId,
61+ fatal,
6262 location : { start, end } ,
6363 } 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+ }
6478 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 ) ,
7181 loc : {
7282 // ! eslint ast column is 0-indexed, but unified is 1-indexed
7383 start : {
0 commit comments