JavaScript best practices documentation updated

Hi devs,

I’ve updated the JavaScript best practices documentation (see changes) because it was outdated. Let me know if something is not clear or if you don’t agree with the items I listed. Please suggest any items I may have missed.

Thanks,
Marius

Thanks Marius, this looks good, thanks for updating it!

Maybe we could extract the JS code style best practices from https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HJavaScriptBestPractices and put them under https://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/ WDYT?

Note: I’ve linked to https://dev.xwiki.org/xwiki/bin/view/Community/Testing/#HJavaScriptUnitTesting for the part about testing.

About:

The JavaScript code should pass the following rules to ensure good quality and common code style

Could we automatically check this as part of the build?

I’ve made some small fixes: https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices?viewer=changes&rev1=176.18&rev2=176.23&

It’s already the case for WebJar modules:

For modules that use frontend-maven-plugin and prefer ESLint you need to configure it as https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-webjar/src/main/config/.eslintrc.js .