From fe73161b18b1739320cd9499effeac7dae2267e5 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 7 May 2022 13:38:23 +0200 Subject: [PATCH 1/3] fix line-sorted error output --- .gitignore | 1 + .../src/processors/remark.ts | 2 +- test/__snapshots__/fixtures.test.ts.snap | 20 +++++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6e0e29a1..57118d90 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ coverage lib node_modules /test.mdx +.idea/ diff --git a/packages/eslint-plugin-mdx/src/processors/remark.ts b/packages/eslint-plugin-mdx/src/processors/remark.ts index 8265d25d..7ef06ad3 100644 --- a/packages/eslint-plugin-mdx/src/processors/remark.ts +++ b/packages/eslint-plugin-mdx/src/processors/remark.ts @@ -30,7 +30,7 @@ export const remark: Linter.Processor = { return [ ...mdxMessages, ...processors.markdown.postprocess(markdownMessages, filename), - ].map(lintMessage => { + ].sort((a, b) => a.line - b.line).map(lintMessage => { const { message, ruleId: eslintRuleId, diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index 2b516661..164cf6a7 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -78,16 +78,6 @@ import React from 'react' "ruleId": "remark-lint-no-duplicate-headings-in-section", "severity": 1, }, - Object { - "column": 1, - "endColumn": 4, - "endLine": 17, - "line": 15, - "message": "Missing code language flag", - "nodeType": "Program", - "ruleId": "remark-lint-fenced-code-flag", - "severity": 1, - }, Object { "column": 18, "endColumn": 30, @@ -106,6 +96,16 @@ import React from 'react' "ruleId": "unicorn/prefer-array-flat", "severity": 2, }, + Object { + "column": 1, + "endColumn": 4, + "endLine": 17, + "line": 15, + "message": "Missing code language flag", + "nodeType": "Program", + "ruleId": "remark-lint-fenced-code-flag", + "severity": 1, + }, Object { "column": 1, "endColumn": 6, From b6f299c5a59ebd63336b13dbdf715b2b29dbcaa3 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 7 May 2022 13:53:52 +0200 Subject: [PATCH 2/3] lint fix --- .../src/processors/remark.ts | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/eslint-plugin-mdx/src/processors/remark.ts b/packages/eslint-plugin-mdx/src/processors/remark.ts index 7ef06ad3..e7ecf06b 100644 --- a/packages/eslint-plugin-mdx/src/processors/remark.ts +++ b/packages/eslint-plugin-mdx/src/processors/remark.ts @@ -30,27 +30,29 @@ export const remark: Linter.Processor = { return [ ...mdxMessages, ...processors.markdown.postprocess(markdownMessages, filename), - ].sort((a, b) => a.line - b.line).map(lintMessage => { - const { - message, - ruleId: eslintRuleId, - severity: eslintSeverity, - } = lintMessage + ] + .sort((a, b) => a.line - b.line) + .map(lintMessage => { + const { + message, + ruleId: eslintRuleId, + severity: eslintSeverity, + } = lintMessage - if (eslintRuleId !== 'mdx/remark') { - return lintMessage - } + if (eslintRuleId !== 'mdx/remark') { + return lintMessage + } - const { source, ruleId, reason, severity } = JSON.parse( - message, - ) as RemarkLintMessage + const { source, ruleId, reason, severity } = JSON.parse( + message, + ) as RemarkLintMessage - return { - ...lintMessage, - ruleId: `${source}-${ruleId}`, - message: reason, - severity: Math.max(eslintSeverity, severity) as Linter.Severity, - } - }) + return { + ...lintMessage, + ruleId: `${source}-${ruleId}`, + message: reason, + severity: Math.max(eslintSeverity, severity) as Linter.Severity, + } + }) }, } From 65613238fae75fa44bc88287a4c4d5a2ef6f7231 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 7 May 2022 15:53:10 +0200 Subject: [PATCH 3/3] Update packages/eslint-plugin-mdx/src/processors/remark.ts Co-authored-by: JounQin --- packages/eslint-plugin-mdx/src/processors/remark.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin-mdx/src/processors/remark.ts b/packages/eslint-plugin-mdx/src/processors/remark.ts index e7ecf06b..a3fea98d 100644 --- a/packages/eslint-plugin-mdx/src/processors/remark.ts +++ b/packages/eslint-plugin-mdx/src/processors/remark.ts @@ -31,7 +31,7 @@ export const remark: Linter.Processor = { ...mdxMessages, ...processors.markdown.postprocess(markdownMessages, filename), ] - .sort((a, b) => a.line - b.line) + .sort((a, b) => a.line - b.line || a.column - b.column) .map(lintMessage => { const { message,