-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Add a Markdown linter for all .md files #10787
Comments
One thing to add here, from a discussion Florian and I had about this: PRs that fix these rules probably ought to be one rule at a time. Such PRs are going to be easier to review and it'll be more apparent if a rule can't be satisfied by our content or otherwise breaks our process. |
FYI, can we consider using the linter to catch use of non-US-English spellings. We fixed these everywhere relevant in #373 , but I do catch myself using "real" English from time to time :-) |
@hamishwillee I think markdownlint only checks the source style for Markdown files and doesn't have a rule for spelling. I'd suggest opening an issue to track US spelling enforcement separately from Markdown source style. |
This is the currently passing config {
"default": true,
"MD001": false,
"MD004": false,
"MD007": false,
"MD013": false,
"MD014": false,
"MD023": false,
"MD024": false,
"MD025": {
"front_matter_title": "^\\s*title\\s*[:=]"
},
"MD026": false,
"MD028": false,
"MD029": false,
"MD030": false,
"MD033": {
"allowed_elements": [
"a",
"abbr",
"annotation",
"base",
"br",
"caption",
"cite",
"code",
"col",
"colgroup",
"dd",
"details",
"dfn",
"div",
"dl",
"dt",
"em",
"h4",
"h5",
"img",
"kbd",
"li",
"math",
"menclose",
"mfenced",
"mfrac",
"mfrac",
"mi",
"mmultiscripts",
"mn",
"mo",
"mover",
"mphantom",
"mprescripts",
"mroot",
"mrow",
"ms",
"mspace",
"mspace",
"msqrt",
"mstyle",
"msub",
"msubsup",
"msup",
"mtable",
"mtd",
"mtext",
"mtr",
"munder",
"munderover",
"none",
"ol",
"p",
"pre",
"section",
"semantics",
"span",
"strong",
"sub",
"summary",
"sup",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"tr",
"ul",
"var"
]
},
"MD034": false,
"MD036": false,
"MD037": false,
"MD040": false,
"MD042": false,
"MD045": false,
"MD046": {
"style": "fenced"
}
} Does it make sense to add it now without integrating the full CI. That way it will work for those editing in IDEs with the markdownlint plugin? |
For spelling I usually use https://github.com/streetsidesoftware/cspell. My local dictionary is pretty big right now though |
There are 2 new rules around strong (MD050) and emphasis (MD049) markers. Does it make sense to keep the default of "consistent" or actually choose a style? I took a look at the rules
MD050:
|
Updated config {
"default": true,
"MD001": false,
"MD004": {
"style": "dash"
},
"MD007": {
"indent": 2
},
"MD013": false,
"MD014": false,
"MD023": false,
"MD024": false,
"MD025": {
"front_matter_title": "^\\s*title\\s*[:=]"
},
"MD026": false,
"MD028": false,
"MD033": {
"allowed_elements": [
"a",
"abbr",
"annotation",
"base",
"br",
"caption",
"cite",
"code",
"col",
"colgroup",
"dd",
"details",
"dfn",
"div",
"dl",
"dt",
"em",
"h4",
"h5",
"img",
"kbd",
"li",
"math",
"menclose",
"mfenced",
"mfrac",
"mfrac",
"mi",
"mmultiscripts",
"mn",
"mo",
"mover",
"mphantom",
"mprescripts",
"mroot",
"mrow",
"ms",
"mspace",
"mspace",
"msqrt",
"mstyle",
"msub",
"msubsup",
"msup",
"mtable",
"mtd",
"mtext",
"mtr",
"munder",
"munderover",
"none",
"ol",
"p",
"pre",
"section",
"semantics",
"span",
"strong",
"sub",
"summary",
"sup",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"tr",
"ul",
"var"
]
},
"MD034": false,
"MD036": false,
"MD040": false,
"MD042": false,
"MD045": false,
"MD046": {
"style": "fenced"
},
"MD049": false,
"MD050": false
} MD037 seems unfixable for the same reason as the new rules. Underscores in the macros trip up the parsing, and that isn't something that upstream would address since it's outside of the CommonMark spec. |
FWIW No strong opinion, but if we do fix on a style I prefer using |
I left those ones off for now and submitted a PR to at least get the current config in the root, without wiring it to the CI. Figure you folks may want to somehow integrate it into yari so you get some sort of integration with the "flaws" |
#12316 is ready now for the next incremental step of having Markdownlint running a fixed version, with a GitHub Action problem matcher to highlight issues. It still only lints the root docs, and not the files content |
Hey @Elchi3, @hamishwillee, and @nschonni! There is this action used on FYI, this is also being added to the |
The same job is in this repo https://github.com/mdn/content/blob/main/.github/workflows/markdown-lint.yml but both are "wrong" in that the globs only look at the root files. #12316 is the PR to expand the glob so it hits the subfolders as well |
I'm not really sure what I'm being asked here. Isn't this being run on a daily basis somehow already? @nschonni let me know if you need anything from me. |
How many files would be changed if we ran this today? I would like to have a daily script, but I think we should be conservative with the number of rules, and when we want to add a rule, we, first, clean MDN for it and then add it. I want to be sure we don't have 50+ pages in such PR when we start. |
I didn't get any hits running it now as it's been cleaned regularly, even though the CI job doesn't test much of the files right now
That is what #16036 is supposed to do, but has like-wise stalled
I did that over a year ago when the first attempt to expand out the CI job stalled out. I've stopped trying to keep #12316 in sync as it has also stalled |
So this is what I believe we should do:
I think 1. is mostly done and we should start with 2. for some time to see how it goes: The action @schalkneethling linked above would perform 2. (I have not looked at the linter config file, though). If I understand well this very PR is for 3. and #16036 is for 2, too. Overall let's be conservative with the rules we check for or enforce, it will be easy to add more later, in separate PRs: no need to argue forever before landing the action/linting to have the perfect set of rules. Let's go for minimum sets and extend them afterward. I would add that @OnkarRuikar is manually running such a linter daily for a week, leading to fixing 5-10 pages per day, mostly for empty spaces, which is easy and quick to review. @wbamberg wdyt? |
The only thing I'd add to ^^^ is perhaps (if possible) we auto-limit the max size of a PR that the linter will throw out. We certainly shouldn't be stalled - either we move on or we cease. |
The issues which the linter can't fix(e.g. broken header hierarchy) needs to be done manually. So, whichever mechanism we use needs to report such issues as a comment or logs somewhere. @schalkneethling if we decide to enforce 64/80 line length for the the PR, there will be a huge number of files flagged by the linter. And the linter won't fix them. FYI I use the following command:
It uses the config file, available at the root of the repo. |
We do not want to enforce a line length on markdown. I abhor them. |
Yes, we had this conversation already and the consensus was pretty clear! #6936. |
Yes, so it is clear we do not want line wrapping and we would prefer a custom Prettier config that sets @wbamberg What would be the action items to get us to a place where we can close this issue? (BTW, not meant as a push to make a decision, more a way for me to understand what still needs doing.) Thanks! |
It would be good to get a review on #16036. The listing of files across actions runs wasn't possible (for me), but it will indicate to maintainers to look at any failed run for the unfixable things on a daily run |
Converting to a discussion 👍 |
In addition to Prettier (see #10402) it would be great to enable a linter that checks if the markdown makes sense.
There already is a markdown linter in CI, but it is currently enabled for meta docs only. #7146 is a stalled PR that tried to enable it for all .md files.
Not all files currently comply with all md-lint rules. The following configuration would currently pass CI, but we should enable many of these rules (and potentially others not listed below).
To test, run
npx markdownlint-cli . -i node_modules -i LICENSE.md
and add.markdownlint.json
to the content folder. Remove some of the lines below to see how they would fail.Tasks (roughly):
yarn content mdlint
command?)--fix
option easily (and document it, too)The text was updated successfully, but these errors were encountered: