woocommerce/packages/js/eslint-plugin
Sam Seay 4c7e0c7fce
Some checks failed
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (10, 10) (push) Failing after 5s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (2, 10) (push) Failing after 4s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (3, 10) (push) Failing after 4s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (1, 10) (push) Failing after 1h0m30s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (5, 10) (push) Failing after 2s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (6, 10) (push) Failing after 2s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (7, 10) (push) Failing after 2s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (8, 10) (push) Failing after 2s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (9, 10) (push) Failing after 2s
Nightly builds / Nightly builds (push) Has been skipped
Process stale issues / stale (push) Failing after 3s
Blocks Playwright Tests / Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} (4, 10) (push) Failing after 1h20m52s
Blocks Playwright Tests / Merge Artifacts (push) Has been skipped
Blocks Playwright Tests / Create GitHub issues for flaky tests (push) Has been skipped
Storybook GitHub Pages / deploy (push) Has been skipped
Daily tests run / Run tests (push) Failing after 1m27s
Bump wireit to 0.14.10 (#54996)
2025-01-31 00:48:44 +13:00
..
changelog Bump wireit to 0.14.10 (#54996) 2025-01-31 00:48:44 +13:00
configs fix: fixed all instances of translator lint rule violations (#41450) 2023-11-16 19:15:11 +08:00
docs/rules
rules
.eslintrc.js
.npmrc
CHANGELOG.md Prepare Packages for Release (#48406) 2024-06-11 15:31:03 -07:00
composer.json bump php version in packages/js/*/composer.json (#42020) 2024-01-04 10:18:34 -04:00
composer.lock
index.js
package.json Bump wireit to 0.14.10 (#54996) 2025-01-31 00:48:44 +13:00
PREVIOUS_CHANGELOG.md
README.md [Accessibility] Fix typos in packages/js/**/*.md files (#48569) 2024-06-20 13:04:24 -07:00

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 to 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