- Use soft-tabs with a two space indent. Spaces are the only way to guarantee code renders the same in any person’s environment.
- We accept
snake_casein object properties, such as
ajaxResponse.page_title, however camelCase or UPPER_CASE should be used everywhere else.
Linting and formatting code¶
Wagtail uses the ESLint linter to help check your code meets the
styleguide. You’ll need node.js and npm on your development machine.
Ensure project dependencies are installed by running
npm install --no-save
$ npm run lint:js
This will lint all the JS in the wagtail project, excluding vendor files and compiled libraries.
$ 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.