HDDS-9570. [Website v2] Integrate eslint and run it in github actions#307
HDDS-9570. [Website v2] Integrate eslint and run it in github actions#307yuriipalam wants to merge 6 commits intoapache:HDDS-9225-website-v2from
Conversation
errose28
left a comment
There was a problem hiding this comment.
Thanks for working on this @yuriipalam. Can we do these changes incrementally? Between prettier, eslint, and markdownlint, it's difficult to figure which one is responsible for which changes. Let's make this three PRs:
- First PR to add
lintandlint:fixcommands for existing linting checks from markdownlint and yamllint.- This shouldn't require reformatting any website content since these checks are being run already.
- Second PR to add eslint and its docusaurus plugin to this command.
lint:fixwill need to be run to commit any violations in existing javascript.
- Third PR to add prettier
- I'm currently not sure that prettier is providing us much benefit on top of the other two changes so it would be good to see the affects of this isolated to their own PR.
|
Thanks for the review @errose28 Sure, we can do that. In my opinion, Prettier does provide us much benefit, especially when it comes to markdown formatting. We have markdownlint, but it doesn't format the markdown files, rather analyzes for errors/structure issues. With prettier we can actually standardize the formatting across all markdown files in the project. For example, tables formatting: Before After And there are much more examples which can be seen in the updated markdown files. |
|
Sounds good, thanks for starting to split this into smaller PRs. I'm going to close this for now since we are continuing reviews in #318, but the changes will still be here for reference. |
What changes were proposed in this pull request?
Integrate ESLint and Prettier into the project, updated the CI respectively.
ESLint is a static code analyzer, so now we have analyzer during the development.
Prettier is a formatting tool, so the code style is consistent across the files.
Both tools were integrated, as well as relevant extensions to them, e.g., Docusaurus ESLint plugin
They were also added to the CI pipeline, so they run in github actions.
Fixed all the issues that the code analyzers found.
Introduced new commands:
pnpm run lintruns checks only (no files are modified).pnpm run lint:fixapplies auto-fixes from ESLint, markdownlint, and Prettier.In the project we also have markdownlint, but it has a conflict rule with Prettier. Prettier uses
_underscores_for emphasis, while markdownlint is configured to require*asterisks*. To keep markdownlint as the source of truth for Markdown emphasis, we run markdownlint after Prettier.Strongly recommend you to check
eslint.config.mjs, since it sets up the code rules for the project. I also added a custom rule that enforces the license header.I also updated
CONTRIBUTE.MDaccordingly, the "Quick Start" and a new "Linting and Formatting" sections.What is the link to the Apache Jira?
HDDS-9570
How was this patch tested?
Check off which of the following tests were done on this change. If additional testing was done, please elaborate here as well.