File tree Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Original file line number Diff line number Diff line change 1
1
import markdownIt from "markdown-it" ;
2
- import markdownlint from "markdownlint" ;
2
+ import { lint } from "markdownlint/sync " ;
3
3
import yaml from "js-yaml" ;
4
4
const markdownItFactory = ( ) => markdownIt ( { html : true } ) ;
5
5
6
6
export const validate = ( markdown , config ) => {
7
7
const configObject = yaml . load ( config ) ;
8
8
return (
9
- markdownlint
10
- . sync ( {
11
- strings : {
12
- content : markdown ,
13
- } ,
14
- config : config
15
- ? { default : false , ...configObject }
16
- : {
17
- default : false ,
18
- "no-default-alt-text" : true ,
19
- "no-alt-text" : true ,
20
- "no-empty-alt-text" : true ,
21
- } ,
22
- handleRuleFailures : true ,
23
- markdownItFactory,
24
- customRules : [ "@github/markdownlint-github" ] ,
25
- } )
26
- . content ?. map ( ( error ) => {
27
- return `- ${ error . ruleDescription } at line ${ error . lineNumber } ` ;
28
- } ) ?? [ ]
9
+ lint ( {
10
+ strings : {
11
+ content : markdown ,
12
+ } ,
13
+ config : config
14
+ ? { default : false , ...configObject }
15
+ : {
16
+ default : false ,
17
+ "no-default-alt-text" : true ,
18
+ "no-alt-text" : true ,
19
+ "no-empty-alt-text" : true ,
20
+ } ,
21
+ handleRuleFailures : true ,
22
+ markdownItFactory,
23
+ customRules : [ "@github/markdownlint-github" ] ,
24
+ } ) . content ?. map ( ( error ) => {
25
+ return `- ${ error . ruleDescription } at line ${ error . lineNumber } ` ;
26
+ } ) ?? [ ]
29
27
) . join ( "\n" ) ;
30
28
} ;
You can’t perform that action at this time.
0 commit comments