-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use processor to display remark reports directly
- Loading branch information
Showing
14 changed files
with
138 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export const base = { | ||
import { Linter } from 'eslint' | ||
|
||
export const base: Linter.Config = { | ||
parser: 'eslint-mdx', | ||
plugins: ['mdx'], | ||
processor: 'mdx/remark', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * as configs from './configs' | ||
|
||
export * from './configs/helper' | ||
export * from './processors' | ||
export * from './rules' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { remark } from './remark' | ||
|
||
// related to https://github.com/benmosher/eslint-plugin-import/issues/2002 | ||
export const processors = { remark } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Linter } from 'eslint' | ||
|
||
import { RemarkLintMessage } from '../rules' | ||
|
||
export const remark = { | ||
postprocess(lintMessages: Linter.LintMessage[][]): Linter.LintMessage[] { | ||
const messages: Linter.LintMessage[] = [] | ||
for (const lintMessageList of lintMessages) { | ||
messages.push( | ||
...lintMessageList.map(lintMessage => { | ||
const { | ||
message, | ||
ruleId: eslintRuleId, | ||
severity: eslintSeverity, | ||
} = lintMessage | ||
if (eslintRuleId !== 'mdx/remark') { | ||
return lintMessage | ||
} | ||
|
||
// related to https://github.com/eslint/eslint/issues/14198 | ||
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 messages | ||
}, | ||
supportsAutofix: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# abc | ||
|
||
# abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters