* add typescript support
* Add type declarations for Cart and CartResponse interfaces
* make sure we’re resolving .ts files as well as .js files on imports
* add more types
* type the cart data store
* Apply suggestions from code review (implement .tsx in configs)
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
* remove global fetchMock declaration and directly import where used.
* rename type
* remove named action types and just infer by returning action creator values as const
* use interface instead of type
* rename
* renames
* create CartAction type as union of action creator returned types and implement in reducer
* remove unused imports
* refresh package-lock after rebase
* Add base TS config that projects will inherit from
* Add tsconfig for assets/js/data project
* Ignore TS error on cart store registration
We will address this in cooldown when we have time to investigate further
* Add tsc to build step to catch TypeScript errors
* add a separate command for tsc and tweak build command to use
* restore checkJs and allowJs values in config and remove ts check from build command
* Add ts:check-all command
* Add TypeScript checking workflows
* Change triggers for TypeScript workflow
* Use npm ci instead of npm install
* Remove ts:check-all from TypeScript workflow
* Remove TS Check GitHub workflow
* Remove type-defs dir from TS include, and remove ts:check-all script
We no longer need the ts:check-all script because ts:check will do this for us, the old ts:check did nothing and did not work.
* fix coupon loading issues
* include .ts files only from type-defs folder
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Improve nonce handling by rejecting previous nonces from cache
* use timestamp instead of previous nonce
* Switch back to time()
* Seconds not ms
* Add comment about the date code
* enable rules and add exceptions
The `import/no-unresolved` and `import/no-extraneous-dependencies` rules defaults are enabled and configuration for adding exceptions for both webpack config resolution and externals or indirect dependencies are added.
* woops forgot to commit eslint-import-plugin-webpack resolver dependency
* I guess node resolver needs installed too?
* remove default resolve (doesn’t seem to help with the GH action errors)
* change config to lowercase for node
* implement prettier config for importing wordpress/prettier config
* update packages
This updates @wordpress/scripts to latest version so we are using the latest `@wordpress/eslint-plugin` rules.
Also installs a new required dependency due to the above update.
* temporarily convert new rules to warnings to handle in followups.
* fix stylint configuration and temporarily block rule
Latest @wordpress/scripts update requires the `@wordpress/stylelint-config` package instead of the previous builtin configuration. So applies a fix needed from that change.
* update puppeteer dependency version
* package-lock update
* add you don’t need lodash eslint plugin
* handle lodash.omit eslint errors
- storybook and webpack config implementations were just ignored.
- shared/validation/index.js was converted to use ES6 destructuring to eliminate usage.
* remove lodash assign usage
* convert lodash isNan to Number.isNan
* ignore lodash.flatten lint error for now
* remove usage of lodash.isNil
* add exclusions for lodash rules in main eslintrc file rather than per file.
* convert eslint config to use @woocommerce/eslint-plugin
- removes unnecessary dependencies
- adds e2e-tests/specs to eslint ignore (they are automatically generated)
- turns off rules that will be handled in subsequent pulls (to avoid a mammoth changeset for review).
- NOTE: prettier config needs left in because of a bug with the existing version of `@wordpress/eslint-plugin` pulled in (fixed in https://github.com/WordPress/gutenberg/pull/25068) so I left the file for now.
* prettier fixes.
* remove obsolete plugin and fixes for eslint update
This branch brings an update to eslint which also changes some syntax with plugins. So this commit:
- fixes featuer-flag plugin syntax.
- removed obsolete dependency-group plugin (which is now in the `@woocommerce/eslint-plugin` configuration.
* add to-do comment
* fixes for test runs
- this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run.
* fixes for test runs
- this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run.
* include prettier alias as a dependency
This has to be done because prettier is installed with storybook and thus the alias setup in `@wordpress/scripts` is over-ridden by the storybook import.
* another attempt at e2e-test-fix
* add some debugging and temporarily just add one e2e config test for travis
* more debugging
* try installing full puppeteer and see if fixes
* fix package-lock?
* setupSettings separately from other fixture loading
* add debugging of files
* add another console.log (hopefully trigger travis)
* split out blockPage creation to it’s own as well
* fixed! remove debugging and re-enable travis configs for entire test suite
* fix config and rename e2e-tests to e2e
- fixes the failing product-search test
- tests/e2e-tests was redundant, I changed to `tests/e2e` (this follows a file pattern change made in woocommerce core as well).
* add todo for some eslint properties
* remove unnecessary early function execution
* revert earlier commit and remove duplicate call to createBlockPages
* Shown express payment methods in Cart block
* Fixes
* Create usePositionRelativeToViewport hook
* Typo
* Style fixes
* Remove footer push div
* Styling fixes
* Improve code clarity
* Split ExpressCheckoutFormControl into two components
* Rename visibilityObserver to referenceElement
* Replace 'useEffect' with 'useLayoutEffect'
* Add tests for usePositionRelativeToViewport
* Self-closing div
* Add explanatory comment
* Create a shim for IntersectionObserver
* Update express payment components class names
* Add todo comment to remove IntersectionObserver shim when we drop IE11 support
* Deregister core cart/checkout scripts and styles when rendering the blocks
* Fix regression: redirect to full cart when adding a product from empty cart
* Make it so it scrolls to the top
* Update assets/js/base/utils/legacy-events.js
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Add check for jQuery availability
* Listen to removed from cart event too
* Remove unnecessary useEffect dependency
* Remove jQuery event subscriptions on component unmount
* Fix tests
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* more setup configuration for rtl
* move default state for cart out of reducer
This also creates a file for default store states, it should make it easier to execute tests in various environments.
* Make sure there’s a default object for cart line item row
* set defaults for cartData
* add fetchMock as a global in eslint config
* add initial cart flow tests
This is just to get the ball rolling, the cart block needs more tests
* fix missing @wordpress/jest-console configs (because I overwrote the original configuration)
* update test because of change in branch
* switch import order
* add globals.d.ts file to declare globals we use.
This is a quick solution to prevent typescript linting warning about `fetchMock`. At some point we could also create a proper interface for it or import the types (if they exist) for the `jest-mock` package.
The new `globals.d.ts` file is excluded from published builds.
* Revert "Move blocks to stable flag (https://github.com/woocommerce/woocommerce-blocks/pull/2261)"
This reverts commit a005649ab8.
* migrate to number based gating
* add todo to watch feature flag
* remove flags from build
* change flag in travis
* load flag in right order
* expose flag to js
* simplify flag definition
* more feature flags
* wrap flag in check
* add helper functions
* add helpers in PHP
* fix typo in flag
* move php code to src/domain/package
* tweak if condition
* return flag to travis
* fix broken block name
* add docker files
* get tests to work
* remove irrelevant files
* change userAgent to chrome
* add woocommerce as a dep
* add jest to eslint
* remove eslintignore for tests
* undo travis chages till another PR
* remove local utils and call them directly from woocommerce
* update deps
* add setup files to run tests
* export default wp link
* wait for select before selecting
* remove travis db
* ignore e2e tests in unit testing
* add tests
* add docker commands
* always run composer
* Make it possible to import directly from '@woocommerce/e2e-tests/utils'
* remove installing woocommerce via composer.
* add more docker npm scripts
* add custom docker config for wp-cli
* add changes to docker-composer.yml
Includes reading environment variables from `.env`
* revert customizations to .travis.yml
* move main docker file for the wordpress container to bin
* fix travis config
* rename wp install for travis builds back to original name
* use a version of docker-compose that travis supports
* add minor change to try and force travis test run
* fix incorrect command
* copy composer lock from master
* only run phpcs on /src directory
* give time for host to spin up for e2e tests
* increase sleep for waiting on container
* make sure plugin is built before running tests
* sigh fix improper command usage
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
* introduce feature flags
* move config to webpack-helper
* remove package default
* add gating to frontendConfig and coreConfig
* add feature gating to PHP
* add flag to start command
* move code to Bootstrap.php
* remove flag from npm start
* add eslint rule
* add strict equal only rule
* update messages to use tokens
* update strictBinary to whitelistedFlag and add all tests
* update to correct messageId key
* add more tests
* highlight wrong flag
* Update dependencies order
* Create eslint WooCommerce plugin with dependency group rule
* Update WCPackageLocality definition so it only includes External and Internal
* Rename WPPackageLocality to WCPackageLocality
* Delete old typedef
* Add dependency injection container for blocks
* Add new Pacakge and Bootstrap classes.
- Bootstrap for bootstrapping the plugin.
- Package will replace `src/Package` and added as a dependency for any classes needing package info.
* Introduce AssetsDataRegistry for managing asset data
* refactor existing classes to use new DIC and Asset Data Registry
- this is the bare minimum needed to make this pull viable.
- further refactors will be done in more atomic smaller pulls for easier review.
* add new settings handling and export `@woocommerce/settings` as an alias to wc.wcSettings
- the export is exposed php side on the `wc-settings` handle.
* Remove unnecessary concatenation
* Fix typos and improve doc blocks
* fix php linting issue
* Use better escaping function.
* improve jsdoc spacing
* improve test assertion
* use fully qualified class names in bootstrap
* improve comment block to account for dynamic version string replace on build
* handle exceptions a bit differently
* correct dependency reference in webpack config
* remove blank lines
* fix doc block comment alignment
* Various doc/grammar/spacing fixes from code review.
Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>
* improve naming, documentation and logic of filter callbacks
While this is intended for sanitization/validation, the callback ultimately provides flexibility for filtering the value before returning or setting in state so `filter` is a better name for this.
* Install prettier
* Reformat all files
* Add prettier to precommit hook
* Update prettier settings to match Gutenberg code standards
* Reformat files with new settings
* Improve legibility in some line breaks
* Add initial work for Product Categories List block
* Add empty category toggle
* Add option to show list as a dropdown
* Fix console warnings
* Only show proptypes linter warning if the component declares proptypes
* Add frontend script to render the product categories
* Split wcSettings & wc_product_block_data globals so that the later can be used from the frontend
* Remove wp dependencies, these are added by the webpack script now
* Capture all "woo packages" into a separate script chunk
These require `wcSettings`, which can't be available on the frontend - but we do need vendors on the frontend.
* Rewrite component into a function
* Fix validation error on editor reload
* Add eslint configuration
* Run eslint auto-fixer to cover fixable issues
* Use wp.element’s component to prevent undefined React error
* Add products data global to eslint config
* Fix remaining eslint errors by hand
* Fix eslint errors in webpack
* Remove duplicate rule