-
Notifications
You must be signed in to change notification settings - Fork 574
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
Introduce markdown linting #2726
Conversation
|
size-limit report 📦
|
e8edee8
to
f49aeec
Compare
There are 80 violations. I could either try to address in this PR, but if they are too difficult to address in one go, I'll turn off the rule completely with a note that we want to turn on eventually... Here are the issues that need to be resolved:
|
I think we could configure this rule to be |
Can I get a first-pass review from @primer/react-reviewers on these configs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋🏼 @khiga8 Thank you so much for this PR 🙏🏼 I left a couple of comments, let us know what you think!
@@ -45,6 +45,7 @@ | |||
"install:docs": "(cd docs && npm install --legacy-peer-deps)", | |||
"lint": "eslint '**/*.{js,ts,tsx,md,mdx}' --max-warnings=0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a set of rules for the md
and mdx
files already on the eslint config. I am not sure if there would be any conflict between them? Or what do you suggest for us to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh interesting! I don't think eslint
runs the same rulesets as markdownlint. do you know what ESLint rules are running on markdown?
…nly increment by one level at a time
// Rules we want to turn on but currently have too many violations | ||
const rulesToEnforce = { | ||
'fenced-code-language': false, | ||
'no-duplicate-header': false, // Fix https://github.com/primer/doctocat/issues/527, then set this rule to `siblings_only: true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@primer/react-reviewers FYI,no-duplicate-header
should be turned on because doctocat messes up the anchor links when headings have the same text. See linked issue. I keep it off for now because there's too many address.
Ideally, the issue is fixed in doctocat so we don't have to set this rule to be strict.
@@ -38,7 +39,7 @@ On the other hand, if we want consumers to have more control over children, a co | |||
|
|||
With React, `children` is the out-of-the-box way for putting [phrasing content](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#phrasing_content) inside your component. By using `children` instead of our own custom prop, we can make the API “predictable” for its consumers. | |||
|
|||
<img width="373" alt="image" src="https://user-images.githubusercontent.com/1863771/144945223-70c4c800-5827-4985-9f18-0ab416eba058.png"> | |||
<img width="373" alt="image" src="https://user-images.githubusercontent.com/1863771/144945223-70c4c800-5827-4985-9f18-0ab416eba058.png"> <!-- markdownlint-disable-line no-default-alt-text --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@primer/react-reviewers This is a TODO! Feel free to suggest something in this PR to fix this!
@@ -2,7 +2,7 @@ | |||
|
|||
Consider a React component that renders a list of items. Here are two possible APIs that component might expose, both achieving an equivalent result. | |||
|
|||
### A: Contents passed as React children | |||
### A: Contents passed as React children <!-- markdownlint-disable-line heading-increment --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@primer/react-reviewers This is a TODO! I'm not sure what the heading structure should be. Feel free to suggest something in this PR to fix this!
``` | ||
|
||
[Show full code example →](https://github.com/primer/react/pull/2019/files?diff=split&w=0) | ||
```tsx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errr I think prettier ran for these files and updated it, but not sure. @primer/react-reviewers is this expected?
const rulesToNotEnforce = { | ||
'line-length': false, | ||
'blanks-around-headings': false, | ||
'blanks-around-lists': false, | ||
'no-trailing-spaces': false, | ||
'no-multiple-blanks': false, | ||
'no-trailing-punctuation': false, | ||
'single-trailing-newline': false, | ||
'ul-indent': false, | ||
'no-hard-tabs': false, | ||
'first-line-heading': false, | ||
'no-space-in-emphasis': false, | ||
'blanks-around-fences': false, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are stylistic rules that I don't think Primer team cares to enforce for now, but not sure. Feel free to configure this to your preference!!!
@primer/react-reviewers This is ready for another review. Please review thoroughly as this will impact developer workflow! For the existing violations listed in #2726 (comment), I addressed some of them. You can go through them by commit. There were two that I disabled inline, which are open to your fix suggestions: Two of the rules, there were too many of to address immediately so I turned them off completely for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! Left a comment for the CI job, let me know what you think about it 👀 Would be great to include, if possible.
.github/workflows/ci.yml
Outdated
- name: Lint | ||
run: npm run markdownlint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add this to the lint
job as a step after npm run lint
? Would be great to keep it in the same job for linting, something like:
- name: Lint JavaScript
run: npm run lint
- name: Lint markdown
run: npm run markdownlint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that! I got feedback in the primer/design
repo that it's more clear when there are separate linting jobs for error clarity, but we can keep it together if you prefer. I don't have a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
note to self to update the |
Hi @joshblack! I addressed your review suggestions in d1f87d2. I additionally updated the |
Thanks for doing this @khiga8! 🙌 |
Fixes: https://github.com/github/accessibility/issues/2550
This PR:
devcontainer
so that issues are flagged in the editor.eslint
andmarkdownlint
.