Skip to content
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

feat: lint links and definitions #188

Merged
merged 2 commits into from
Jun 30, 2021
Merged

feat: lint links and definitions #188

merged 2 commits into from
Jun 30, 2021

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Jun 27, 2021

Replacement for checkLinks.mjs from the nodejs/node repo. Adds a validation for self-reference links to not contain the name of the file.

Replacement for checkLinks.mjs from the nodejs/node repo.
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the necessary changes land in core

@nschonni
Copy link
Member

nschonni commented Jun 27, 2021

This rule seems like it's less nodejs specific than some of the others, so it might be worth having it as a standalone that is just used here

@aduh95
Copy link
Contributor Author

aduh95 commented Jun 27, 2021

This rule seems like it's less nodejs specific that some of the others, so it might be worth having it as a standalone that is just used here

If someone wants to publish it standalone on npm, nothing's stoping them, but I don't feel like doing it myself (at least, not for the time being).

aduh95 added a commit to aduh95/node that referenced this pull request Jun 27, 2021
PR-URL: nodejs#39170
Refs: nodejs/remark-preset-lint-node#188
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
nodejs-github-bot pushed a commit to nodejs/node that referenced this pull request Jun 29, 2021
Refs: nodejs/remark-preset-lint-node#188

PR-URL: #39165
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Harshitha K P <harshitha014@gmail.com>
@aduh95
Copy link
Contributor Author

aduh95 commented Jun 29, 2021

Tests are now passing, I think this is now ready to land.
I'm not sure what is the semver-ness of this change, as it would be quite breaking for a repo that doesn't currently order md references.

@Trott
Copy link
Member

Trott commented Jun 30, 2021

Tests are now passing, I think this is now ready to land.
I'm not sure what is the semver-ness of this change, as it would be quite breaking for a repo that doesn't currently order md references.

I believe we usually treat new rules as semver-minor and save semver-major for things like dropping support of an older version of Node.js.

@Trott Trott merged commit 641684e into nodejs:main Jun 30, 2021
@aduh95 aduh95 deleted the lint-links branch June 30, 2021 07:31
targos pushed a commit to nodejs/node that referenced this pull request Jul 11, 2021
PR-URL: #39170
Refs: nodejs/remark-preset-lint-node#188
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
targos pushed a commit to nodejs/node that referenced this pull request Jul 11, 2021
Refs: nodejs/remark-preset-lint-node#188

PR-URL: #39165
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Harshitha K P <harshitha014@gmail.com>
@SEWeiTung
Copy link

@Trott & @aduh95:
Sorry to interrupt:but it seems for mul-language translations in md such as nodejs/nodejs.org#3956, there're so many errors when testing... What does this change mainly do and what to do with so many errors for node.org?

@Trott
Copy link
Member

Trott commented Jul 14, 2021

@Trott & @aduh95:
Sorry to interrupt:but it seems for mul-language translations in md such as nodejs/nodejs.org#3956, there're so many errors when testing... What does this change mainly do and what to do with so many errors for node.org?

I wonder if there's a way to disable this check for localized/translated files. It seems like it would create extra surprising work unnecessarily for translators. Or at least maybe as a partial measure, ignore links that start with (or contain) non-ASCII characters? That would at least address the problem for languages where the ordering will surely change (like Arabic). What do you think, @aduh95?

@MaledongGit It does a few things, but the one that is probably causing all the issues for translations is that it checks to make sure that the links listed at the bottom of the .md file are in ASCII order. This doesn't affect rendering and seems sensible for when the link lists get very long. However, obviously the "right" ordering in English is going to be different from the "right" ordering once all the link text is translated to another language. And that adds an unexpected burden to translators. And it's not even clear that they should be re-ordering the links. Maybe the "right" ordering is to keep it the same as in the document from which they are translating so that the link is in the expected place should it ever need to be updated based on an update from the original doc.

If we can't figure out something to make it work for translations, I'd consider removing the ordering part of the rule entirely.

