-
-
Notifications
You must be signed in to change notification settings - Fork 216
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 linting to CI for martin book #1030
Conversation
How about we ignore the Line Length rule? @nyurik |
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.
looks good, thanks! Could you rename the config file though - it should not have a .
in front of the name. The dot is only used when you want to hide the file, e.g. if its in the root of the repo. Thx!
Some rules do we need to ignore / finetune?
I prefer to ignore the |
I don't think either of these two rules are that important to us. Simpler is better. The more significant aspect would be to make sure all URLs are working. The rest is just "nice to have". Thx! |
0140812
to
58b335a
Compare
419b770
to
de6ebc2
Compare
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.
looks great, thanks! I left a few minor comments. Also, please modify justfile:
- modify
clippy
target to run URL link checker and format checker. Might be OK to just verify markdown formatting. - add
fmt-docs
(or maybe modifyfmt
?) to reformat all *.md files
P.S. If the license link |
I just tried it with |
I'm confused. Both work on my pc. markdown-link-check ./README.md -c /home/zhangyijun/repos/martin/.github/files/markdown.links.config.json
..
[✓] http://www.apache.org/licenses/LICENSE-2.0
[✓] LICENSE-MIT
[✓] http://opensource.org/licenses/MIT
... curl -vL http://opensource.org/licenses/MIT
...
<div id="LicenseText">
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</div> |
Hm, I ran it again -- you can see that it returns 403 (the
|
P.S. I suspect this is due to some CloudFlare anti-DDOS process that uses javascript to redirect to the right page |
de6ebc2
to
911aa38
Compare
403 still after many hours. Ignored 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.
I absolutely love the clean markdown, thanks!
I don't think NPM requirement for development is worth it just for markdown, especially considering how flaky NPM can be. Instead, lets use docker
containers for this. Docker with docker-compose is already a dependency. We can do it two different ways:
- from justfile, use
docker run --rm -it ...
command for formatting and linting - from justfile, use
docker-compose run
and add two new sections to thedocker-compose
.
I think the first path might be easier.
See https://github.com/DavidAnson/markdownlint-cli2#container-image for info on at least one of the tools.
@@ -0,0 +1,18 @@ | |||
{ |
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.
for consistency, lets rename this file as .github/files/markdownlint-cli2.jsonc
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.
I suspect we couldn't do this:
@sharkAndshark ➜ /workspaces/martin (doc_style_check) $ markdownlint-cli2 --config ./.github/files/markdownlint-cli2.jsonc --fix
markdownlint-cli2 v0.11.0 (markdownlint v0.32.1)
Error: Configuration file "/workspaces/martin/.github/files/markdownlint-cli2.jsonc" is unrecognized; its name should be (or end with) one of the supported types (e.g., ".markdownlint.json" or "example.markdownlint-cli2.jsonc").
at readOptionsOrConfig (/usr/local/share/nvm/versions/node/v20.8.1/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js:191:11)
at main (/usr/local/share/nvm/versions/node/v20.8.1/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js:935:13)
at /usr/local/share/nvm/versions/node/v20.8.1/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js:1045:32
at run (/usr/local/share/nvm/versions/node/v20.8.1/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js:1050:5)
at Object.<anonymous> (/usr/local/share/nvm/versions/node/v20.8.1/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js:1062:3)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
// Read an options or config file in any format and return the object
const readOptionsOrConfig = async (configPath, fs, noRequire) => {
const basename = pathPosix.basename(configPath);
const dirname = pathPosix.dirname(configPath);
let options = null;
let config = null;
if (basename.endsWith(".markdownlint-cli2.jsonc")) {
const jsoncParse = await getJsoncParse();
options = jsoncParse(await fs.promises.readFile(configPath, utf8));
} else if (basename.endsWith(".markdownlint-cli2.yaml")) {
options = yamlParse(await fs.promises.readFile(configPath, utf8));
} else if (
basename.endsWith(".markdownlint-cli2.cjs") ||
basename.endsWith(".markdownlint-cli2.mjs")
) {
options = await (
importOrRequireConfig(fs, dirname, basename, noRequire, noop)()
);
} else if (
basename.endsWith(".markdownlint.jsonc") ||
basename.endsWith(".markdownlint.json") ||
basename.endsWith(".markdownlint.yaml") ||
basename.endsWith(".markdownlint.yml")
) {
const jsoncParse = await getJsoncParse();
config =
await markdownlintReadConfig(configPath, [ jsoncParse, yamlParse ], fs);
} else if (
basename.endsWith(".markdownlint.cjs") ||
basename.endsWith(".markdownlint.mjs")
) {
config = await (
importOrRequireConfig(fs, dirname, basename, noRequire, noop)()
);
} else {
throw new Error(
`Configuration file "${configPath}" is unrecognized; ` +
"its name should be (or end with) one of the supported types " +
"(e.g., \".markdownlint.json\" or \"example.markdownlint-cli2.jsonc\")."
);
}
if (options) {
if (options.config) {
options.config = await getExtendedConfig(options.config, configPath, fs);
}
return options;
}
config = await getExtendedConfig(config, configPath, fs);
return { config };
};
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.
awesome job, thanks! I made a minor adjustment in the justfile to make lints run faster with parallel execution and a single docker run command (they are slow to start up)
Try to fix #979 with markdownlint-cli2 and markdown-link-check
Link check
CHANGELOG.md
localhost
and127.0.0.1
http://opensource.org
Lintting
CHANGELOG.md
?