diff --git a/package.json b/package.json index e9e28bde..1d2cd226 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test-extra": "nodeunit test/markdownlint-test-extra.js", "debug": "node debug node_modules/nodeunit/bin/nodeunit", "lint": "eslint lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0\" demo && eslint --rule \"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0\" example", - "ci": "npm run test && npm run lint && npm run test-cover && npm run test-declaration", + "ci": "npm run test-cover && npm run lint && npm run test-declaration", "build-config-schema": "node schema/build-config-schema.js", "build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration", "build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && uglifyjs markdownlint-browser.js --compress --mangle --comments --output markdownlint-browser.min.js", diff --git a/test/markdownlint-test-extra.js b/test/markdownlint-test-extra.js index de2d1797..91d3f58e 100644 --- a/test/markdownlint-test-extra.js +++ b/test/markdownlint-test-extra.js @@ -6,52 +6,39 @@ const fs = require("fs"); const path = require("path"); const glob = require("glob"); const markdownlint = require("../lib/markdownlint"); -const { newLineRe, utf8Encoding } = require("../helpers"); +const { utf8Encoding } = require("../helpers"); -module.exports.typeTestFiles = function typeTestFiles(test) { - // Simulates typing each test file to validate handling of partial input - function validate(file, content) { - const results = markdownlint.sync({ - "strings": { - "content": content - }, +// Simulates typing each test file to validate handling of partial input +const files = fs.readdirSync("./test"); +files.filter((file) => /\.md$/.test(file)).forEach((file) => { + const strings = {}; + let content = fs.readFileSync(path.join("./test", file), utf8Encoding); + while (content) { + strings[content.length.toString()] = content; + content = content.slice(0, -1); + } + module.exports[`type ${file}`] = (test) => { + markdownlint.sync({ + // @ts-ignore + strings, "resultVersion": 0 }); - const contentLineCount = content.split(newLineRe).length; - Object.keys(results.content).forEach(function forKey(ruleName) { - results.content[ruleName].forEach(function forLine(line) { - test.ok((line >= 1) && (line <= contentLineCount), - "Line number out of range: " + line + - " (" + file + ", " + content.length + ", " + ruleName + ")"); - }); - }); - } - const files = fs.readdirSync("./test"); - files.forEach(function forFile(file) { - if (/\.md$/.test(file)) { - let content = fs.readFileSync( - path.join("./test", file), utf8Encoding); - while (content) { - validate(file, content); - content = content.slice(0, -1); - } - } - }); - test.done(); -}; + test.done(); + }; +}); -module.exports.parseAllFiles = function parseAllFiles(test) { - // Parses all Markdown files in all dependencies +// Parses all Markdown files in all package dependencies +module.exports.parseAllFiles = (test) => { const globOptions = { // "cwd": "/", "realpath": true }; - glob("**/*.{md,markdown}", globOptions, function globCallback(err, matches) { + glob("**/*.{md,markdown}", globOptions, (err, matches) => { test.ifError(err); const markdownlintOptions = { "files": matches }; - markdownlint(markdownlintOptions, function markdownlintCallback(errr) { + markdownlint(markdownlintOptions, (errr) => { test.ifError(errr); test.done(); }); diff --git a/test/markdownlint-test.js b/test/markdownlint-test.js index 484eb5ec..43ae4e7d 100644 --- a/test/markdownlint-test.js +++ b/test/markdownlint-test.js @@ -2823,12 +2823,12 @@ module.exports.someCustomRulesHaveValidUrl = (Object.getPrototypeOf(rule.information) === URL.prototype)); if (rule === customRules.anyBlockquote) { test.equal( - rule.information, + rule.information.href, `${homepage}/blob/master/test/rules/any-blockquote.js` ); } else if (rule === customRules.lettersEX) { test.equal( - rule.information, + rule.information.href, `${homepage}/blob/master/test/rules/letters-E-X.js` ); }