Merge branch 'fix/code-coverage' of github.com:woocommerce/woocommerce into fix/code-coverage

This commit is contained in:
moon 2022-03-29 17:06:40 -07:00
commit 93bd09ea2d
266 changed files with 2300 additions and 1080 deletions

View File

@ -6,9 +6,6 @@ contact_links:
- name: ❓ Support Question
url: https://woocommerce.com/document/woocommerce-self-service-guide/
about: If you have a question please see our docs or use our forums, helpdesk, or Slack community!
- name: WooCommerce Admin
url: https://github.com/woocommerce/woocommerce-admin
about: Please report issues for WooCommerce Admin (such as Analytics and Onboarding) directly to it's repository.
- name: WooCommerce Blocks
url: https://github.com/woocommerce/woocommerce-gutenberg-products-block
about: Please report issues for WooCommerce Blocks directly to it's repository.

View File

@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
php: [ '7.2', '7.3', '7.4', '8.0' ]
wp: [ 'latest' ]
include:
- wp: nightly

View File

@ -5,6 +5,11 @@ jobs:
name: Build zip for PR
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
@ -78,7 +83,16 @@ jobs:
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
run: pnpx wc-e2e test:e2e
- name: Archive E2E test screenshots
uses: actions/upload-artifact@v2
if: always()
with:
name: E2E Screenshots
path: package/woocommerce/plugins/woocommerce/tests/e2e/screenshots
if-no-files-found: ignore
retention-days: 5
api-tests-run:
name: Runs API tests.
runs-on: ubuntu-18.04
@ -136,65 +150,65 @@ jobs:
run: pnpx wc-api-tests test api
k6-tests-run:
name: Runs k6 Performance tests
runs-on: ubuntu-18.04
needs: [build]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
mkdir -p node_modules
- name: Checkout code.
uses: actions/checkout@v2
with:
path: package/woocommerce
name: Runs k6 Performance tests
runs-on: ubuntu-18.04
needs: [build]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
mkdir -p node_modules
- name: Checkout code.
uses: actions/checkout@v2
with:
path: package/woocommerce
- name: Install PNPM and install dependencies
working-directory: package/woocommerce
run: |
npm install -g pnpm
pnpm install
- name: Install PNPM and install dependencies
working-directory: package/woocommerce
run: |
npm install -g pnpm
pnpm install
- name: Workaround to use initialization file with prepopulated data.
working-directory: package/woocommerce/plugins/woocommerce/tests/e2e/docker
run: |
cp init-sample-products.sh initialize.sh
- name: Workaround to use initialization file with prepopulated data.
working-directory: package/woocommerce/plugins/woocommerce/tests/e2e/docker
run: |
cp init-sample-products.sh initialize.sh
- name: Load docker images and start containers.
working-directory: package/woocommerce/plugins/woocommerce
run: pnpx wc-e2e docker:up
- name: Load docker images and start containers.
working-directory: package/woocommerce/plugins/woocommerce
run: pnpx wc-e2e docker:up
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v2
with:
name: woocommerce
path: tmp
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v2
with:
name: woocommerce
path: tmp
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
- name: Install dependencies again
working-directory: package/woocommerce
run: |
npm install -g pnpm
pnpm install
- name: Install dependencies again
working-directory: package/woocommerce
run: |
npm install -g pnpm
pnpm install
- name: Wait for the Docker container to be built
working-directory: package/woocommerce/plugins/woocommerce
run: pnpx wc-e2e docker:wait
- name: Wait for the Docker container to be built
working-directory: package/woocommerce/plugins/woocommerce
run: pnpx wc-e2e docker:wait
- name: Install k6
run: |
curl https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
- name: Run k6 tests
run: |
./k6 run package/woocommerce/plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js
- name: Install k6
run: |
curl https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
- name: Run k6 tests
run: |
./k6 run package/woocommerce/plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js

View File

@ -19,6 +19,11 @@ jobs:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
with:

View File

@ -11,6 +11,11 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
with:

View File

@ -9,6 +9,11 @@ jobs:
label_project:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -11,6 +11,11 @@ jobs:
if: "${{ contains(github.event.label.name, 'run: smoke tests') }}"
runs-on: ubuntu-18.04
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Create dirs.
run: |
mkdir -p code/woocommerce

View File

@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
php: [ '7.2', '7.3', '7.4', '8.0' ]
wp: [ "latest" ]
include:
- wp: nightly
@ -32,6 +32,11 @@ jobs:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2

5
.gitignore vendored
View File

