-
Notifications
You must be signed in to change notification settings - Fork 16k
Markdownlint: Use test runner for custom rule tests #30592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
--format CLI option released in v0.19.0 and required in custom rule tests
Normal markdownlint workflow now should only apply to lessons/projects
Not all parts of TOP003 are fixable
Original fix tests only assert that running the fix script matches the respective `fixed_*` md file, but do not actually test that the applied fixes are sensible and fully resolve the relevant errors.
Nested/ordered list test md files need splitting because of this (nested can't be fixed but ordered can).
Missing headings not fixable but incorrect heading levels are, so the test md files should be split.
8b9cc87 to
94fc986
Compare
|
just some nit, maybe we can just directly pass the full file path in the module.exports = async (markdownFileFullPath) => {
// don't catch - we want this to throw and halt the tests if the file does not exist
await access(markdownFileFullPath);
try {
await exec(`npm run lint -- "${markdownFileFullPath}"`);
return [];
} catch (error) {
return error.stderr.trim().split("\n");
}
}and then on the test file we use it like this: // before
// const getLintErrors = require("../../test_utils/lint")(__dirname);
// const fixLintErrors = require("../../test_utils/fix")(__dirname);
// after
const getLintErrors = require("../../test_utils/lint");
const fixLintErrors = require("../../test_utils/fix");since I noticed if |
|
@jove0610 With the way you've suggested, you'd have to pass in an absolute path from root for the test The way I've chosen this code to be written means Basically, I don't want all the |
|
Thought I should include #30575 in this PR since it'd probably make reviewing easier |
6881cba to
bd7017a
Compare
bd7017a to
36770e5
Compare

Because
The current way of testing markdownlint custom rules is functional but not the most ideal. Ideal would be automated tests with a runner and against assertions, but until now has been a low priority thing due to potential complexities in testing CLI stuff with third-party libraries.
This is one beefy PR but should be more approachable by reviewing the individual commits, and all tests hopefully passing. The commits are for the most part separate from each other, shouldn't be many commits that change something about a previous commit.
Please do checkout into the PR locally and run
npm run testjust in case I've made errors with the GH workflow.This PR
markdownlint/from standard markdownlint GH workflow (intended for lessons/projects)markdownlint-cli2minimum version to0.20.0due to needing the--formatCLI option for tests (released in0.19.0)Issue
Closes #30590
Closes #30575
Pull Request Requirements
location of change: brief description of changeformat, e.g.Intro to HTML and CSS lesson: Fix link textBecausesection summarizes the reason for this PRThis PRsection has a bullet point list describing the changes in this PRIssuesection