I also wonder if we should add nodejs.org to our CI test for this repo so we catch these things earlier. Translations are likely to run into all sorts of issues that we probably won't see in the main repo.

@aduh95
Copy link
Contributor Author

aduh95 commented Jul 14, 2021

I suppose the solution could be to add a disable comment to the translated files:

<!--lint disable remark-lint:nodejs-links-->

@SEWeiTung
Copy link

SEWeiTung commented Jul 15, 2021

I suppose the solution could be to add a disable comment to the translated files:

<!--lint disable remark-lint:nodejs-links-->

Well, I copied some of your files into my node_module to have a test with....
image

However it doens't work properly :(
image
Notice, this is a test file only, we don't need to check its syntax. But when running "npm run test:lint:md", it still shows me a lot of errors in node.org forked project :(
image
So it is for all the other translated files:
image

And this is my command in node.org:
image

@SEWeiTung
Copy link

SEWeiTung commented Jul 15, 2021

BTW: Is it possible to disable in the ".remarkrc"? I suspect whether it's not a published package, so this cannot be used here...?

@nschonni
Copy link
Member

@MaledongGit we already do https://github.com/nodejs/nodejs.org/blob/master/.remarkrc

I think one thing might be to leave the English "references" at the bottom, as this is accepted [Translated text][english reference]

@nschonni
Copy link
Member

It seems like there is a small case sensitivity issue with the current imlementation though. EX: from nodejs.org

locale\en\blog\wg\diag-wg-update-2017-02.md
       70:1-70:65  warning  Unordered reference ("CLI debugger" should be before "async_hooks")                                     nodejs-links  remark-lint
       73:1-73:63  warning  Unordered reference ("Diagnostics WG" should be before "diag-agenda")                                   nodejs-links  remark-lint
       75:1-75:89  warning  Unordered reference ("Inspector" should be before "Inspector API")                                      nodejs-links  remark-lint
       79:1-79:70  warning  Broken link                                                                                             nodejs-links  remark-lint
       79:1-79:70  warning  Unordered reference ("Node.js Foundation survey" should be before "node-report")                        nodejs-links  remark-lint
       81:1-81:66  warning  Unordered reference ("Open an issue" should be before "nodejs/node")                                    nodejs-links  remark-lint
       83:1-83:61  warning  Unordered reference ("Trace Controller" should be before "stability")                                   nodejs-links  remark-lint

Why should the capitalized "CLI" be before "async"

@Trott
Copy link
Member

Trott commented Jul 15, 2021

Why should the capitalized "CLI" be before "async"

This was for localization, ironically. The idea was that instead of alphabetical order, it should be in code-point order, and capital letters all come before lowercase letters that way. The thinking was that "alphabetical order" might not make any sense and/or be hard to code for in some languages (like Chinese), whereas ordering by code-point value is straightforward.

Of course, what we're discovering now is that maybe the thing to do wasn't to try to accommodate these languages but rather to exempt them from the check altogether.

@Trott
Copy link
Member

Trott commented Jul 15, 2021

I suppose the solution could be to add a disable comment to the translated files:

<!--lint disable remark-lint:nodejs-links-->

Well, I copied some of your files into my node_module to have a test with....

The following syntax is working for me:

<!--lint disable nodejs-links remark-lint-->

SEWeiTung added a commit to nodejs/nodejs.org that referenced this pull request Jul 16, 2021
According to #3956, it seems we're ordering the links' titles with ASCII orders, however NOT all the docs (such as translations) and test\scripts\*.md, we DON'T need to cope
with this rule, so we should disable it manually as a special case.

Ref:
1. nodejs/remark-preset-lint-node#188.
2. nodejs/node#39170.
targos pushed a commit to nodejs/node that referenced this pull request Sep 4, 2021
Refs: nodejs/remark-preset-lint-node#188

PR-URL: #39165
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Harshitha K P <harshitha014@gmail.com>
targos pushed a commit to nodejs/node that referenced this pull request Sep 4, 2021
PR-URL: #39170
Refs: nodejs/remark-preset-lint-node#188
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants