diff --git a/markdownlint-cli2.js b/markdownlint-cli2.js index ad9111e..ca08d15 100755 --- a/markdownlint-cli2.js +++ b/markdownlint-cli2.js @@ -56,12 +56,6 @@ const utu = (file, error) => { ); }; -// ... -const wutu = (file, prom) => (value) => { - return Promise.resolve(prom(value)). - catch((error) => utu(file, error)); -}; - // Return a posix path (even on Windows) const posixPath = (p) => p.split(pathDefault.sep).join(pathPosix.sep); @@ -318,8 +312,8 @@ const getAndProcessDirInfo = ( dirToDirInfo[dir] = dirInfo; let file = null; + // eslint-disable-next-line no-return-assign const save = (f) => file = f; - // const acc = (f) => fs.promises.access(file = f); // Load markdownlint-cli2 object(s) const markdownlintCli2Jsonc = @@ -332,18 +326,18 @@ const getAndProcessDirInfo = ( then( () => fs.promises. readFile(markdownlintCli2Jsonc, utf8). - then(getJsoncParse()), //zzz + then(getJsoncParse()), () => fs.promises.access(save(markdownlintCli2Yaml)). then( () => fs.promises. readFile(markdownlintCli2Yaml, utf8). - then(getYamlParse()), //zzz - importOrRequireConfig( + then(getYamlParse()), + () => importOrRequireConfig( fs, dir, save(".markdownlint-cli2.cjs"), noRequire, - importOrRequireConfig( + () => importOrRequireConfig( fs, dir, save(".markdownlint-cli2.mjs"), @@ -356,12 +350,12 @@ const getAndProcessDirInfo = ( then( () => fs.promises. readFile(packageJson, utf8). - then(getJsoncParse()). //zzz + then(getJsoncParse()). then((obj) => obj[packageName]), noop ) - ) - ) + )() + )() ) ). then((options) => { diff --git a/test/markdownlint-cli2-test-cases.js b/test/markdownlint-cli2-test-cases.js index 82721ea..2ccfbe8 100644 --- a/test/markdownlint-cli2-test-cases.js +++ b/test/markdownlint-cli2-test-cases.js @@ -346,21 +346,21 @@ const testCases = ({ "name": "markdownlint-json-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint\.json".*Unable to parse JSONC content/u + "stderrRe": /\.markdownlint\.json'.*Unable to parse JSONC content/u }); testCase({ "name": "markdownlint-yaml-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint\.yaml".*Map keys must be unique/u + "stderrRe": /\.markdownlint\.yaml'.*Map keys must be unique/u }); testCase({ "name": "markdownlint-cjs-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint\.cjs".*Unable to require or import module '/u, + "stderrRe": /Unable to require or import module '.*\.markdownlint\.cjs'/u, "usesRequire": true }); @@ -368,7 +368,7 @@ const testCases = ({ "name": "markdownlint-mjs-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint\.mjs".*Unable to require or import module '/u, + "stderrRe": /Unable to require or import module '.*\.markdownlint\.mjs'/u, "usesRequire": true }); @@ -446,7 +446,7 @@ const testCases = ({ "name": "markdownlint-cli2-jsonc-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint-cli2\.jsonc".*Unable to parse JSONC content/u + "stderrRe": /\.markdownlint-cli2\.jsonc".*Unable to parse JSONC content/u }); testCase({ @@ -469,7 +469,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".*Map keys must be unique/u }); testCase({ @@ -490,7 +490,7 @@ const testCases = ({ "name": "markdownlint-cli2-cjs-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint-cli2\.cjs".*Unable to require or import module '/u, + "stderrRe": /\.markdownlint-cli2\.cjs".*Unable to require or import module '/u, "usesRequire": true }); @@ -498,7 +498,7 @@ const testCases = ({ "name": "markdownlint-cli2-mjs-invalid", "args": [ ".*" ], "exitCode": 2, - "stderrRe": /"\.markdownlint-cli2\.mjs".*Unable to require or import module '/u, + "stderrRe": /\.markdownlint-cli2\.mjs".*Unable to require or import module '/u, "usesRequire": true }); @@ -683,7 +683,7 @@ const testCases = ({ "name": `config-files-${invalidConfigFile}-invalid-arg`, "args": [ "--config", `cfg/${invalidConfigFile}`, "**/*.md" ], "exitCode": 2, - "stderrRe": new RegExp(`${invalidConfigFile.replace(".", "\\.")}".*${stderrRe}`), + "stderrRe": new RegExp(`${invalidConfigFile.replace(".", "\\.")}".*${stderrRe}`, "u"), "cwd": "config-files", usesRequire }); @@ -774,7 +774,7 @@ const testCases = ({ "name": "package-json-invalid", "args": [ "**/*.md" ], "exitCode": 2, - "stderrRe": /"package\.json".*Unable to parse JSONC content/u + "stderrRe": /package\.json".*Unable to parse JSONC content/u }); testCase({