@ -4,7 +4,7 @@ Thumbs.db
# IDE files
.idea
.vscode/
.vscode/*
project.xml
project.properties
.project
@ -13,6 +13,9 @@ project.properties
*.sublime-workspace
.sublimelinterrc
# Excluded IDE Files for developer experience tooling within workspace
!.vscode/tasks.json
# Grunt
none

29
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"command": "pnpm tsc -b tsconfig.base.json",
"type": "shell",
"problemMatcher": [ "$tsc" ],
"label": "Typescript compile",
"detail": "Run tsc against tsconfig.base.json",
"runOptions": {
"runOn": "default"
}
},
{
"command": "pnpm tsc -b tsconfig.base.json --watch",
"type": "shell",
"problemMatcher": {
"base": "$tsc-watch",
"applyTo": "allDocuments"
},
"isBackground": true,
"label": "Incremental Typescript compile",
"detail": "Incremental background type checks",
"runOptions": {
"runOn": "folderOpen"
}
}
]
}

View File

@ -45,6 +45,21 @@ You might also want to run `pnpm start` to watch your CSS and JS changes if you
You're now ready to develop!
### Typescript Checking
Typescript is progressively being implemented in this repository, and you might come across some files that are `.ts` or `.tsx`. By default, a VSCode environment will run type checking on such files that are currently open.
As of now, some parts of the codebase that were imported from the Woocommerce-Admin repository, into the `plugins/woocommerce-admin/client` directory, still fail Typescript checking. This has been scheduled on the team's backlog to be fixed.
In order to run type checking across the entire repository, you can run this command in your shell, from the root of this repository:
```sh
pnpm tsc -b tsconfig.base.json
```
For better developer experience, the folder `.vscode/tasks.json` has two VSCode tasks to run these commands automatically as well as to parse the output and highlight the errors in the `Problems` tab and in the file explorer pane. The first task runs it once, the second one runs it in the background upon saving of any modified files. This task is also automatically prompted by VSCode to be run upon opening the folder.
## Using Xdebug
Please refer to [WP-ENV official README](https://github.com/WordPress/gutenberg/tree/master/packages/env#using-xdebug) section for setting up Xdebug.

View File

@ -19,13 +19,14 @@
"devDependencies": {
"@automattic/nx-composer": "^0.1.0",
"@nrwl/cli": "^13.3.4",
"@nrwl/linter": "^13.3.4",
"@nrwl/devkit": "^13.1.4",
"@nrwl/linter": "^13.3.4",
"@nrwl/tao": "13.3.4",
"@nrwl/web": "^13.3.4",
"@nrwl/workspace": "^13.3.4",
"@types/node": "14.14.33",
"@woocommerce/eslint-plugin": "workspace:*",
"@wordpress/eslint-plugin": "^11.0.0",
"@wordpress/prettier-config": "^1.1.1",
"chalk": "^4.1.2",
"glob": "^7.2.0",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -37,6 +37,8 @@
"@types/puppeteer": "^5.4.5",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@woocommerce/api": "^0.2.0",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"jest-mock-extended": "^1.0.18",
@ -48,10 +50,11 @@
"access": "public"
},
"scripts": {
"prepare": "pnpm run build",
"prepare": "pnpm run build",
"build": "tsc --build",
"start": "tsc --build --watch",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"lint": "eslint src",
"prepack": "pnpm run clean && pnpm run build"
}
}

View File

@ -47,7 +47,7 @@ async function deactivateAndDeletePlugin( pluginName: string ) {
}
export async function deactivateAndDeleteAllPlugins( except: string[] = [] ) {
let plugins = await getPlugins();
let skippedPlugins = [];
const skippedPlugins = [];
const promises = [];
for ( const plugin of plugins ) {
const splitPluginName = plugin.plugin.split( '/' );

View File

@ -18,7 +18,9 @@ export class ThemeSection extends BasePage {
const title = await waitForElementByText( 'h2', themeTitle );
const chooseButton = await title?.evaluateHandle( ( element ) => {
const card = element.closest( '.components-card' );
return Array.from( card?.querySelectorAll('button') || [] ).find( el => el.textContent === 'Choose');
return Array.from( card?.querySelectorAll( 'button' ) || [] ).find(
( el ) => el.textContent === 'Choose'
);
} );
if ( chooseButton ) {
await chooseButton.asElement()?.click();

View File

@ -1,13 +1,21 @@
# WooCommerce API Client
An isometric API client for interacting with WooCommerce installations. Here are the current and planned
An API client for interacting with WooCommerce installations that works both in the browser and in Node environments. Here are the current and planned
features:
- [x] TypeScript Definitions
- [x] TypeScript Definitions \*
- [x] Axios API Client with support for OAuth & basic auth
- [x] Repositories to simplify interaction with basic data types
- [X] Partial support to Repositories, to simplify interaction with basic data types \*
- [x] Service classes for common activities such as changing settings
_\* TypeScript Definitions and Repositories are currently only supported for [Products](https://woocommerce.github.io/woocommerce-rest-api-docs/#products), and partially supported for [Orders](https://woocommerce.github.io/woocommerce-rest-api-docs/#orders)._
## Differences from @woocommerce/woocomerce-rest-api
WooCommerce has two API clients in JavaScript for interacting with a WooCommerce installation's RESTful API. This package, and the [@woocommerce/woocomerce-rest-api](https://www.npmjs.com/package/@woocommerce/woocommerce-rest-api) package.
The main difference between them is the Repositories and the TypeScript definitions for the supported endpoints. When using Axios directly, as you can do with both libraries, you query the WooCommerce API in a raw object format, following the [API documentation](https://woocommerce.github.io/woocommerce-rest-api-docs/#introduction) parameters. Comparatively, with the Repositories provided in this package, you have the parameters as properties of an object, which gives you the benefits of auto-complete and strict types, for instance.
## Usage
```bash

View File

@ -12,56 +12,44 @@ const { options: babelDefaultConfig } = babel.loadPartialConfig( {
} );
const plugins = babelDefaultConfig.plugins;
if ( ! process.env.SKIP_JSX_PRAGMA_TRANSFORM ) {
plugins.push( [ '@wordpress/babel-plugin-import-jsx-pragma', {
scopeVariable: 'createElement',
source: '@wordpress/element',
isDefault: false,
} ] );
plugins.push( [
'@wordpress/babel-plugin-import-jsx-pragma',
{
scopeVariable: 'createElement',
source: '@wordpress/element',
isDefault: false,
},
] );
}
const overrideOptions = ( target, targetName, options ) => {
if ( get( target, [ 'file', 'request' ] ) === targetName ) {
return [ targetName, Object.assign(
{},
target.options,
options
) ];
return [ targetName, Object.assign( {}, target.options, options ) ];
}
return target;
};
const babelConfigs = {
main: Object.assign(
{},
babelDefaultConfig,
{
plugins,
presets: map(
babelDefaultConfig.presets,
( preset ) => overrideOptions( preset, '@babel/preset-env', {
modules: 'commonjs',
} )
),
}
),
module: Object.assign(
{},
babelDefaultConfig,
{
plugins: map(
plugins,
( plugin ) => overrideOptions( plugin, '@babel/plugin-transform-runtime', {
useESModules: true,
} )
),
presets: map(
babelDefaultConfig.presets,
( preset ) => overrideOptions( preset, '@babel/preset-env', {
modules: false,
} )
),
}
),
main: Object.assign( {}, babelDefaultConfig, {
plugins,
presets: map( babelDefaultConfig.presets, ( preset ) =>
overrideOptions( preset, '@babel/preset-env', {
modules: 'commonjs',
} )
),
} ),
module: Object.assign( {}, babelDefaultConfig, {
plugins: map( plugins, ( plugin ) =>
overrideOptions( plugin, '@babel/plugin-transform-runtime', {
useESModules: true,
} )
),
presets: map( babelDefaultConfig.presets, ( preset ) =>
overrideOptions( preset, '@babel/preset-env', {
modules: false,
} )
),
} ),
};
function getBabelConfig( environment ) {

View File

@ -0,0 +1,19 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
overrides: [
{
files: [
'**/stories/*.js',
'**/stories/*.jsx',
'**/docs/example.js',
],
rules: {
'import/no-unresolved': [
'warn',
{ ignore: [ '@woocommerce/components' ] },
],
},
},
],
};

