4210b6f0a8
* update @wordpress/eslint-plugin dependency to latest version * local prettier config isn’t needed anymore because of fix in upstream package * add jsdoc config to use typescript format for jsdocs * update changelog * update packages and include .prettierrc.js back in for code editor support of prettier * add docs * minor prettier fix in test file * Convert all new eslint rules throwing errors to warnings temporarily to be handled in separate prs * updated changelog * fix package-lock.json * prettier auto-fixes * add prettier dependency at root * sigh prettier is being finicky * version bump Co-authored-by: Paul Sealock <psealock@gmail.com> |
||
---|---|---|
.. | ||
configs | ||
docs/rules | ||
rules | ||
.npmrc | ||
CHANGELOG.md | ||
README.md | ||
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):
- 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
npm 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 | ✓ |