Recently we've been having quite a few discussions on multiple PRs regarding case style (camelCase, snake_case or kebab-case) used in code, for example:
To avoid wasting time on discussing and fixing these kind of issues, I suggest updating dev docs with whatever convention we choose for PS code base.
@matks wdyt?
Yes, it's a good thing to discuss and decide it now
ping @PierreRambaud
Not sure if its the right place, but we could also decide yaml files ident.
OK, here's my suggestions:
YAML files indent: 2 spaces
JSON payloads to API and JSON responses: snake_case
HTML class and ids: kebab-case
No logic behind that, it just seems to be the most popular standards to me
ping @PrestaShop/prestashop-core-developers
HTML class and ids: kebab-case
By default, Symfony Form component renders form elements with snake_case ids.
ping @jolelievre @PierreRambaud
OK, here's my suggestions:
YAML files indent: 2 spaces
JSON payloads to API and JSON responses: snake_case
HTML class and ids: kebab-caseNo logic behind that, it just seems to be the most popular standards to me
Same as @matks, this is the most popular.
Plus, 2 spaces for HTML, JS & CSS (as airbnb guide style, one of the most used in VueJs community)
For XML files, indent ?
Actually, it is tabs (Example).
About the JSON API snake_case.
Currently we mostly use it for private api requests. For this reason I suggest using camelCase.
$this->json. We wouldn't need to have custom serializer configuration so it would save couple code lines in each response.@zuk3975 FYI, Symfony is also able to return snake case for response with $this->json it's configurable. But we can get inspired from what google do and take camelcase as you suggest: https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
OK, here's my suggestions:
YAML files indent: 2 spaces
JSON payloads to API and JSON responses: snake_case
HTML class and ids: kebab-caseNo logic behind that, it just seems to be the most popular standards to me
According to this, I've been following YML 2 spaces for a while, but recently it was updated to 4 here https://github.com/PrestaShop/PrestaShop/pull/20324, so I guess thats what we follow now :smile:
ping @NeOMakinG if you have any idea :)
HTML ids and classes => kebab-case
JS vars => camelCase
It seems to be the most used, bootstrap use kebab-case everywhere, Vue seems to use camelCase everywhere !
Hope @PrestaShop/prestashop-maintainers agree
@NeOMakinG This is documented ?
I think the only thing documented is that we follow bootstrap best practice for html/css