View File

@ -77,6 +77,7 @@
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/runtime": "^7.17.2",
"@storybook/addon-actions": "^6.4.0",
"@storybook/addon-console": "^1.2.3",
"@storybook/addon-controls": "^6.4.19",
@ -95,9 +96,11 @@
"@testing-library/user-event": "^13.5.0",
"@woocommerce/style-build": "workspace:*",
"@wordpress/browserslist-config": "^4.1.1",
"@wordpress/eslint-plugin": "^11.0.0",
"@wordpress/scripts": "^12.6.1",
"concurrently": "^7.0.0",
"css-loader": "^3.6.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"postcss-loader": "^3.0.0",
@ -113,6 +116,7 @@
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build:css": "webpack",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"lint": "eslint src --ext=js,ts,tsx",
"prepack": "pnpm run clean && pnpm run build",
"start": "concurrently \"tsc --build ./tsconfig.json --watch\" \"webpack --watch\"",
"test": "pnpm run build && pnpm run test:nobuild",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -32,12 +32,15 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -35,12 +35,15 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -41,8 +41,10 @@
"@types/wordpress__components": "^9.8.6",
"@woocommerce/style-build": "workspace:*",
"@wordpress/browserslist-config": "^4.1.1",
"@wordpress/eslint-plugin": "^11.0.0",
"concurrently": "^7.0.0",
"css-loader": "^3.6.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"postcss-loader": "^3.0.0",
@ -64,6 +66,7 @@
"build:css": "webpack",
"start": "concurrently \"tsc --build --watch\" \"webpack --watch\"",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -43,9 +43,12 @@
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/runtime": "^7.17.2",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@types/wordpress__data-controls": "^2.2.0",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",
@ -63,6 +66,7 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -28,7 +28,9 @@
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"d3-time-format": "^2.3.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",
@ -46,6 +48,7 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -25,6 +25,8 @@
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -13,7 +13,7 @@
- Update `@wordpress/eslint-plugin` from v8 to v11. #8475
- Update `@typescript-eslint/parser` from v4 to v5. #8475
- Drop support for Node v10. Required node version is now ^12.22.0 || ^14.17.0 || >=16.0.0. #8475
- Update recommended eslint rules for @woocommerce/* packages, please see `recommended.js` for details.
# 1.2.0

View File

@ -7,10 +7,75 @@ module.exports = {
parser: '@typescript-eslint/parser',
globals: {
wcSettings: 'readonly',
'jest/globals': true,
jest: true,
},
plugins: [ '@wordpress' ],
rules: {
radix: 'error',
yoda: [ 'error', 'never' ],
// temporary conversion to warnings until the below are all handled.
'@wordpress/i18n-translator-comments': 'warn',
'@wordpress/valid-sprintf': 'warn',
'@wordpress/no-unsafe-wp-apis': 'warn',
'@wordpress/no-global-active-element': 'warn',
'import/no-extraneous-dependencies': 'warn',
'import/no-unresolved': 'warn',
'jest/no-deprecated-functions': 'warn',
'jest/valid-title': 'warn',
'jsdoc/check-tag-names': [
'error',
{
definedTags: [
'jest-environment',
'filter',
'action',
'slotFill',
'scope',
],
},
],
'no-unused-vars': [
'error',
{
varsIgnorePattern: 'createElement',
},
],
'react/react-in-jsx-scope': 'error',
},
settings: {
'import/resolver': 'typescript',
// List of modules that are externals in our webpack config.
'import/core-modules': [ '@woocommerce/settings', 'lodash', 'react' ],
react: {
pragma: 'createElement',
},
},
overrides: [
{
files: [ '*.ts', '*.tsx' ],
extends: [ 'plugin:@typescript-eslint/recommended' ],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-use-before-define': [ 'error' ],
'@typescript-eslint/no-shadow': [ 'error' ],
'@typescript-eslint/no-empty-function': 'off',
camelcase: 'off',
'no-use-before-define': 'off',
'jsdoc/require-param': 'off',
// Making use of typescript no-shadow instead, fixes issues with enum.
'no-shadow': 'off',
},
},
{
files: [
'**/stories/*.js',
'**/stories/*.jsx',
'**/docs/example.js',
],
rules: {
'react/react-in-jsx-scope': 'off',
},
},
],
};

View File

