-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat(lint): use ESLint for linting snippets #7720
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Note Your Pull Request seems to be updating Translations of the Node.js Website. Whilst we appreciate your intent; Any Translation update should be done through our Crowdin Project. Thank you! |
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.
Pull Request Overview
This PR refactors our code snippets by replacing custom linting logic with MDX’s built‐in lintCodeBlocks option, while also updating variable declarations from var to const/let and reordering some imports.
- Replace custom snippet linting with MDX’s lintCodeBlocks
- Switch from var to const/let in multiple code examples
- Reorder and adjust import statements in several release and documentation pages
Reviewed Changes
Copilot reviewed 46 out of 48 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
apps/site/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md | Convert variable declarations to const and improve logging |
apps/site/pages/en/learn/asynchronous-work/discover-promises-in-nodejs.md | Use const for promise executor variables |
apps/site/pages/en/learn/asynchronous-work/asynchronous-flow-control.md | Remove unnecessary ESLint disable comments; use const in loops |
apps/site/pages/en/blog/release/*.md | Reorder and adjust import statements and update logging output |
apps/site/pages/en/blog/module/service-logging-in-json-with-bunyan.md | Replace var with const; update logging usage/comments |
apps/site/pages/en/blog/feature/streams2.md | Replace var with const; modernize event handler callbacks |
apps/site/pages/en/blog/community/domain-postmortem.md | Replace var with let and update loop declarations; update error handling comments |
apps/site/pages/en/blog/announcements/v20-release-announce.md | Reorder import statements to reflect recommended ordering |
apps/site/next.mdx.plugins.mjs | Remove redundant comments in plugin definitions |
apps/site/eslint.config.js | Add MDX remark processor configuration and mdx.flatCodeBlocks setting |
Files not reviewed (2)
- apps/site/package.json: Language not supported
- apps/site/pages/en/index.mdx: Language not supported
Comments suppressed due to low confidence (1)
apps/site/pages/en/blog/community/domain-postmortem.md:194
- Consider using Buffer.alloc(FILESIZE) instead of Buffer(FILESIZE) for enhanced memory safety.
const buf = Buffer(FILESIZE);
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #7720 +/- ##
=======================================
Coverage 74.84% 74.84%
=======================================
Files 98 98
Lines 7888 7888
Branches 200 200
=======================================
Hits 5904 5904
Misses 1983 1983
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
LGTM
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.
LGTM! Just double check all snippets to verify we didn't lose things.
Note that the snippets on the main page are no longer uniformly 14 lines after this PR. If that's a problem, I can add an additional comment to the 13-lined snippet to make them uniform again. |
Let's open another issue for that, I feel we can change the CSS so the width/height of all code tabs becomes the width/height of the largest one; I recall CSS grid/flexboxes support something like that. Can I create a follow-up issue for this? |
Lighthouse Results
|
Looks like I got some errors to review, will do! |
3db98d7
to
29af9a3
Compare
@nodejs/web-infra This doesn't really concern the other groups, so I doubt they will review. Can we merge without them? |
I've enabled auto-merge. Please merge when ready, with or without additional reviews. |
Bump @nodejs/releasers @nodejs/security-wg |
I'm concerned that a number of release posts have been updated in this PR, which suggests that this is going to be using different linting rules than in nodejs/node (since we lint the changelogs there and the release posts are generated from those). |
Thanks! Ill update the globs to only match learn articles |
b88636b
to
c591cc5
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.
Changes in Security best practices are ok for me 👍
@avivkeller did you address this comment? |
Yes. I changed the glob to skip blog posts. |
Description
This PR replaces our custom snippet linting logic with MDX's
lintCodeBlocks
option.Validation
Linting should pass
Check List
pnpm format
to ensure the code follows the style guide.pnpm test
to check if all tests are passing.pnpm build
to check if the website builds without errors.