woocommerce/plugins/woocommerce-admin/packages/eslint-plugin
louwie17 cb3c1e88e8 Add tilde (~) option for client root directory (https://github.com/woocommerce/woocommerce-admin/pull/6517)
* Add tilde option for client root directory

* Support tilde start as internal to fix lint issues

* Update baseUrl and paths so auto complete works correctly

* Add changelogs

* Add eslint support for webpack resolvers

Co-authored-by: Matt Sherman <matt@jam123.com>
2021-03-10 11:11:37 -04:00
..
configs Update wordpress monorepo (https://github.com/woocommerce/woocommerce-admin/pull/6013) 2021-02-11 10:52:39 +13:00
docs/rules Add @woocommerce/eslint-plugin (https://github.com/woocommerce/woocommerce-admin/pull/4714) 2020-07-28 14:32:58 +12:00
rules Add tilde (~) option for client root directory (https://github.com/woocommerce/woocommerce-admin/pull/6517) 2021-03-10 11:11:37 -04:00
.npmrc Add @woocommerce/eslint-plugin (https://github.com/woocommerce/woocommerce-admin/pull/4714) 2020-07-28 14:32:58 +12:00
CHANGELOG.md Add tilde (~) option for client root directory (https://github.com/woocommerce/woocommerce-admin/pull/6517) 2021-03-10 11:11:37 -04:00
README.md Update wordpress monorepo (https://github.com/woocommerce/woocommerce-admin/pull/6013) 2021-02-11 10:52:39 +13:00
index.js Add @woocommerce/eslint-plugin (https://github.com/woocommerce/woocommerce-admin/pull/4714) 2020-07-28 14:32:58 +12:00
package.json Update wordpress monorepo (https://github.com/woocommerce/woocommerce-admin/pull/6013) 2021-02-11 10:52:39 +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

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