From fb5f647368e9841d7c7615929249871e0a66e866 Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 8 Jun 2021 22:20:13 -0700 Subject: [PATCH] Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2. --- .eslintrc.json | 10 ++++++ demo/markdownlint-browser.js | 68 +++++++++++++++++++----------------- lib/markdownlint.d.ts | 4 +-- lib/markdownlint.js | 6 ++-- package.json | 24 ++++++------- test/markdownlint-test.js | 8 +++-- 6 files changed, 67 insertions(+), 53 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6fb0c078..86878e12 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -142,6 +142,7 @@ "unicorn/no-array-push-push": "error", "unicorn/no-array-reduce": "error", "unicorn/no-console-spaces": "error", + "unicorn/no-document-cookie": "error", "unicorn/no-for-loop": "error", "unicorn/no-hex-escape": "error", "unicorn/no-instanceof-array": "error", @@ -153,6 +154,7 @@ "unicorn/no-null": "off", "unicorn/no-object-as-default-parameter": "error", "unicorn/no-process-exit": "error", + "unicorn/no-static-only-class": "error", "unicorn/no-this-assignment": "error", "unicorn/no-unreadable-array-destructuring": "error", "unicorn/no-unsafe-regex": "off", @@ -163,6 +165,7 @@ "unicorn/numeric-separators-style": "error", "unicorn/prefer-add-event-listener": "error", "unicorn/prefer-array-find": "error", + "unicorn/prefer-array-flat": "error", "unicorn/prefer-array-flat-map": "error", "unicorn/prefer-array-index-of": "error", "unicorn/prefer-array-some": "error", @@ -176,9 +179,13 @@ "unicorn/prefer-keyboard-event-key": "error", "unicorn/prefer-math-trunc": "error", "unicorn/prefer-modern-dom-apis": "error", + "unicorn/prefer-module": "off", "unicorn/prefer-negative-index": "error", + "unicorn/prefer-node-protocol": "error", "unicorn/prefer-number-properties": "error", + "unicorn/prefer-object-has-own": "error", "unicorn/prefer-optional-catch-binding": "error", + "unicorn/prefer-prototype-methods": "error", "unicorn/prefer-query-selector": "error", "unicorn/prefer-reflect-apply": "error", "unicorn/prefer-regexp-test": "error", @@ -188,9 +195,12 @@ "unicorn/prefer-string-slice": "off", "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-string-trim-start-end": "error", + "unicorn/prefer-switch": "off", "unicorn/prefer-ternary": "error", "unicorn/prefer-type-error": "error", "unicorn/prevent-abbreviations": "off", + "unicorn/require-array-join-separator": "error", + "unicorn/require-number-to-fixed-digits-argument": "error", "unicorn/string-content": "error", "unicorn/throw-new-error": "error" }, diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 33ea45ed..e4d4b89b 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -1,5 +1,5 @@ /*! markdownlint 0.23.1 https://github.com/DavidAnson/markdownlint @license MIT */ -var markdownlint;markdownlint = +var markdownlint; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ @@ -30,7 +30,7 @@ module.exports = webpackEmptyContext; "use strict"; // @ts-check -var os = __webpack_require__(/*! os */ "?5533"); +var os = __webpack_require__(/*! os */ "?591e"); // Regular expression for matching common newline characters // See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js var newLineRe = /\r\n?|\n/g; @@ -769,16 +769,14 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; -var __spreadArrays = (this && this.__spreadArrays) || function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; +var __spreadArray = (this && this.__spreadArray) || function (to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) + to[j] = from[i]; + return to; }; -var fs = __webpack_require__(/*! fs */ "?65c5"); -var path = __webpack_require__(/*! path */ "?0f27"); -var promisify = __webpack_require__(/*! util */ "?0bed").promisify; +var fs = __webpack_require__(/*! fs */ "?ec0a"); +var path = __webpack_require__(/*! path */ "?b85c"); +var promisify = __webpack_require__(/*! util */ "?96a2").promisify; var markdownIt = __webpack_require__(/*! markdown-it */ "markdown-it"); var rules = __webpack_require__(/*! ./rules */ "../lib/rules.js"); var helpers = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"); @@ -952,7 +950,7 @@ function annotateTokens(tokens, lines) { // Handle missing maps for table head/body if ((token.type === "thead_open") || (token.type === "tbody_open")) { - tableMap = token.map.slice(); + tableMap = __spreadArray([], token.map); } else if ((token.type === "tr_close") && tableMap) { @@ -963,7 +961,7 @@ function annotateTokens(tokens, lines) { tableMap = null; } if (tableMap && !token.map) { - token.map = tableMap.slice(); + token.map = __spreadArray([], tableMap); } // Update token metadata if (token.map) { @@ -1323,7 +1321,7 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul "lineNumber": errorInfo.lineNumber + frontMatterLines.length, "detail": errorInfo.detail || null, "context": errorInfo.context || null, - "range": errorInfo.range ? __spreadArrays(errorInfo.range) : null, + "range": errorInfo.range ? __spreadArray([], errorInfo.range) : null, "fixInfo": fixInfo ? cleanFixInfo : null }); } @@ -1449,7 +1447,7 @@ function lintInput(options, synchronous, callback) { } var files = []; if (Array.isArray(options.files)) { - files = options.files.slice(); + files = __spreadArray([], options.files); } else if (options.files) { files = [String(options.files)]; @@ -4028,7 +4026,7 @@ module.exports = rules; /***/ ((module) => { "use strict"; -module.exports = JSON.parse("{\"name\":\"markdownlint\",\"version\":\"0.23.1\",\"description\":\"A Node.js style checker and lint tool for Markdown/CommonMark files.\",\"main\":\"lib/markdownlint.js\",\"types\":\"lib/markdownlint.d.ts\",\"author\":\"David Anson (https://dlaa.me/)\",\"license\":\"MIT\",\"homepage\":\"https://github.com/DavidAnson/markdownlint\",\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/DavidAnson/markdownlint.git\"},\"bugs\":\"https://github.com/DavidAnson/markdownlint/issues\",\"scripts\":{\"build-config\":\"npm run build-config-schema && npm run build-config-example\",\"build-config-example\":\"node schema/build-config-example.js\",\"build-config-schema\":\"node schema/build-config-schema.js\",\"build-declaration\":\"tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'\",\"build-demo\":\"cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && webpack --no-stats\",\"build-example\":\"npm install --no-save --ignore-scripts grunt grunt-cli gulp through2\",\"ci\":\"npm-run-all --continue-on-error --parallel test-cover lint declaration build-config build-demo && git diff --exit-code\",\"clean-test-repos\":\"rimraf test-repos\",\"clone-test-repos\":\"mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet\",\"clone-test-repos-large\":\"npm run clone-test-repos && cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet\",\"declaration\":\"npm run build-declaration && npm run test-declaration\",\"example\":\"cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint\",\"lint\":\"eslint --max-warnings 0 .\",\"lint-test-repos\":\"ava --timeout=5m test/markdownlint-test-repos.js\",\"test\":\"ava test/markdownlint-test.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js\",\"test-cover\":\"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test\",\"test-declaration\":\"cd example/typescript && tsc && node type-check.js\",\"test-extra\":\"ava --timeout=5m test/markdownlint-test-extra.js\"},\"engines\":{\"node\":\">=10\"},\"dependencies\":{\"markdown-it\":\"12.0.6\"},\"devDependencies\":{\"ava\":\"~3.15.0\",\"c8\":\"~7.5.0\",\"cpy-cli\":\"~3.1.1\",\"eslint\":\"~7.19.0\",\"eslint-plugin-jsdoc\":\"~31.6.0\",\"eslint-plugin-node\":\"~11.1.0\",\"eslint-plugin-unicorn\":\"~27.0.0\",\"globby\":\"~11.0.2\",\"js-yaml\":\"~4.0.0\",\"markdown-it-for-inline\":\"~0.1.1\",\"markdown-it-sub\":\"~1.0.0\",\"markdown-it-sup\":\"~1.0.0\",\"markdown-it-texmath\":\"~0.8.0\",\"markdownlint-rule-helpers\":\"~0.13.0\",\"npm-run-all\":\"~4.1.5\",\"rimraf\":\"~3.0.2\",\"strip-json-comments\":\"~3.1.1\",\"toml\":\"~3.0.0\",\"ts-loader\":\"~8.0.15\",\"tv4\":\"~1.3.0\",\"typescript\":\"~4.1.3\",\"webpack\":\"~5.21.1\",\"webpack-cli\":\"~4.5.0\"},\"keywords\":[\"markdown\",\"lint\",\"md\",\"CommonMark\",\"markdownlint\"]}"); +module.exports = JSON.parse('{"name":"markdownlint","version":"0.23.1","description":"A Node.js style checker and lint tool for Markdown/CommonMark files.","main":"lib/markdownlint.js","types":"lib/markdownlint.d.ts","author":"David Anson (https://dlaa.me/)","license":"MIT","homepage":"https://github.com/DavidAnson/markdownlint","repository":{"type":"git","url":"https://github.com/DavidAnson/markdownlint.git"},"bugs":"https://github.com/DavidAnson/markdownlint/issues","scripts":{"build-config":"npm run build-config-schema && npm run build-config-example","build-config-example":"node schema/build-config-example.js","build-config-schema":"node schema/build-config-schema.js","build-declaration":"tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf \'lib/{c,md,r}*.d.ts\' \'helpers/*.d.ts\'","build-demo":"cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && webpack --no-stats","build-example":"npm install --no-save --ignore-scripts grunt grunt-cli gulp through2","ci":"npm-run-all --continue-on-error --parallel test-cover lint declaration build-config build-demo && git diff --exit-code","clean-test-repos":"rimraf test-repos","clone-test-repos":"mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet","clone-test-repos-large":"npm run clone-test-repos && cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet","declaration":"npm run build-declaration && npm run test-declaration","example":"cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint","lint":"eslint --max-warnings 0 .","lint-test-repos":"ava --timeout=5m test/markdownlint-test-repos.js","test":"ava test/markdownlint-test.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js","test-cover":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test","test-declaration":"cd example/typescript && tsc && node type-check.js","test-extra":"ava --timeout=5m test/markdownlint-test-extra.js"},"engines":{"node":">=10"},"dependencies":{"markdown-it":"12.0.6"},"devDependencies":{"ava":"~3.15.0","c8":"~7.7.2","cpy-cli":"~3.1.1","eslint":"~7.28.0","eslint-plugin-jsdoc":"~35.1.3","eslint-plugin-node":"~11.1.0","eslint-plugin-unicorn":"~33.0.1","globby":"~11.0.3","js-yaml":"~4.1.0","markdown-it-for-inline":"~0.1.1","markdown-it-sub":"~1.0.0","markdown-it-sup":"~1.0.0","markdown-it-texmath":"~0.9.0","markdownlint-rule-helpers":"~0.14.0","npm-run-all":"~4.1.5","rimraf":"~3.0.2","strip-json-comments":"~3.1.1","toml":"~3.0.0","ts-loader":"~9.2.3","tv4":"~1.3.0","typescript":"~4.3.2","webpack":"~5.38.1","webpack-cli":"~4.7.2"},"keywords":["markdown","lint","md","CommonMark","markdownlint"]}'); /***/ }), @@ -4043,17 +4041,7 @@ module.exports = markdownit; /***/ }), -/***/ "?65c5": -/*!********************!*\ - !*** fs (ignored) ***! - \********************/ -/***/ (() => { - -/* (ignored) */ - -/***/ }), - -/***/ "?5533": +/***/ "?591e": /*!********************!*\ !*** os (ignored) ***! \********************/ @@ -4063,7 +4051,17 @@ module.exports = markdownit; /***/ }), -/***/ "?0f27": +/***/ "?ec0a": +/*!********************!*\ + !*** fs (ignored) ***! + \********************/ +/***/ (() => { + +/* (ignored) */ + +/***/ }), + +/***/ "?b85c": /*!**********************!*\ !*** path (ignored) ***! \**********************/ @@ -4073,7 +4071,7 @@ module.exports = markdownit; /***/ }), -/***/ "?0bed": +/***/ "?96a2": /*!**********************!*\ !*** util (ignored) ***! \**********************/ @@ -4091,8 +4089,9 @@ module.exports = markdownit; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ if(__webpack_module_cache__[moduleId]) { -/******/ return __webpack_module_cache__[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { @@ -4115,9 +4114,12 @@ module.exports = markdownit; /******/ })(); /******/ /************************************************************************/ -/******/ // module exports must be returned from runtime so entry inlining is disabled +/******/ /******/ // startup /******/ // Load entry module and return exports -/******/ return __webpack_require__("../lib/markdownlint.js"); +/******/ // This entry module is referenced by other modules so it can't be inlined +/******/ var __webpack_exports__ = __webpack_require__("../lib/markdownlint.js"); +/******/ markdownlint = __webpack_exports__; +/******/ /******/ })() ; \ No newline at end of file diff --git a/lib/markdownlint.d.ts b/lib/markdownlint.d.ts index 7a6199e3..b38c7836 100644 --- a/lib/markdownlint.d.ts +++ b/lib/markdownlint.d.ts @@ -334,12 +334,12 @@ type FixInfo = { * {@link ../schema/markdownlint-config-schema.json}. */ type Configuration = { - [x: string]: any; + [x: string]: RuleConfiguration; }; /** * Rule configuration. */ -type RuleConfiguration = any; +type RuleConfiguration = boolean | any; /** * Parses a configuration string and returns a configuration object. */ diff --git a/lib/markdownlint.js b/lib/markdownlint.js index 165a144b..ee7e8bcc 100644 --- a/lib/markdownlint.js +++ b/lib/markdownlint.js @@ -190,7 +190,7 @@ function annotateTokens(tokens, lines) { (token.type === "thead_open") || (token.type === "tbody_open") ) { - tableMap = token.map.slice(); + tableMap = [ ...token.map ]; } else if ( (token.type === "tr_close") && tableMap @@ -203,7 +203,7 @@ function annotateTokens(tokens, lines) { tableMap = null; } if (tableMap && !token.map) { - token.map = tableMap.slice(); + token.map = [ ...tableMap ]; } // Update token metadata if (token.map) { @@ -736,7 +736,7 @@ function lintInput(options, synchronous, callback) { } let files = []; if (Array.isArray(options.files)) { - files = options.files.slice(); + files = [ ...options.files ]; } else if (options.files) { files = [ String(options.files) ]; } diff --git a/package.json b/package.json index 7b1c33c9..d23ce7b1 100644 --- a/package.json +++ b/package.json @@ -40,28 +40,28 @@ }, "devDependencies": { "ava": "~3.15.0", - "c8": "~7.5.0", + "c8": "~7.7.2", "cpy-cli": "~3.1.1", - "eslint": "~7.19.0", - "eslint-plugin-jsdoc": "~31.6.0", + "eslint": "~7.28.0", + "eslint-plugin-jsdoc": "~35.1.3", "eslint-plugin-node": "~11.1.0", - "eslint-plugin-unicorn": "~27.0.0", - "globby": "~11.0.2", - "js-yaml": "~4.0.0", + "eslint-plugin-unicorn": "~33.0.1", + "globby": "~11.0.3", + "js-yaml": "~4.1.0", "markdown-it-for-inline": "~0.1.1", "markdown-it-sub": "~1.0.0", "markdown-it-sup": "~1.0.0", - "markdown-it-texmath": "~0.8.0", - "markdownlint-rule-helpers": "~0.13.0", + "markdown-it-texmath": "~0.9.0", + "markdownlint-rule-helpers": "~0.14.0", "npm-run-all": "~4.1.5", "rimraf": "~3.0.2", "strip-json-comments": "~3.1.1", "toml": "~3.0.0", - "ts-loader": "~8.0.15", + "ts-loader": "~9.2.3", "tv4": "~1.3.0", - "typescript": "~4.1.3", - "webpack": "~5.21.1", - "webpack-cli": "~4.5.0" + "typescript": "~4.3.2", + "webpack": "~5.38.1", + "webpack-cli": "~4.7.2" }, "keywords": [ "markdown", diff --git a/test/markdownlint-test.js b/test/markdownlint-test.js index 5193a7a3..32b73edc 100644 --- a/test/markdownlint-test.js +++ b/test/markdownlint-test.js @@ -681,7 +681,7 @@ test.cb("filesArrayNotModified", (t) => { "./test/atx_heading_spacing.md", "./test/first_heading_bad_atx.md" ]; - const expectedFiles = files.slice(); + const expectedFiles = [ ...files ]; markdownlint({ "files": files }, function callback(err) { t.falsy(err); t.deepEqual(files, expectedFiles, "Files modified."); @@ -811,12 +811,13 @@ test.cb("readme", (t) => { fs.readFile("README.md", "utf8", function readFile(err, contents) { t.falsy(err); - const rulesLeft = rules.slice(); + const rulesLeft = [ ...rules ]; let seenRelated = false; let seenRules = false; let inRules = false; let seenTags = false; let inTags = false; + // @ts-ignore md.parse(contents, {}).forEach(function forToken(token) { if ( (token.type === "bullet_list_open") && @@ -878,7 +879,7 @@ test.cb("rules", (t) => { fs.readFile("doc/Rules.md", "utf8", (err, contents) => { t.falsy(err); - const rulesLeft = rules.slice(); + const rulesLeft = [ ...rules ]; let inHeading = false; let rule = null; let ruleHasTags = true; @@ -896,6 +897,7 @@ test.cb("rules", (t) => { t.true(!ruleUsesParams, "Missing parameters for rule " + r.names + "."); }; + // @ts-ignore md.parse(contents, {}).forEach(function forToken(token) { if ((token.type === "heading_open") && (token.tag === "h2")) { inHeading = true;