diff --git a/package.json b/package.json index 02515e5c..7374cbad 100644 --- a/package.json +++ b/package.json @@ -69,11 +69,11 @@ ], "dependencies": { "globby": "14.0.1", + "js-yaml": "4.1.0", "jsonc-parser": "3.2.1", "markdownlint": "0.33.0", "markdownlint-cli2-formatter-default": "0.0.4", - "micromatch": "4.0.5", - "yaml": "2.3.4" + "micromatch": "4.0.5" }, "devDependencies": { "@iktakahiro/markdown-it-katex": "4.0.1", diff --git a/parsers/yaml-parse.js b/parsers/yaml-parse.js index a036ca05..22ff335f 100644 --- a/parsers/yaml-parse.js +++ b/parsers/yaml-parse.js @@ -2,13 +2,13 @@ "use strict"; -const yaml = require("yaml"); +const yaml = require("js-yaml"); /** * Parses a YAML string, returning the corresponding object. * @param {string} text String to parse as YAML. * @returns {object} Corresponding object. */ -const yamlParse = (text) => yaml.parse(text); +const yamlParse = (text) => yaml.load(text); module.exports = yamlParse; diff --git a/test/markdownlint-cli2-test-cases.js b/test/markdownlint-cli2-test-cases.js index 3c665f3b..966be160 100644 --- a/test/markdownlint-cli2-test-cases.js +++ b/test/markdownlint-cli2-test-cases.js @@ -353,7 +353,7 @@ const testCases = ({ "name": "markdownlint-yaml-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /'[^']*\.markdownlint\.yaml'.*Map keys must be unique/u + "stderrRe": /'[^']*\.markdownlint\.yaml'.*duplicated mapping key/u }); testCase({ @@ -394,21 +394,22 @@ const testCases = ({ testCase({ "name": "markdownlint-cli2-yaml-mismatch", "args": [ "viewme.md" ], - "exitCode": 1 + "exitCode": 2, + "stderrRe": /'[^']*\.markdownlint-cli2\.yaml'.*missed comma between flow collection entries/u }); testCase({ "name": "markdownlint-json-mismatch-config", "args": [ "--config", "../markdownlint-json-mismatch/.markdownlint.json", "viewme.md" ], "exitCode": 0, - "cwd": "no-config", + "cwd": "no-config" }); testCase({ "name": "markdownlint-yaml-mismatch-config", "args": [ "--config", "../markdownlint-yaml-mismatch/.markdownlint.yaml", "viewme.md" ], "exitCode": 0, - "cwd": "no-config", + "cwd": "no-config" }); testCase({ @@ -416,14 +417,15 @@ const testCases = ({ "args": [ "--config", "../markdownlint-cli2-jsonc-mismatch/.markdownlint-cli2.jsonc", "viewme.md" ], "exitCode": 2, "stderrRe": /'[^']*\.markdownlint-cli2\.jsonc'.*Unable to parse JSONC content/u, - "cwd": "no-config", + "cwd": "no-config" }); testCase({ "name": "markdownlint-cli2-yaml-mismatch-config", "args": [ "--config", "../markdownlint-cli2-yaml-mismatch/.markdownlint-cli2.yaml", "viewme.md" ], - "exitCode": 1, - "cwd": "no-config", + "exitCode": 2, + "stderrRe": /'[^']*\.markdownlint-cli2\.yaml'.*missed comma between flow collection entries/u, + "cwd": "no-config" }); testCase({ @@ -469,7 +471,7 @@ const testCases = ({ "name": "markdownlint-cli2-yaml-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /'[^']*\.markdownlint-cli2\.yaml'.*Map keys must be unique/u + "stderrRe": /'[^']*\.markdownlint-cli2\.yaml'.*duplicated mapping key/u }); testCase({ diff --git a/test/snapshots/markdownlint-cli2-test-exec.js.md b/test/snapshots/markdownlint-cli2-test-exec.js.md index c24fe0f1..d7bc3566 100644 --- a/test/snapshots/markdownlint-cli2-test-exec.js.md +++ b/test/snapshots/markdownlint-cli2-test-exec.js.md @@ -1071,21 +1071,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } @@ -1144,21 +1135,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } diff --git a/test/snapshots/markdownlint-cli2-test-exec.js.snap b/test/snapshots/markdownlint-cli2-test-exec.js.snap index ad3f1d97..23949622 100644 Binary files a/test/snapshots/markdownlint-cli2-test-exec.js.snap and b/test/snapshots/markdownlint-cli2-test-exec.js.snap differ diff --git a/test/snapshots/markdownlint-cli2-test-fs.js.md b/test/snapshots/markdownlint-cli2-test-fs.js.md index ef0733a2..68ded1ce 100644 --- a/test/snapshots/markdownlint-cli2-test-fs.js.md +++ b/test/snapshots/markdownlint-cli2-test-fs.js.md @@ -987,21 +987,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } @@ -1060,21 +1051,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } diff --git a/test/snapshots/markdownlint-cli2-test-fs.js.snap b/test/snapshots/markdownlint-cli2-test-fs.js.snap index 91932d1b..f5351479 100644 Binary files a/test/snapshots/markdownlint-cli2-test-fs.js.snap and b/test/snapshots/markdownlint-cli2-test-fs.js.snap differ diff --git a/test/snapshots/markdownlint-cli2-test-main.js.md b/test/snapshots/markdownlint-cli2-test-main.js.md index 9dd484b5..5ab2ff73 100644 --- a/test/snapshots/markdownlint-cli2-test-main.js.md +++ b/test/snapshots/markdownlint-cli2-test-main.js.md @@ -1071,21 +1071,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } @@ -1144,21 +1135,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - exitCode: 1, + exitCode: 2, formatterCodeQuality: '', formatterJson: '', formatterJunit: '', formatterSarif: '', - stderr: `viewme.md:3:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]␊ - viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]␊ - viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]␊ - viewme.md:12:1 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "## Summary"]␊ - viewme.md:14:14 MD047/single-trailing-newline Files should end with a single newline character␊ - `, stdout: `markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)␊ - Finding: viewme.md␊ - Linting: 1 file(s)␊ - Summary: 5 error(s)␊ `, } diff --git a/test/snapshots/markdownlint-cli2-test-main.js.snap b/test/snapshots/markdownlint-cli2-test-main.js.snap index 8352f63e..fd8077e7 100644 Binary files a/test/snapshots/markdownlint-cli2-test-main.js.snap and b/test/snapshots/markdownlint-cli2-test-main.js.snap differ