Add MD045/no-alt-text (fixes #75).

This commit is contained in:
Duncan Mackenzie 2017-12-29 17:01:21 -08:00 committed by David Anson
parent ac180ff9b9
commit 4fa837a031
8 changed files with 94 additions and 5 deletions

View file

@ -15,3 +15,11 @@ name wrong twice:
MarkDownLint.
A [normal](link) and an [empty one]() and a [fragment](#one).
An image without alt text ![](image.jpg)
![](image.jpg)
A reference image without alt text ![][reference]
[reference]: image.jpg "title"

View file

@ -45,7 +45,7 @@
"errorRange": [25, 13]
},
{
"lineNumber": 18,
"lineNumber": 25,
"ruleName": "MD043",
"ruleAlias": "required-headers",
"ruleDescription": "Required header structure",
@ -79,5 +79,32 @@
"errorDetail": "Expected: markdownlint; Actual: MarkDownLint",
"errorContext": null,
"errorRange": [1, 12]
},
{
"lineNumber": 19,
"ruleName": "MD045",
"ruleAlias": "no-alt-text",
"ruleDescription": "Images should have ALT Text attribute",
"errorDetail": null,
"errorContext": null,
"errorRange": null
},
{
"lineNumber": 21,
"ruleName": "MD045",
"ruleAlias": "no-alt-text",
"ruleDescription": "Images should have ALT Text attribute",
"errorDetail": null,
"errorContext": null,
"errorRange": null
},
{
"lineNumber": 23,
"ruleName": "MD045",
"ruleAlias": "no-alt-text",
"ruleDescription": "Images should have ALT Text attribute",
"errorDetail": null,
"errorContext": null,
"errorRange": null
}
]

View file

@ -965,7 +965,7 @@ module.exports.missingStringValue = function missingStringValue(test) {
};
module.exports.ruleNamesUpperCase = function ruleNamesUpperCase(test) {
test.expect(40);
test.expect(41);
rules.forEach(function forRule(rule) {
test.equal(rule.name, rule.name.toUpperCase(), "Rule name not upper-case.");
});
@ -973,7 +973,7 @@ module.exports.ruleNamesUpperCase = function ruleNamesUpperCase(test) {
};
module.exports.uniqueAliases = function uniqueAliases(test) {
test.expect(80);
test.expect(82);
var tags = [];
rules.forEach(function forRule(rule) {
Array.prototype.push.apply(tags, rule.tags);
@ -990,7 +990,7 @@ module.exports.uniqueAliases = function uniqueAliases(test) {
};
module.exports.readme = function readme(test) {
test.expect(104);
test.expect(108);
var tagToRules = {};
rules.forEach(function forRule(rule) {
rule.tags.forEach(function forTag(tag) {
@ -1052,7 +1052,7 @@ module.exports.readme = function readme(test) {
};
module.exports.doc = function doc(test) {
test.expect(303);
test.expect(310);
fs.readFile("doc/Rules.md", shared.utf8Encoding,
function readFile(err, contents) {
test.ifError(err);

3
test/no-alt-text.md Normal file
View file

@ -0,0 +1,3 @@
# This is an image link without any alt text
![](image.jpg) {MD045}