Closed llxia closed 2 years ago
I'd love to investigate on the tool
Here are some potential formatting tools for the project I have found.
RubyMine
Language Specific Java:
Python: Black
Thanks @yinggzz ! Based on our discussion today, you and @llxia have a few additional activities on this one, focussing on Prettier and CodeBeautify. Think about what we would expect of contributors to this repository. Would we 'enforce' formatting with a PR check? Are their github actions that would allow for this as part of a workflow? If we do not enforce it, is this mainly about creating a template and document guidelines?
The goal is this task is to find a formatting tool that can format automatically for the users. Ideally, the PR should be formatted well before users submit the PRs. I would expect that there is no or minimal work for both users and reviewers for formatting.
CodeBeautify is not what we are looking for. It is a third-party online tool that users have to manually format their files on its site.
Using Prettier as an example, we can check in our formatter file in the repo. And users can just install Prettier for their IDE (i.e., Formatter for Visual Studio Code https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). Once it is installed and configured (one-time setup), the files will be auto-formatted at saving. Or a husky hook can be added to prettify on commit https://prettier.io/docs/en/precommit.html
PR checks may be needed for users that do not use common IDE with formatter tool support. This can be discussed at a later stage. But for this issue, I would like to focus on:
Thanks @yinggzz for your work so far. I hope the above description clarifies the goal and scope of this task. If you have any questions, please let us know.
Hi @llxia , thank you for your instruction! After a lot of research, I couldn’t really find other tools that are similar to Prettier and support integration with different IDEs and languages.
Please see below for my research on Prettier, it can be used as a pre-commit tool to format file before committing.
I was wondering if you can elaborate what to include in the “Format file” besides links for downloading it for different code editors.
Prettier Pros:
Cons:
Pull-requests, pre-commit hook
Example use case for a project: Run prettier on a large code base at once https://flexport.engineering/upgrading-prettier-on-a-large-codebase-28d56c4de49e
Goal: run prettier so that changes it makes are attributed correctly in git, no merge conflict in open pull requests, repeatable.
General work flow to automate code formatting in pull requests: https://peterevans.dev/posts/github-actions-how-to-automate-code-formatting-in-pull-requests/
Add prettier in TRSS https://github.com/adoptium/aqa-test-tools/pull/611
Code formatter prettier is added in TRSS. I will close this issue.
It is very important to have a good coding standard. It helps to keep the code simple and clean. A nice formatted code is easier for people to understand, review, compare, maintain and update. We should investigate a good formatting tool for the project. Below are some of the requirements:
Possible tool: https://prettier.io/
Addtional description (see https://github.com/adoptium/aqa-test-tools/issues/591#issuecomment-1023239334)