json-schema-spell-checker
Version:
Check the spelling of your JSON Schema (including OpenAPI!) documents
22 lines (19 loc) • 597 B
JavaScript
import strip from "remark-plain-text";
import { remark } from "remark";
import mdSpellcheck from "markdown-spellcheck";
const spellcheck = mdSpellcheck.default;
const check = async (item, options) => {
return new Promise((resolve, reject) => {
remark()
.use(strip)
.process(item.value, (error, result) => {
if (error) {
reject(error);
}
const plain = result.value || result.toString();
const errors = spellcheck.spell(plain, options);
resolve({ errors, plain: plain.trim(), ...item });
});
});
};
export default check;