Code formatter for AEM core component project

111 views
Skip to first unread message

Rajesh Dwivedi

unread,
Jun 11, 2020, 10:49:33 PM6/11/20
to AEM Core Components Developer Community
Hi All,

Just a suggestion from my end.

I noticed, there is editor config available but there is no specific code formatter in the core components code base. I have used prettier for Java and JavaScript formatting. It does a really good job. I liked it over Google code formatter for Java code formatting as I feel it's more readable.. I know this may not be everyone's preference but beautiful looking/formatted code is always easy to read and gives a good impression.

Pros: 
  1. Prettier can format code nicely for both Java and JavaScript.
  2. It can format HTML files and styles as well. 
  3. It's easy to configure.
  4. This is really fast to format the files.
  5. Make code more readable and consistent with similar formatting throughout the code base.
Cons: 
  1. It is a node plugin so needs one time dependency install which everyone may not like it. However, I noticed, there are package.json files under 3 different submodules.

We can tie the code formatting with build process or with git hook so that code is formatted by every commit.

Please review the suggestion and let me know if you guys are in favor of this suggestion. I can add a feature request and add the configuration

Thanks
Rajesh Dwivedi

kyle giovannetti

unread,
Jun 11, 2020, 11:14:10 PM6/11/20
to aem-core-co...@googlegroups.com
Personally, I'd be in favour of just adding a checkstyle config file, and adding a checkstyle report to the PR build. 

Most IDEs can easily handle a standard checkstyle configuration and format to match. 

When I submit PRs now I have to disable my IDEs auto formatting because lacking a proper configuration for this project it wants to just use my defaults, which would change most of it :)

I agree though that I'd like a standard to follow with respect to code style/comments/documentation/etc, and I'd like the tooling to be available to minimize the effort.


Kyle

--
You received this message because you are subscribed to the Google Groups "AEM Core Components Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aem-core-componen...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aem-core-components-dev/0eee22d1-6c7b-4e2f-9654-6deb8ed65e6co%40googlegroups.com.

Rajeev Yadav

unread,
Jun 11, 2020, 11:25:28 PM6/11/20
to AEM Core Components Developer Community
I like the idea of adding formatting support as part build/codebase.

Rajesh Dwivedi

unread,
Jun 12, 2020, 11:12:35 PM6/12/20
to AEM Core Components Developer Community
Thanks Kyle/Rajeev for the response.

I will create a ticket and will add formatter to code base in few days.


Thanks
Rajesh Dwivedi
Reply all
Reply to author
Forward
0 new messages