Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Feb 2, 2024
1 parent 8bc2ed6 commit 6856fcb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
22 changes: 8 additions & 14 deletions markdownlint-cli2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 =
Expand All @@ -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"),
Expand All @@ -356,12 +350,12 @@ const getAndProcessDirInfo = (
then(
() => fs.promises.
readFile(packageJson, utf8).
then(getJsoncParse()). //zzz
then(getJsoncParse()).
then((obj) => obj[packageName]),
noop
)
)
)
)()
)()
)
).
then((options) => {
Expand Down
20 changes: 10 additions & 10 deletions test/markdownlint-cli2-test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,29 +346,29 @@ 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
});

testCase({
"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
});

Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -490,15 +490,15 @@ 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
});

testCase({
"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
});

Expand Down Expand Up @@ -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
});
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 6856fcb

Please sign in to comment.