Shareable ESLint config for Wagtail.
The package provides Wagtail's ESLint configuration as an extensible shared config using the ESLint flat config format.
This package uses ESLint v9+ flat config format. Install it with its peer dependencies:
npm install --save-dev @wagtail/eslint-config-wagtail@latestThen, import and use the config in your eslint.config.js file:
import wagtailConfig from '@wagtail/eslint-config-wagtail';
export default [
...wagtailConfig,
// Your custom config here
];This ESLint config includes recommended rules from:
- ESLint rules
- eslint-plugin-import
- eslint-plugin-react
- eslint-plugin-react-hooks
- eslint-plugin-jsx-a11y
- eslint-config-prettier
With some Wagtail-specific customizations:
- 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 asajaxResponse.page_title, however camelCase or UPPER_CASE should be used everywhere else.
- Required Node
- We recommend using nvm
- Clone the project on to your computer
- Run
nvm installto ensure you have the correct Node version - Run
npm installto install project dependencies - Ensure your editor is set up to use editorconfig, Prettier and Eslint
- Run
nvm useto set Node to the correct version - Run tests via
npm run test - Run linting via
npm run lint - Run preflight checks before commiting final code via
npm run preflight - Note: When working with the rule set, only modify the
index.jsfile, not theeslint.config.jsfile as it is for the linting of this project only