Use Prettier for all formatting considerations.
snake_casein object properties, such as
ajaxResponse.page_title, however camelCase or UPPER_CASE should be used everywhere else.
Linting and formatting code¶
$ npm run lint:js
This will lint all the JS in the wagtail project, excluding vendor files and compiled libraries.
For Prettier auto-formatting, run:
$ npm run format
If you want to autofix linting errors:
$ npm run lint:js -- --fix
This will perform safe edits to conform your JS code to the styleguide. It won’t touch the line-length, or convert quotemarks from double to single.
Run the linter after you’ve formatted the code to see what manual fixes you need to make to the codebase.
Changing the linter configuration¶
The configuration for the linting rules is managed in an external repository so that it can be easily shared across other Wagtail projects or plugins. This configuration can be found at eslint-config-wagtail.