woocommerce/packages/js/eslint-plugin
Christopher Allford bf29119032
Updated PNPM to ^8.12.1 (#42860)
2023-12-18 20:31:49 +13:00
..
changelog Updated PNPM to ^8.12.1 (#42860) 2023-12-18 20:31:49 +13:00
configs fix: fixed all instances of translator lint rule violations (#41450) 2023-11-16 19:15:11 +08:00
docs/rules Moved WCA Packages 2022-03-18 14:25:26 -07:00
rules Update the @woocommerce/eslint-plugin and fix bugs (#36988) 2023-03-02 11:36:38 +13:00
.eslintrc.js Update Syncpack and use it to pin @wordpress packages to wp-6.0 (#37034) 2023-03-09 10:13:25 +13:00
.npmrc Moved WCA Packages 2022-03-18 14:25:26 -07:00
CHANGELOG.md Prepare Packages for Release (#33776) 2022-07-08 14:04:49 +12:00
PREVIOUS_CHANGELOG.md Update JS packages changelogs (#33412) 2022-06-16 10:06:31 +12:00
README.md Moved WCA Packages 2022-03-18 14:25:26 -07:00
composer.json Update changelogger to 3.3.0 to support PR number capturing with merge (#36266) 2023-01-05 14:42:51 +05:30
composer.lock Update changelogger to 3.3.0 to support PR number capturing with merge (#36266) 2023-01-05 14:42:51 +05:30
index.js Update the @woocommerce/eslint-plugin and fix bugs (#36988) 2023-03-02 11:36:38 +13:00
package.json Updated PNPM to ^8.12.1 (#42860) 2023-12-18 20:31:49 +13:00

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