-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore(cdk-lint): add linting to README.md files #11708
Conversation
Consistent heading structure in the `README.md` files is necessary in order to ensure consistent rendering in the Python documentation, as the rendering of the TOC tree is dependent on heading levels. The best experience is achieved by having all `README.md` files start with a `H1` heading, and subsequently contain only `H2` and deeper headings. It is also important that no heading level is skipped (i.e: a `H4` "nested" in a `H2`). This adds a `pkglint` rule that parses the `README.md` files using the `commonmark` parser, and ensures the heading structure is consistent per the above rules, and registers fixable offenses otherwise. Each offense is reported (and fixed) independently in an effort to provide "more actionnable" feedback in the context of PR validation, and to avoid risking to modify other parts of the document if we were to simply "re-render" the updated Markdown.
Note: this probably should be merged only after https://github.com/aws/cdk-ops/pull/945 has been merged. |
Features | Stability | ||
-------------------------------------------|-------------------------------------------------------- | ||
CFN Resources | ![Stable](https://img.shields.io/badge/stable-success.svg?style=for-the-badge) | ||
Higher level constructs for HTTP APIs | ![Experimental](https://img.shields.io/badge/experimental-important.svg?style=for-the-badge) | ||
Higher level constructs for Websocket APIs | ![Not Implemented](https://img.shields.io/badge/not--implemented-black.svg?style=for-the-badge) | ||
|
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.
This change is such that the table reads better when looking at it in the source. I find it's a neat improvement.
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.
Love it!
@@ -1580,5 +1594,5 @@ function toRegExp(str: string): RegExp { | |||
} | |||
|
|||
function readBannerFile(file: string): string { | |||
return fs.readFileSync(path.join(__dirname, 'banners', file), { encoding: 'utf-8' }); | |||
return fs.readFileSync(path.join(__dirname, 'banners', file), { encoding: 'utf-8' }).trim(); |
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.
This trim()
ensures we don't insert too much vertical space in the stability banners, as markdownlint
would subsequently consider those are formatting errors.
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.
Consider adding this comment directly into the code.
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.
Minor comments below.
@@ -0,0 +1,30 @@ | |||
{ | |||
"default": false, | |||
"MD001": 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.
can we use the rule name instead of the code?
Tells us which rule this is without having to reference somewhere, at least a first approximation.
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 can yeah. I had initially decided against because rules have multiple names... But I guess you're right this might be better In the long run. If only JSON supported comments... -_-
tools/cdk-build-tools/tsconfig.json
Outdated
@@ -2,19 +2,19 @@ | |||
"compilerOptions": { | |||
"target": "ES2018", | |||
"module": "commonjs", | |||
"lib": ["es2018"], | |||
"lib": ["dom", "es2018"], |
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.
add comment on why dom
is needed.
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.
Oh - good you'd ask... It was needed in one stage of my experiments there but is no longer needed!
tools/cdk-build-tools/tsconfig.json
Outdated
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"resolveJsonModule": true, | ||
"composite": true, | ||
"incremental": true | ||
"incremental": true, | ||
"importHelpers": 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.
add a comment on why this option is needed.
Features | Stability | ||
-------------------------------------------|-------------------------------------------------------- | ||
CFN Resources | ![Stable](https://img.shields.io/badge/stable-success.svg?style=for-the-badge) | ||
Higher level constructs for HTTP APIs | ![Experimental](https://img.shields.io/badge/experimental-important.svg?style=for-the-badge) | ||
Higher level constructs for Websocket APIs | ![Not Implemented](https://img.shields.io/badge/not--implemented-black.svg?style=for-the-badge) | ||
|
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.
Love it!
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Consistent heading structure in the
README.md
files is necessary inorder to ensure consistent rendering in the Python documentation, as the
rendering of the TOC tree is dependent on heading levels. The best
experience is achieved by having all
README.md
files start with aH1
heading, and subsequently contain only
H2
and deeper headings. It isalso important that no heading level is skipped (i.e: a
H4
"nested" ina
H2
).This adds a
cdk-lint
stage that executesmarkdownlint
on theREADME.md
files, with a configuration that is crafted specifically tomaximize compatibility with most Markdown parsers, and to ensure
correct rendering in the Python docs. Many of these offenses can be
automatically fixed by running
cdk-lint --fix
oryarn lint --fix
, howeversome cannot be automatically fixed by the tool and will require human
intervention.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license