The shareable EcmaScript standard for developing UF Health WordPress projects.
- Based on
@ufhealth/eslint-config-standard
- Allows common globals exposed by WordPress in front-end views and in the editor
- Includes WordPress-flavored React/JSX support using the
wp.element
pragma.
yarn install @ufhealth/eslint-config-wp
In your .eslintrc
, eslint.config.js
or package.json#eslint
:
{
"extends": ["@ufhealth/eslint-config-wp"]
}
By default, this configuration supports the React library bundled with WordPress, exposed as wp.element
. If you're writing scripts for the block editor, or enqueueing wp-element
for use on the front-end, you don't need to do anything (and we highly recommend you don't).
However, if your script isn't for the editor and you'd like to use a different version of React (or another library like Preact)...
...no problem! Just change the pragma
and version
settings accordingly:
{
"extends": ["@ufhealth/eslint-config-wp"],
"settings": {
"react": {
"pragma": "Preact",
"version": "8.4"
}
}
}
NOTE: You'll need to make sure your .babelrc
pragma setting matches whatever you choose, and also make sure you import
your respective library wherever you use JSX (this second step isn't required if you're using the wp.element
default).