@double-great/remark-lint-alt-text
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -15,8 +15,8 @@ import { lintRule } from "unified-lint-rule"; | ||
hasAltText = true; | ||
if (!alt && !imageIsLink) | ||
return; | ||
if (!alt && | ||
imageIsLink && | ||
options && | ||
options["image-is-link"] !== false) { | ||
if (!alt && !imageIsLink) { | ||
const suggestion = altText(undefined, options); | ||
if (suggestion) | ||
file.message(suggestion, node); | ||
} | ||
if (!alt && imageIsLink && options["image-is-link"] !== false) { | ||
file.message(imageLink.check(), node); | ||
@@ -32,21 +32,16 @@ } | ||
visitParents(tree, "image", aggregate); | ||
Object.keys(textToNodes).map((alt) => { | ||
for (const alt of Object.keys(textToNodes)) { | ||
const nodes = textToNodes[alt]; | ||
if (!nodes) | ||
return; | ||
nodes.forEach((node) => { | ||
if (hasAltText) { | ||
const suggestion = altText(node.alt, options); | ||
if (suggestion) | ||
file.message(suggestion, node); | ||
} | ||
if (imageIsLink && | ||
hasAltText && | ||
options && | ||
options["image-is-link"] !== false) { | ||
for (const node of nodes) { | ||
const suggestion = altText(node.alt, options); | ||
if (suggestion) | ||
file.message(suggestion, node); | ||
if (imageIsLink && hasAltText && options["image-is-link"] !== false) { | ||
file.message(imageLink.check(), node); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
}); | ||
export default checkAltText; |
{ | ||
"name": "@double-great/remark-lint-alt-text", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "A remark-lint plugin that finds unhelpful or missing image alt text", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
"prepare": "husky install", | ||
"prepublish": "tsc" | ||
"prepublishOnly": "tsc" | ||
}, | ||
@@ -17,0 +17,0 @@ "author": "@double-great", |
@@ -22,1 +22,11 @@ # remark-lint-alt-text ![Build Status](https://github.com/double-great/remark-lint-alt-text/workflows/Test/badge.svg) | ||
``` | ||
You can also customize suggestions: | ||
```json | ||
"remarkConfig": { | ||
"plugins": [ | ||
["@double-great/remark-lint-alt-text", [1, { "empty-alt-text": false }]], | ||
] | ||
}, | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5628
32
49