@ -28,7 +28,6 @@
"dependencies": {
"@typescript-eslint/parser": "^5.14.0",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.10.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-testing-library": "^5.1.0",
"requireindex": "^1.2.0"
@ -36,8 +35,12 @@
"publishConfig": {
"access": "public"
},
"scripts": {
"lint": "eslint ./rules ./configs"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"eslint": "^8.11.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -54,8 +54,10 @@
"@types/react-transition-group": "^4.4.4",
"@woocommerce/style-build": "workspace:*",
"@wordpress/browserslist-config": "^4.1.1",
"@wordpress/eslint-plugin": "^11.0.0",
"concurrently": "^7.0.0",
"css-loader": "^3.6.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"postcss-loader": "^3.0.0",
@ -77,6 +79,7 @@
"build:css": "webpack",
"start": "concurrently \"tsc --build --watch\" \"webpack --watch\"",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -37,6 +37,8 @@
"@types/cookie": "^0.4.1",
"@types/node": "^17.0.21",
"@types/qs": "^6.9.7",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",
@ -48,6 +50,7 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -26,7 +26,6 @@ const getRequestQueryString = ( {
* args.experimentName = 'my-experiment';
* return args;
* });
*
*/
return stringify(
applyFilters( 'woocommerce_explat_request_args', {

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -20,7 +20,8 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"ts:check": "tsc --noEmit --project ./tsconfig.json",
"clean": "pnpm exec rimraf *.tsbuildinfo build build-*",
"prepack": "pnpm run clean && pnpm run build"
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src"
},
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
@ -32,6 +33,8 @@
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -42,12 +42,16 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"@babel/runtime": "^7.17.2",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -39,10 +39,13 @@
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build"
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -30,12 +30,16 @@
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src",
"test": "pnpm run build && pnpm run test:nobuild",
"test:nobuild": "jest --config ./jest.config.json",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"@babel/runtime": "^7.17.2",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -38,7 +38,9 @@
"@babel/core": "^7.17.5",
"@woocommerce/style-build": "workspace:*",
"@wordpress/browserslist-config": "^4.1.1",
"@wordpress/eslint-plugin": "^11.0.0",
"css-loader": "^3.6.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"postcss-loader": "^3.0.0",
@ -55,6 +57,7 @@
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build:css": "webpack",
"start": "concurrently \"tsc --build --watch\" \"webpack --watch\"",
"prepack": "pnpm run clean && pnpm run build"
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src"
}
}

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -22,15 +22,20 @@
"@wordpress/base-styles": "^3.6.0",
"@wordpress/postcss-plugins-preset": "^1.6.0",
"css-loader": "^3.6.0",
"mini-css-extract-plugin": "^2.6.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^10.2.1",
"webpack-remove-empty-scripts": "^0.7.3",
"mini-css-extract-plugin": "^2.6.0",
"webpack-rtl-plugin": "^2.0.0"
},
"scripts": {
"lint": "eslint index.js"
},
"private": true,
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -0,0 +1,4 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
};

View File

@ -30,10 +30,13 @@
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build"
"prepack": "pnpm run clean && pnpm run build",
"lint": "eslint src"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@wordpress/eslint-plugin": "^11.0.0",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"rimraf": "^3.0.2",

View File

@ -10,3 +10,12 @@ vendor
legacy
tests/e2e
build-types
# These packages have their own eslint config and command
api
e2e-environment
e2e-utils
# These packages don't have their eslint setup, but have many lint errors.
api-core-tests
e2e-core-tests

View File

