-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert custom markdownlint rules to ESM
- Loading branch information
1 parent
1f2d756
commit fbf8810
Showing
8 changed files
with
38 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
dist | ||
node_modules | ||
markdownlint-rules/emd002.cjs | ||
markdownlint-rules/emd003.cjs |
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
export const names = ['EMD004', 'no-newline-in-links']; | ||
export const description = 'Newlines inside link text'; | ||
export const tags = ['newline', 'links']; | ||
export const parser = 'markdownit'; | ||
|
||
function EMD004(params, onError) { | ||
const tokens = params.parsers.markdownit.tokens.filter((token) => token.type === 'inline'); | ||
|
||
for (const token of tokens) { | ||
const { children } = token; | ||
let { lineNumber } = token; | ||
let inLink = false; | ||
for (const child of children) { | ||
const { type } = child; | ||
if (type === 'link_open') { | ||
inLink = true; | ||
} else if (type === 'link_close') { | ||
inLink = false; | ||
} else if (type === 'softbreak') { | ||
if (inLink) { | ||
onError({ lineNumber }); | ||
break; | ||
} else { | ||
lineNumber++; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export { EMD004 as function }; |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
import * as EMD002 from './emd002.mjs'; | ||
import * as EMD003 from './emd003.mjs'; | ||
import * as EMD004 from './emd004.mjs'; | ||
|
||
export default [EMD002, EMD003, EMD004]; |
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