c6048b5c49
* add uuid to syncpack * add rimraf to syncpack * add glob to syncpack * Add changefile(s) from automation for the following project(s): @woocommerce/tracks, @woocommerce/product-editor, @woocommerce/onboarding, @woocommerce/number, @woocommerce/notices, @woocommerce/navigation, @woocommerce/internal-js-tests, @woocommerce/integrate-plugin, @woocommerce/expression-evaluation, @woocommerce/explat, @woocommerce/experimental, @woocommerce/eslint-plugin, @woocommerce/dependency-extraction-webpack-plugin, @woocommerce/date, @woocommerce/data, @woocommerce/customer-effort-score, @woocommerce/currency, @woocommerce/csv-export, @woocommerce/components, @woocommerce/block-templates, @woocommerce/ai, @woocommerce/admin-layout, @woocommerce/admin-e2e-tests, woocommerce --------- Co-authored-by: Ron Rennick <ronald.rennick@automattic.com> Co-authored-by: github-actions <github-actions@github.com> |
||
---|---|---|
.. | ||
changelog | ||
configs | ||
docs/rules | ||
rules | ||
.eslintrc.js | ||
.npmrc | ||
CHANGELOG.md | ||
PREVIOUS_CHANGELOG.md | ||
README.md | ||
composer.json | ||
composer.lock | ||
index.js | ||
package.json |
README.md
ESLint Plugin
This is an ESLint plugin including configurations and custom rules for WooCommerce development.
Note: This primarily extends the @wordpress/eslint-plugin/recommended
ruleset and does not change any of the rules exposed on that plugin. As a base, all WooCommerce projects are expected to follow WordPress JavaScript Code Styles.
However, this ruleset does implement the following (which do not conflict with WordPress standards):
- Using typescript eslint parser to allow for eslint Import (see issue)
- prettier formatting (using
wp-prettier
) - Dependency grouping (External and Internal) for dependencies in JavaScript files
- No yoda conditionals
- Radix argument required for
parseInt
.
Installation
Install the module
pnpm install @woocommerce/eslint-plugin --save-dev
Usage
To opt-in to the default configuration, extend your own project's .eslintrc.js
file:
module.exports = {
"extends": [ "plugin:@woocommerce/eslint-plugin/recommended" ]
}
Refer to the ESLint documentation on Shareable Configs for more information.
The recommended
preset will include rules governing an ES2015+ environment, and includes rules from the @wordpress/eslint-plugin/recommended
project.
If you want to use prettier in your code editor, you'll need ot create a .prettierrc.js
file at the root of your project with the following:
module.exports = require("@wordpress/prettier-config");
Rules
Rule | Description | Recommended |
---|---|---|
dependency-group | Enforce dependencies docblocks formatting | ✓ |