@ -1,77 +1,9 @@
module.exports = {
env: {
'jest/globals': true,
},
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
settings: {
'import/resolver': 'typescript',
// List of modules that are externals in our webpack config.
'import/core-modules': [ '@woocommerce/settings', 'lodash', 'react' ],
react: {
pragma: 'createElement',
},
},
root: true,
rules: {
// temporary conversion to warnings until the below are all handled.
'@wordpress/i18n-translator-comments': 'warn',
'@wordpress/valid-sprintf': 'warn',
'jsdoc/check-tag-names': [
'error',
{
definedTags: [
'jest-environment',
'filter',
'action',
'slotFill',
'scope',
],
},
],
'import/no-extraneous-dependencies': 'warn',
'import/no-unresolved': 'warn',
'jest/no-deprecated-functions': 'warn',
'@wordpress/no-unsafe-wp-apis': 'warn',
'jest/valid-title': 'warn',
'@wordpress/no-global-active-element': 'warn',
'no-unused-vars': [
'error',
{
varsIgnorePattern: 'createElement',
},
],
'react/react-in-jsx-scope': 'error',
},
overrides: [
{
files: [ '*.ts', '*.tsx' ],
parser: '@typescript-eslint/parser',
extends: [
'plugin:@woocommerce/eslint-plugin/recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
camelcase: 'off',
'import/no-unresolved': 'warn',
'import/no-extraneous-dependencies': 'warn',
'@typescript-eslint/no-explicit-any': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [ 'error' ],
'jsdoc/require-param': 'off',
// Making use of typescript no-shadow instead, fixes issues with enum.
'no-shadow': 'off',
'@typescript-eslint/no-shadow': [ 'error' ],
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: [
'client/**/*.js',
'client/**/*.jsx',
'**/stories/*.js',
'**/stories/*.jsx',
'**/docs/example.js',
],
files: [ 'client/**/*.js', 'client/**/*.jsx', 'client/**/*.tsx' ],
rules: {
'react/react-in-jsx-scope': 'off',
},

View File

@ -289,8 +289,8 @@ export default compose(
const taskLists = getTaskLists();
const welcomeFromCalypsoModalDismissed =
getOption( WELCOME_FROM_CALYPSO_MODAL_DISMISSED_OPTION_NAME ) ===
'yes';
getOption( WELCOME_FROM_CALYPSO_MODAL_DISMISSED_OPTION_NAME ) !==
'no';
const welcomeFromCalypsoModalDismissedResolved = hasFinishedResolution(
'getOption',
[ WELCOME_FROM_CALYPSO_MODAL_DISMISSED_OPTION_NAME ]
@ -305,7 +305,7 @@ export default compose(
fromCalypsoUrlArgIsPresent;
const welcomeModalDismissed =
getOption( WELCOME_MODAL_DISMISSED_OPTION_NAME ) === 'yes';
getOption( WELCOME_MODAL_DISMISSED_OPTION_NAME ) !== 'no';
const installTimestamp = getOption(
WOOCOMMERCE_ADMIN_INSTALL_TIMESTAMP_OPTION_NAME

View File

@ -25,9 +25,9 @@ export const ProgressHeader: React.FC< ProgressHeaderProps > = ( {
const taskList: TaskListType = select(
ONBOARDING_STORE_NAME
).getTaskList( taskListId );
const finishedResolution = select( ONBOARDING_STORE_NAME ).hasFinishedResolution(
'getTaskList', [ taskListId ]
);
const finishedResolution = select(
ONBOARDING_STORE_NAME
).hasFinishedResolution( 'getTaskList', [ taskListId ] );
const nowTimestamp = Date.now();
const visibleTasks = taskList?.tasks.filter(
( task ) =>
@ -49,7 +49,10 @@ export const ProgressHeader: React.FC< ProgressHeaderProps > = ( {
);
const progressTitle = useMemo( () => {
if ( ( ! hasVisitedTasks && completedCount < 2 ) || completedCount === tasksCount ) {
if (
( ! hasVisitedTasks && completedCount < 2 ) ||
completedCount === tasksCount
) {
const siteTitle = getSetting( 'siteTitle' );
return siteTitle
? sprintf(

View File

@ -6,7 +6,7 @@
align-items: center;
color: #fff;
&:before {
&::before {
content: '';
}

View File

@ -102,9 +102,8 @@ export const TasksReminderBar: React.FC< ReminderBarProps > = ( {
( ! task.isSnoozed || task.snoozedUntil < Date.now() )
);
const completedTasks = (visibleTasks?.filter(
( task ) => task.isComplete
) || []);
const completedTasks =
visibleTasks?.filter( ( task ) => task.isComplete ) || [];
const isResolved = taskListIsResolved && optionIsResolved;

View File

@ -17,11 +17,11 @@
"typeRoots": [
"../typings",
"../node_modules/@types",
"../packages/**/node_modules/@types"
"../../../packages/js/**/node_modules/@types"
],
"baseUrl": "./",
"paths": {
"@woocommerce/*": [ "../packages/*/src" ],
"@woocommerce/*": [ "../../../packages/js/*/src" ],
"~/*": [ "./*" ]
},
"declaration": false,
@ -30,20 +30,20 @@
},
"exclude": [ "node_modules", "build", "build-module", "dist", "vendor" ],
"references": [
{ "path": "../packages/admin-e2e-tests" },
{ "path": "../packages/components" },
{ "path": "../packages/csv-export" },
{ "path": "../packages/currency" },
{ "path": "../packages/customer-effort-score" },
{ "path": "../packages/data" },
{ "path": "../packages/date" },
{ "path": "../packages/experimental" },
{ "path": "../packages/explat" },
{ "path": "../packages/js-tests" },
{ "path": "../packages/navigation" },
{ "path": "../packages/notices" },
{ "path": "../packages/number" },
{ "path": "../packages/onboarding" },
{ "path": "../packages/tracks" }
]
{ "path": "../../../packages/js/admin-e2e-tests" },
{ "path": "../../../packages/js/components" },
{ "path": "../../../packages/js/csv-export" },
{ "path": "../../../packages/js/currency" },
{ "path": "../../../packages/js/customer-effort-score" },
{ "path": "../../../packages/js/data" },
{ "path": "../../../packages/js/date" },
{ "path": "../../../packages/js/experimental" },
{ "path": "../../../packages/js/explat" },
{ "path": "../../../packages/js/js-tests" },
{ "path": "../../../packages/js/navigation" },
{ "path": "../../../packages/js/notices" },
{ "path": "../../../packages/js/number" },
{ "path": "../../../packages/js/onboarding" },
{ "path": "../../../packages/js/tracks" }
]
}

View File

@ -6,12 +6,16 @@ import { useEffect, useRef, useState, createElement } from '@wordpress/element';
import { Button, Card } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { EllipsisMenu } from '@woocommerce/components';
import { updateQueryString, getHistory, getNewPath } from '@woocommerce/navigation';
import {
updateQueryString,
getHistory,
getNewPath,
} from '@woocommerce/navigation';
import {
OPTIONS_STORE_NAME,
ONBOARDING_STORE_NAME,
TaskType,
useUserPreferences
useUserPreferences,
} from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { List, TaskItem } from '@woocommerce/experimental';

View File

@ -1,6 +1,6 @@
{
"name": "@woocommerce/admin-library",
"version": "3.4.0-dev",
"version": "3.3.0",
"homepage": "https://woocommerce.github.io/woocommerce-admin/",
"repository": {
"type": "git",
@ -46,13 +46,12 @@
"lint": "pnpm run lint:js && pnpm run lint:css",
"lint:css": "stylelint '**/*.scss'",
"lint:css-fix": "stylelint '**/*.scss' --fix --ip 'storybook/wordpress'",
"lint:js": "wp-scripts lint-js ../../packages/js ./client --ext=js,ts,tsx",
"lint:js": "wp-scripts lint-js ./client --ext=js,ts,tsx",
"lint:js:packages": "wp-scripts lint-js ../../packages/js --ext=js,ts,tsx",
"lint:js:client": "wp-scripts lint-js ./client --ext=js,ts,tsx",
"lint:js-fix": "pnpm run lint:js -- --fix --ext=js,ts,tsx",
"lint:php": "./vendor/bin/phpcs --standard=phpcs.xml.dist $(git ls-files | grep .php$)",
"lint:php-fix": "./vendor/bin/phpcbf --standard=phpcs.xml.dist $(git ls-files | grep .php$)",
"ts:check": "tsc --build ./tsconfig.json",
"ts:check": "tsc --build ./tsconfig.json --pretty",
"ts:check:watch": "npm run ts:check -- --watch",
"reformat-files": "wp-scripts format-js -- --ignore-path .eslintignore",
"prepack": "pnpm install && pnpm run lint && pnpm run test && cross-env WC_ADMIN_PHASE=core pnpm run build",
@ -236,6 +235,7 @@
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-react": "^7.29.2",
"expose-loader": "^3.1.0",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"fs-extra": "^8.1.0",
"grunt": "^1.4.1",

View File

@ -35,6 +35,12 @@
],
"parallel": true
}
},
"lint": {
"executor": "@nrwl/workspace:run-script",
"options": {
"script": "lint"
}
}
}
}

View File

@ -6,9 +6,9 @@ module.exports = {
},
stories: [
// WooCommerce Admin / @woocommerce/components components
'../../packages/components/src/**/stories/*.@(js|tsx)',
'../../../../packages/js/components/src/**/stories/*.@(js|tsx)',
// WooCommerce Admin / @woocommerce/experimental components
'../../packages/experimental/src/**/stories/*.@(js|tsx)',
'../../../../packages/js/experimental/src/**/stories/*.@(js|tsx)',
'../../client/**/stories/*.js',
],
addons: [

View File

@ -22,14 +22,32 @@ const wcAdminPackages = [
];
module.exports = ( storybookConfig ) => {
storybookConfig.module.rules.push( ...wcAdminWebpackConfig.module.rules );
storybookConfig.module.rules = [
...storybookConfig.module.rules,
...wcAdminWebpackConfig.module.rules,
// We need to expose packages in "peerDependencies" to the global scope for @woocommerce/* to resolve packages.
{
test: require.resolve( 'moment' ),
loader: 'expose-loader',
options: {
exposes: [ 'moment' ],
},
},
{
test: require.resolve( '@wordpress/data' ),
loader: 'expose-loader',
options: {
exposes: [ '_wp_data' ],
},
},
];
storybookConfig.resolve.alias = wcAdminWebpackConfig.resolve.alias;
wcAdminPackages.forEach( ( name ) => {
storybookConfig.resolve.alias[
`@woocommerce/${ name }`
] = path.resolve( __dirname, `../packages/${ name }/src` );
] = path.resolve( __dirname, `../../../packages/js/${ name }/src` );
} );
storybookConfig.resolve.alias[ '@woocommerce/settings' ] = path.resolve(
@ -53,14 +71,14 @@ module.exports = ( storybookConfig ) => {
{
from: path.resolve(
__dirname,
`../packages/components/build-style/*.css`
`../../../packages/js/components/build-style/*.css`
),
to: `./component-css/[name][ext]`,
},
{
from: path.resolve(
__dirname,
`../packages/experimental/build-style/*.css`
`../../../packages/js/experimental/build-style/*.css`
),
to: `./experimental-css/[name][ext]`,
},
@ -68,5 +86,10 @@ module.exports = ( storybookConfig ) => {
} )
);
storybookConfig.externals = {
'@wordpress/data': '_wp_data',
moment: 'moment',
};
return storybookConfig;
};

View File

@ -17,11 +17,11 @@
"typeRoots": [
"./typings",
"./node_modules/@types",
"packages/**/node_modules/@types"
"../../packages/js/**/node_modules/@types"
],
"baseUrl": "./",
"paths": {
"@woocommerce/*": [ "packages/*/src" ],
"@woocommerce/*": [ "../../packages/js/*/src" ],
"~/*": [ "client/*" ]
}
},
@ -29,20 +29,20 @@
"files": [],
"references": [
{ "path": "client/" },
{ "path": "packages/admin-e2e-tests" },
{ "path": "packages/components" },
{ "path": "packages/csv-export" },
{ "path": "packages/currency" },
{ "path": "packages/customer-effort-score" },
{ "path": "packages/data" },
{ "path": "packages/date" },
{ "path": "packages/experimental" },
{ "path": "packages/explat" },
{ "path": "packages/js-tests" },
{ "path": "packages/navigation" },
{ "path": "packages/notices" },
{ "path": "packages/number" },
{ "path": "packages/onboarding" },
{ "path": "packages/tracks" },
{ "path": "../../packages/js/admin-e2e-tests" },
{ "path": "../../packages/js/components" },
{ "path": "../../packages/js/csv-export" },
{ "path": "../../packages/js/currency" },
{ "path": "../../packages/js/customer-effort-score" },
{ "path": "../../packages/js/data" },
{ "path": "../../packages/js/date" },
{ "path": "../../packages/js/experimental" },
{ "path": "../../packages/js/explat" },
{ "path": "../../packages/js/js-tests" },
{ "path": "../../packages/js/navigation" },
{ "path": "../../packages/js/notices" },
{ "path": "../../packages/js/number" },
{ "path": "../../packages/js/onboarding" },
{ "path": "../../packages/js/tracks" },
]
}

View File

@ -7,7 +7,7 @@
* Author URI: https://woocommerce.com/
* Text Domain: woocommerce-admin
* Domain Path: /languages
* Version: 3.4.0-dev
* Version: 3.3.0
* Requires at least: 5.6
* Requires PHP: 7.0
*

View File

@ -22,6 +22,7 @@ tests/cli/vendor
/tests/e2e/docker
/tests/e2e/screenshots
/tests/e2e/plugins
.phpunit.result.cache
# Packages
/packages/*

View File

@ -13,19 +13,20 @@
}
],
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-autoloader": "2.10.1",
"automattic/jetpack-constants": "1.5.1",
"composer/installers": "~1.7",
"maxmind-db/reader": "1.6.0",
"pelago/emogrifier": "3.1.0",
"composer/installers": "^1.9",
"maxmind-db/reader": "^1.11",
"pelago/emogrifier": "^6.0",
"psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.4.0",
"woocommerce/woocommerce-blocks": "7.2.0"
"woocommerce/woocommerce-blocks": "7.2.1"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"yoast/phpunit-polyfills": "^1.0",
"phpunit/phpunit": "7.5.20",
"automattic/jetpack-changelogger": "3.0.2"
},
"config": {
@ -37,7 +38,7 @@
},
"sort-packages": true,
"platform": {
"php": "7.0.33"
"php": "7.2"
},
"allow-plugins": {
"automattic/jetpack-autoloader": true,

File diff suppressed because it is too large Load Diff

View File

@ -44,8 +44,9 @@ class WC_DateTime extends DateTime {
/**
* Get UTC offset if set, or default to the DateTime object's offset.
*/
#[\ReturnTypeWillChange]
public function getOffset() {
return $this->utc_offset ? $this->utc_offset : parent::getOffset();
return $this->utc_offset ?: parent::getOffset();
}
/**
@ -54,6 +55,7 @@ class WC_DateTime extends DateTime {
* @param DateTimeZone $timezone DateTimeZone instance.
* @return DateTime
*/
#[\ReturnTypeWillChange]
public function setTimezone( $timezone ) {
$this->utc_offset = 0;
return parent::setTimezone( $timezone );
@ -65,6 +67,7 @@ class WC_DateTime extends DateTime {
* @since 3.0.0
* @return int
*/
#[\ReturnTypeWillChange]
public function getTimestamp() {
return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' );
}

View File

@ -47,6 +47,7 @@ class WC_Meta_Data implements JsonSerializable {
*
* @return object|array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return $this->get_data();
}

View File

@ -5,6 +5,10 @@
* @package WooCommerce\Emails
*/
use Pelago\Emogrifier\CssInliner;
use Pelago\Emogrifier\HtmlProcessor\CssToAttributeConverter;
use Pelago\Emogrifier\HtmlProcessor\HtmlPruner;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@ -559,18 +563,20 @@ class WC_Email extends WC_Settings_API {
wc_get_template( 'emails/email-styles.php' );
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean(), $this );
$emogrifier_class = 'Pelago\\Emogrifier';
$css_inliner_class = CssInliner::class;
if ( $this->supports_emogrifier() && class_exists( $emogrifier_class ) ) {
if ( $this->supports_emogrifier() && class_exists( $css_inliner_class ) ) {
try {
$emogrifier = new $emogrifier_class( $content, $css );
$css_inliner = CssInliner::fromHtml( $content )->inlineCss( $css );
do_action( 'woocommerce_emogrifier', $emogrifier, $this );
do_action( 'woocommerce_emogrifier', $css_inliner, $this );
$content = $emogrifier->emogrify();
$html_prune = \Pelago\Emogrifier\HtmlProcessor\HtmlPruner::fromHtml( $content );
$html_prune->removeElementsWithDisplayNone();
$content = $html_prune->render();
$dom_document = $css_inliner->getDomDocument();
HtmlPruner::fromDomDocument( $dom_document )->removeElementsWithDisplayNone();
$content = CssToAttributeConverter::fromDomDocument( $dom_document )
->convertCssToVisualAttributes()
->render();
} catch ( Exception $e ) {
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );

View File

@ -26,7 +26,7 @@ class Package {
*
* @var string
*/
const VERSION = '3.4.0-dev';
const VERSION = '3.3.0';
/**
* Package active.

View File

@ -155,9 +155,13 @@ class FeaturePlugin {
$this->define( 'WC_ADMIN_PLUGIN_FILE', WC_PLUGIN_FILE );
$this->define( 'WC_ADMIN_IMAGES_FOLDER_URL', plugins_url( 'assets/images', WC_PLUGIN_FILE ) );
// WARNING: Do not directly edit this version number constant.
// It is updated as part of the prebuild process from the package.json value.
$this->define( 'WC_ADMIN_VERSION_NUMBER', '3.4.0-dev' );
/**
* Define the current WC Admin version.
*
* @deprecated 3.3.0
* @var string
*/
define( 'WC_ADMIN_VERSION_NUMBER', '3.3.0' );
}
/**

View File

@ -21,7 +21,7 @@ class CustomOrdersTableController {
/**
* The name of the option for enabling the usage of the custom orders tables
*/
const CUSTOM_ORDERS_TABLE_USAGE_ENABLED_OPTION = 'woocommerce_custom_orders_table_enabled';
private const CUSTOM_ORDERS_TABLE_USAGE_ENABLED_OPTION = 'woocommerce_custom_orders_table_enabled';
/**
* The data store object to use.

View File

@ -15,7 +15,7 @@ class Definition extends BaseDefinition {
/**
* The standard method that we use for dependency injection.
*/
const INJECTION_METHOD = 'init';
public const INJECTION_METHOD = 'init';
/**
* Resolve a class using method injection instead of constructor injection.

View File

@ -31,7 +31,7 @@ defined( 'ABSPATH' ) || exit;
*/
class DataRegenerator {
const PRODUCTS_PER_GENERATION_STEP = 10;
public const PRODUCTS_PER_GENERATION_STEP = 10;
/**
* The data store to use.

View File

@ -18,10 +18,10 @@ class LookupDataStore {
* Types of updates to perform depending on the current changest
*/
const ACTION_NONE = 0;
const ACTION_INSERT = 1;
const ACTION_UPDATE_STOCK = 2;
const ACTION_DELETE = 3;
public const ACTION_NONE = 0;
public const ACTION_INSERT = 1;
public const ACTION_UPDATE_STOCK = 2;
public const ACTION_DELETE = 3;
/**
* The lookup table name.

View File

@ -9,6 +9,6 @@ use Exception;
* was performed.
*/
class ApprovedDirectoriesException extends Exception {
const INVALID_URL = 1;
const DB_ERROR = 2;
public const INVALID_URL = 1;
public const DB_ERROR = 2;
}

View File

@ -15,13 +15,13 @@ class Register {
/**
* Used to indicate the current mode.
*/
const MODES = array(
private const MODES = array(
self::MODE_DISABLED,
self::MODE_ENABLED,
);
const MODE_DISABLED = 'disabled';
const MODE_ENABLED = 'enabled';
public const MODE_DISABLED = 'disabled';
public const MODE_ENABLED = 'enabled';
/**
* Name of the option used to store the current mode. See self::MODES for a

View File

@ -16,17 +16,17 @@ class Synchronize {
/**
* Scheduled action hook used to facilitate scanning the product catalog for downloadable products.
*/
const SYNC_TASK = 'woocommerce_download_dir_sync';
public const SYNC_TASK = 'woocommerce_download_dir_sync';
/**
* The group under which synchronization tasks run (our standard 'woocommerce-db-updates' group).
*/
const SYNC_TASK_GROUP = 'woocommerce-db-updates';
public const SYNC_TASK_GROUP = 'woocommerce-db-updates';
/**
* Used to track progress throughout the sync process.
*/
const SYNC_TASK_PAGE = 'wc_product_download_dir_sync_page';
public const SYNC_TASK_PAGE = 'wc_product_download_dir_sync_page';
/**
* Used to record an estimation of progress on the current synchronization process. 0 means 0%,
@ -34,12 +34,12 @@ class Synchronize {
*
* @param int
*/
const SYNC_TASK_PROGRESS = 'wc_product_download_dir_sync_progress';
public const SYNC_TASK_PROGRESS = 'wc_product_download_dir_sync_progress';
/**
* Number of downloadable products to be processed in each atomic sync task.
*/
const SYNC_TASK_BATCH_SIZE = 20;
public const SYNC_TASK_BATCH_SIZE = 20;
/**
* WC Queue.

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body style="padding: 0;"><p class="text" style='color: #3c3c3c; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;'>Hello World!</p></body>
<body style="padding: 0;"><p class="text" style='color: #3c3c3c; font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;'>Hello World!</p></body>
</html>

View File

@ -21,7 +21,7 @@ class WC_API_Unit_Test_Case extends WC_Unit_Test_Case {
* @since 2.2
* @see WC_Unit_Test_Case::setUp()
*/
public function setUp() {
public function setUp(): void {
parent::setUp();

View File

@ -21,7 +21,7 @@ class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
global $wp_rest_server;
$wp_rest_server = new WP_Test_Spy_REST_Server();
@ -37,7 +37,7 @@ class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
/**
* Unset the server.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
global $wp_rest_server;
unset( $this->server );

View File

@ -62,7 +62,7 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
*
* @since 2.2
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
@ -90,7 +90,7 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
*
* @since 3.5.0
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
// Terms are deleted in WP_UnitTestCase::tearDownAfterClass, then e.g. Uncategorized product_cat is missing.
@ -328,6 +328,6 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
* @return bool mixed True if the value is of integer type, false otherwise.
*/
public static function assertIsInteger( $actual, $message = '' ) {
return self::assertInternalType( 'int', $actual, $message );
return self::assertIsInt( $actual, $message );
}
}

View File

@ -134,7 +134,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
/**
* @since 1.3.0
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
if ( ! self::$did_init ) {
self::init();
@ -146,7 +146,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
/**
* @since 1.3.1
*/
public static function tearDownAfterClass() {
public static function tearDownAfterClass(): void {
self::save_cache();
@ -158,7 +158,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
*
* @since 1.0.0
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
@ -176,7 +176,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
*
* @since 1.0.0
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();

View File

@ -13,7 +13,7 @@ class WC_Tests_Account_Permissions extends WC_Unit_Test_Case {
* Setup:
* 1. Set current user to zero to simulate not logged in state.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
wp_set_current_user( 0 );
}
@ -22,7 +22,7 @@ class WC_Tests_Account_Permissions extends WC_Unit_Test_Case {
* Teardown:
* 1. Set current user to 0 because we change current user in some tests.
*/
public function tearDown() {
public function tearDown(): void {
wp_set_current_user( 0 );
parent::tearDown();
}

View File

@ -13,7 +13,7 @@ class WC_Tests_Admin_Dashboard extends WC_Unit_Test_Case {
/**
* Set up for tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(
@ -28,7 +28,7 @@ class WC_Tests_Admin_Dashboard extends WC_Unit_Test_Case {
/**
* Tear down.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
remove_filter( 'rest_pre_dispatch', array( $this, 'mock_rest_responses' ), 10 );
}

View File

@ -16,7 +16,7 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/wc-admin-functions.php';
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/notes/class-wc-notes-run-db-update.php';
@ -25,7 +25,7 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
/**
* Clean up before each test.
*/
public function setUp() {
public function setUp(): void {
if ( ! WC()->is_wc_admin_active() ) {
$this->markTestSkipped( 'WC Admin is not active on WP versions < 5.3' );
return;

View File

@ -14,7 +14,7 @@ class WC_Tests_Admin_Report extends WC_Unit_Test_Case {
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
}

View File

@ -13,7 +13,7 @@ class WC_Tests_Report_Sales_By_Date extends WC_Unit_Test_Case {
/**
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-report-sales-by-date.php';
}

View File

@ -49,7 +49,7 @@ class WC_Tests_Attributes_Functions extends WC_Unit_Test_Case {
public function test_wc_create_attribute() {
// Test success.
$id = wc_create_attribute( array( 'name' => 'Brand' ) );
$this->assertInternalType( 'int', $id );
$this->assertIsInt( $id );
// Test failures.
$err = wc_create_attribute( array() );

View File

@ -13,7 +13,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* tearDown.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->cart->empty_cart();

View File

@ -12,7 +12,7 @@ class WC_Tests_Checkout extends WC_Unit_Test_Case {
/**
* TearDown.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->cart->empty_cart();
}
@ -20,7 +20,7 @@ class WC_Tests_Checkout extends WC_Unit_Test_Case {
/**
* Setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
WC()->cart->empty_cart();
}

View File

@ -26,7 +26,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
*
* @since 2.2
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->wc = WC();
}

View File

@ -20,7 +20,7 @@ class WC_Test_Admin_Post_Types extends WC_Unit_Test_Case {
/**
* Setup. Create a instance to use throughout.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->wc_cpt = new WC_Admin_Post_Types();
}

View File

@ -15,7 +15,7 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
/**
* Sets up the test class.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Set a valid address for the customer so shipping rates will calculate.
@ -27,7 +27,7 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
/**
* Cleans up after the test class.
*/
public function tearDown() {
public function tearDown(): void {
WC()->cart->empty_cart();
WC()->cart->remove_coupons();

Some files were not shown because too many files have changed in this diff Show More