mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-23 17:30:12 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
28
lib/md014.js
Normal file
28
lib/md014.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
var dollarCommandRe = /^(\s*)(\$\s)/;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD014", "commands-show-output" ],
|
||||
"description": "Dollar signs used before commands without showing output",
|
||||
"tags": [ "code" ],
|
||||
"function": function MD014(params, onError) {
|
||||
[ "code_block", "fence" ].forEach(function forType(type) {
|
||||
shared.filterTokens(params, type, function forToken(token) {
|
||||
var allBlank = true;
|
||||
if (token.content && token.content.split(shared.newLineRe)
|
||||
.every(function forLine(line) {
|
||||
return !line || (allBlank = false) || dollarCommandRe.test(line);
|
||||
}) && !allBlank) {
|
||||
shared.addErrorContext(onError, token.lineNumber,
|
||||
token.content.split(shared.newLineRe)[0].trim(), null, null,
|
||||
shared.rangeFromRegExp(token.line, dollarCommandRe));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue