From 9edad5270d7bf991670af521479aaaa7b5400001 Mon Sep 17 00:00:00 2001 From: Leif Singer Date: Mon, 6 Nov 2023 23:43:45 +0100 Subject: [PATCH] appease the linter --- .github/CONTRIBUTING.md | 6 +- SECURITY.md | 4 +- packages/js/e2e-core-tests/README.md | 114 +++++++++--------- .../docs/examples/activity-panel-inbox.md | 8 +- .../src/Blocks/fixtures/no-frontmatter.md | 4 +- .../tests/src/Blocks/fixtures/test.md | 6 +- plugins/woocommerce/README.md | 18 +-- plugins/woocommerce/packages/README.md | 14 +-- 8 files changed, 87 insertions(+), 87 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7565261ceef..dca642e6d8b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -38,9 +38,9 @@ Please take a moment to review the [project readme](https://github.com/woocommer - Before pushing commits to GitHub, check your code against our code standards. For PHP code in the WooCommerce Core project you can do this by running `pnpm --filter=woocommerce run lint:php:changes:branch`. - Whenever possible, please fix pre-existing code standards errors in code that you change. - Please consider adding appropriate tests related to your change if applicable such as unit, API and E2E tests. You can check the following guides for this purpose: - - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#guide-for-writing-unit-tests). - - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-api-tests). - - [Writing E2E tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e-pw#guide-for-writing-e2e-tests). + - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#guide-for-writing-unit-tests). + - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-api-tests). + - [Writing E2E tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e-pw#guide-for-writing-e2e-tests). - Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured. - When committing, reference your issue number (#1234) and include a note about the fix. - Ensure that your code supports the minimum supported versions of PHP and WordPress; this is shown at the top of the `readme.txt` file. diff --git a/SECURITY.md b/SECURITY.md index f53b324f4a3..b258ac8367d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -21,7 +21,7 @@ Our most critical targets are: For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic). -_Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._ +Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress). ## Guidelines @@ -31,7 +31,7 @@ We're committed to working with security researchers to resolve the vulnerabilit * Pen-testing Production: * Please **setup a local environment** instead whenever possible. Most of our code is open source (see above). * If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC. - * **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels. + * **Don't automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels. * To be eligible for a bounty, please follow all of these guidelines. * Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability. diff --git a/packages/js/e2e-core-tests/README.md b/packages/js/e2e-core-tests/README.md index b440e384c36..0a6027c81e6 100644 --- a/packages/js/e2e-core-tests/README.md +++ b/packages/js/e2e-core-tests/README.md @@ -7,9 +7,9 @@ This package contains the automated end-to-end tests for WooCommerce. - [Pre-requisites](#pre-requisites) - [Setting up core tests](#setting-up-core-tests) - [Test functions](#test-functions) - - [Activation and setup](#activation-and-setup) - - [Merchant](#merchant) - - [Shopper](#shopper) + - [Activation and setup](#activation-and-setup) + - [Merchant](#merchant) + - [Shopper](#shopper) - [Contributing a new test](#contributing-a-new-test) ## Pre-requisites @@ -27,13 +27,14 @@ Version 0.2.0 added a test installer that will populate the `tests/e2e/specs` fo - Install the e2e-environment `npm install @woocommerce/e2e-environment --save-dev` - Run the installer `npx wc-e2e install @woocommerce/e2e-core-tests` - Merge the sample configuration files: - - `tests/e2e/docker/woocommerce.e2e-core-tests.sh` => `initialize.sh` - - `tests/e2e/config/default-woocommerce.e2e-core-tests.json` => `default.json` + - `tests/e2e/docker/woocommerce.e2e-core-tests.sh` => `initialize.sh` + - `tests/e2e/config/default-woocommerce.e2e-core-tests.json` => `default.json` #### Version 0.1.X or other test runner - Create the folder `tests/e2e/specs` in your repository if it does not exist. - To add a core test to your test suite, create a new `.test.js` file within `tests/e2e/specs` . Example code to run all the shopper tests: + ```js const { runShopperTests } = require( '@woocommerce/e2e-core-tests' ); @@ -54,71 +55,72 @@ The functions to access the core tests are: ### Activation and setup - `runSetupOnboardingTests` - Run all setup and onboarding tests - - `runActivationTest` - Merchant can activate WooCommerce - - `runOnboardingFlowTest` - Merchant can complete onboarding flow - - `runTaskListTest` - Merchant can complete onboarding task list - - `runInitialStoreSettingsTest` - Merchant can complete initial settings + - `runActivationTest` - Merchant can activate WooCommerce + - `runOnboardingFlowTest` - Merchant can complete onboarding flow + - `runTaskListTest` - Merchant can complete onboarding task list + - `runInitialStoreSettingsTest` - Merchant can complete initial settings ### Merchant - `runMerchantTests` - Run all merchant tests - - `runAddShippingClassesTest` - Merchant can create shipping classes and let shopper test them - - `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them - - `runAddSimpleProductTest` - Merchant can create a simple product - - `runAddVariableProductTest` - Merchant can create a variable product - - `runCreateCouponTest` - Merchant can create coupon - - `runCreateOrderTest` - Merchant can create order - - `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page - - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions - - `runEditOrderTest` - Merchant can edit an order in the dashboard - - `runOrderStatusFilterTest` - Merchant can filter orders by order status - - `runOrderRefundTest` - Merchant can refund an order - - `runOrderApplyCouponTest` - Merchant can apply a coupon to an order - - `runOrderSearchingTest` - Merchant can search for order via different terms - - `runProductEditDetailsTest` - Merchant can edit an existing product - - `runProductSearchTest` - Merchant can search for a product and view it - - `runProductSettingsTest` - Merchant can update product settings - - `runTaxSettingsTest` - Merchant can update tax settings - - `runUpdateGeneralSettingsTest` - Merchant can update general settings - - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions - - `runAnalyticsPageLoadsTest` - Merchant can load and see all pages in Analytics - - `runImportProductsTest` - Merchant can import products via CSV file - - `runInitiateWccomConnectionTest` - Merchant can initiate connection to Woo.com - - `runAdminPageLoadTests` - Merchant can load pages from the WP Admin sidebar + - `runAddShippingClassesTest` - Merchant can create shipping classes and let shopper test them + - `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them + - `runAddSimpleProductTest` - Merchant can create a simple product + - `runAddVariableProductTest` - Merchant can create a variable product + - `runCreateCouponTest` - Merchant can create coupon + - `runCreateOrderTest` - Merchant can create order + - `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page + - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions + - `runEditOrderTest` - Merchant can edit an order in the dashboard + - `runOrderStatusFilterTest` - Merchant can filter orders by order status + - `runOrderRefundTest` - Merchant can refund an order + - `runOrderApplyCouponTest` - Merchant can apply a coupon to an order + - `runOrderSearchingTest` - Merchant can search for order via different terms + - `runProductEditDetailsTest` - Merchant can edit an existing product + - `runProductSearchTest` - Merchant can search for a product and view it + - `runProductSettingsTest` - Merchant can update product settings + - `runTaxSettingsTest` - Merchant can update tax settings + - `runUpdateGeneralSettingsTest` - Merchant can update general settings + - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions + - `runAnalyticsPageLoadsTest` - Merchant can load and see all pages in Analytics + - `runImportProductsTest` - Merchant can import products via CSV file + - `runInitiateWccomConnectionTest` - Merchant can initiate connection to Woo.com + - `runAdminPageLoadTests` - Merchant can load pages from the WP Admin sidebar ### Shopper - `runShopperTests` - Run all shopper tests - - `runCartApplyCouponsTest` - Shopper can use coupons on cart - - `runCartPageTest` - Shopper can view and update cart - - `runCheckoutApplyCouponsTest` - Shopper can use coupons on checkout - - `runCheckoutPageTest` - Shopper can complete checkout - - `runMyAccountPageTest` - Shopper can access my account page - - `runMyAccountPayOrderTest` - Shopper can pay for their order in My Account - - `runProductBrowseSearchSortTest` - Shopper can browse, search & sort products - - `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped) - - `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product - - `runCheckoutCreateAccountTest` - Shopper can create an account during checkout - - `runCheckoutLoginAccountTest` - Shopper can login to an account during checkout - - `runMyAccountCreateAccountTest` - Shopper can create an account via my account page - - `runCartCalculateShippingTest` - Shopper can calculate shipping in the cart - - `runCartRedirectionTest` - Shopper is redirected to the cart page after adding to cart - - `runOrderEmailReceivingTest` - Shopper can receive an email for his order - - `runCartAndCheckoutConsistentShippingTest` - Shopper gets consistent shipping information on cart and checkout pages + - `runCartApplyCouponsTest` - Shopper can use coupons on cart + - `runCartPageTest` - Shopper can view and update cart + - `runCheckoutApplyCouponsTest` - Shopper can use coupons on checkout + - `runCheckoutPageTest` - Shopper can complete checkout + - `runMyAccountPageTest` - Shopper can access my account page + - `runMyAccountPayOrderTest` - Shopper can pay for their order in My Account + - `runProductBrowseSearchSortTest` - Shopper can browse, search & sort products + - `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped) + - `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product + - `runCheckoutCreateAccountTest` - Shopper can create an account during checkout + - `runCheckoutLoginAccountTest` - Shopper can login to an account during checkout + - `runMyAccountCreateAccountTest` - Shopper can create an account via my account page + - `runCartCalculateShippingTest` - Shopper can calculate shipping in the cart + - `runCartRedirectionTest` - Shopper is redirected to the cart page after adding to cart + - `runOrderEmailReceivingTest` - Shopper can receive an email for his order + - `runCartAndCheckoutConsistentShippingTest` - Shopper gets consistent shipping information on cart and checkout pages ### REST API - `runApiTests` - Run all API tests - - `runExternalProductAPITest` - Can create, read, and delete an external product - - `runGroupedProductAPITest` - Can create, read, and delete a grouped product - - `runVariableProductAPITest` - Can create, read, and delete a variable product and its variations - - `runCouponApiTest` - Can create, read, and delete a coupon - - `runOrderApiTest` - Can create, read, and delete an order + - `runExternalProductAPITest` - Can create, read, and delete an external product + - `runGroupedProductAPITest` - Can create, read, and delete a grouped product + - `runVariableProductAPITest` - Can create, read, and delete a variable product and its variations + - `runCouponApiTest` - Can create, read, and delete a coupon + - `runOrderApiTest` - Can create, read, and delete an order ## Contributing a new test - In your branch create a new `example-test-name.test.js` under the appropriate folder in the [`specs`](specs) directory. -- Jest does not allow its global functions to be accessed outside the jest environment. To allow the test code to be published in a package import any jest global functions used in your test +- Jest does not allow its global functions to be accessed outside the jest environment. To allow the test code to be published in a package import any jest global functions used in your test. + ```js const { it, @@ -126,7 +128,9 @@ const { beforeAll, } = require( '@jest/globals' ); ``` + - Wrap your test in a function and export it + ```js const runExampleTestName = () => { describe('Example test', () => { @@ -143,7 +147,9 @@ const runExampleTestName = () => { module.exports = runExampleTestName; ``` + - Add your test to [`specs/index.js`](specs/index.js) + ```js const runExampleTestName = require( './grouping/example-test-name.test' ); // ... diff --git a/plugins/woocommerce-admin/docs/examples/activity-panel-inbox.md b/plugins/woocommerce-admin/docs/examples/activity-panel-inbox.md index 3bd543ed393..86c1cd7dddc 100644 --- a/plugins/woocommerce-admin/docs/examples/activity-panel-inbox.md +++ b/plugins/woocommerce-admin/docs/examples/activity-panel-inbox.md @@ -1,5 +1,4 @@ -Activity Panel Inbox -==================== +# Activity Panel Inbox Right now, installing and activating WooCommerce and a few extensions quickly results in a cascade of notices vying for the store administrator’s attention (and pushing whatever wp-admin content they were trying to get to on a page down, way down.) @@ -19,14 +18,15 @@ But unlike today’s notices, this part of the UI will be reserved for “priori The second category is what we’re focusing on in this example - and what we expect the vast majority of extension developers will want to extend - we call it the “Activity Panel Inbox.” It will look something like this: -Activity Panel Inbox +![Activity Panel Inbox](images/activity-panel-inbox.png) This section is dedicated to informational content coming from multiple sources such as WooCommerce core, Woo.com Subscription management, extensions activity and store achievements. This section was also envisioned to display more insightful content in the future, e.g. content that could help with the day to day tasks of managing and optimizing a store. Each notice or “note” has a type represented by an icon (Gridicon), a title, content, a timestamp and one or two actions (action title + link). ### Inbox Design Constraints and Best Practices -Extensions can add their own notes via the data stores we’ll be covering below, but first... some constraints... + +Extensions can add their own notes via the data stores we’ll be covering below, but first: some constraints. There are some constraints extensions should follow when working with the inbox: diff --git a/plugins/woocommerce-docs/tests/src/Blocks/fixtures/no-frontmatter.md b/plugins/woocommerce-docs/tests/src/Blocks/fixtures/no-frontmatter.md index 02ca655baee..10e87cb3b3a 100644 --- a/plugins/woocommerce-docs/tests/src/Blocks/fixtures/no-frontmatter.md +++ b/plugins/woocommerce-docs/tests/src/Blocks/fixtures/no-frontmatter.md @@ -28,8 +28,8 @@ Here is a link: [Woo.com](https://woo.com). ![An image](https://picsum.photos/200/300 'This is an image.') -``` -$ cd /path/to/woocommerce-docs +```shell +cd /path/to/woocommerce-docs ``` > This is a blockquote. diff --git a/plugins/woocommerce-docs/tests/src/Blocks/fixtures/test.md b/plugins/woocommerce-docs/tests/src/Blocks/fixtures/test.md index 36985c81411..492ee76c26d 100644 --- a/plugins/woocommerce-docs/tests/src/Blocks/fixtures/test.md +++ b/plugins/woocommerce-docs/tests/src/Blocks/fixtures/test.md @@ -2,7 +2,7 @@ title: Some frontmatter --- -# Heading 1 +# Heading 1 {{< mdl-disable "" >}} ## Heading 2 @@ -30,8 +30,8 @@ Here is a link: [Woo.com](https://woo.com). ![An image](https://picsum.photos/200/300 'This is an image.') -``` -$ cd /path/to/woocommerce-docs +```shell +cd /path/to/woocommerce-docs ``` > This is a blockquote. diff --git a/plugins/woocommerce/README.md b/plugins/woocommerce/README.md index fd7f4b7334f..0c5d2da5b85 100644 --- a/plugins/woocommerce/README.md +++ b/plugins/woocommerce/README.md @@ -1,12 +1,10 @@ -

WooCommerce

+# [![WooCommerce](https://woo.com/wp-content/themes/woo/images/logo-woocommerce@2x.png 'WooCommerce')](https://woo.com/) -

-license -WordPress.org downloads -WordPress.org rating -Build Status -codecov -

+[![License](https://poser.pugx.org/woocommerce/woocommerce/license 'License')](https://packagist.org/packages/woocommerce/woocommerce) +![WordPress.org downloads](https://img.shields.io/wordpress/plugin/dt/woocommerce.svg 'WordPress.org downloads') +![WordPress.org rating](https://img.shields.io/wordpress/plugin/r/woocommerce.svg 'WordPress.org rating') +[![Build Status](https://github.com/woocommerce/woocommerce/actions/workflows/ci.yml/badge.svg?branch=trunk 'Build Status')](https://github.com/woocommerce/woocommerce/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/woocommerce/woocommerce/branch/trunk/graph/badge.svg 'codecov')](https://codecov.io/gh/woocommerce/woocommerce) This is the WooCommerce Core plugin. Here you can browse the source and keep track of development. We recommend all developers to follow the [WooCommerce development blog](https://woocommerce.wordpress.com/) to stay up to date about everything happening in the project. You can also [follow @DevelopWC](https://twitter.com/DevelopWC) on Twitter for the latest development updates. @@ -25,7 +23,7 @@ cd plugins/woocommerce pnpm -- wp-env start ``` -You should now be able to visit http://localhost:8888/ and access WooCommerce environment. +You should now be able to visit `http://localhost:8888/` and access WooCommerce environment. ## Building Components @@ -72,10 +70,12 @@ pnpm --filter=woocommerce/client/admin ts:check ``` ## Documentation + * [WooCommerce Documentation](https://woo.com/) * [WooCommerce Developer Documentation](https://github.com/woocommerce/woocommerce/wiki) * [WooCommerce Code Reference](https://woo.com/wc-apidocs/) * [WooCommerce REST API Docs](https://woocommerce.github.io/woocommerce-rest-api-docs/) ## Reporting Security Issues + To disclose a security issue to our team, [please submit a report via HackerOne here](https://hackerone.com/automattic/). diff --git a/plugins/woocommerce/packages/README.md b/plugins/woocommerce/packages/README.md index 52259ed59d7..432f5c894ff 100644 --- a/plugins/woocommerce/packages/README.md +++ b/plugins/woocommerce/packages/README.md @@ -8,19 +8,13 @@ You need Composer to use the packages. If you don't have it installed, go and ch ## Developing new packages -To create a package and/or feature plugin for core, you can base your plugin on the example package here: - -https://github.com/woocommerce/woocommerce-example-package +To create a package and/or feature plugin for core, you can base your plugin on [the example package here](https://github.com/woocommerce/woocommerce-example-package). Packages require a Package class which inits the package and returns version information, and Packages also require that you use the `jetpack-autoloader` package which prevents version conflicts should the same package be used by multiple plugins at once. This is shown in the example package above. ## Publishing a package -Your package should be published to Packagist. For example: - -https://packagist.org/packages/woocommerce/woocommerce-example-package - -The package name in this case is `woocommerce/woocommerce-example-package`. +Your package should be published to Packagist ([example](https://packagist.org/packages/woocommerce/woocommerce-example-package)). The package name in this case is `woocommerce/woocommerce-example-package`. ## Including packages in core @@ -47,7 +41,7 @@ Edit `composer.json` in the root directory and add the package and package versi Next, if your package contains user translatable strings you'll need to edit `bin/package-update.sh` and instruct it to change your package textdomain to the `woocommerce` textdomain. For example: -``` +```shell find ./packages/woocommerce-example-package -iname '*.php' -exec sed -i.bak -e "s/, 'woocommerce-example-package'/, 'woocommerce'/g" {} \; ``` @@ -67,7 +61,7 @@ You can add tests to ensure your package is loaded to the WooCommerce unit-tests Once you have defined your package requirements, run -``` +```shell composer install ```