Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Update dependency rules to enforce order and WooCommerce dependencies #2775

Closed
wants to merge 3 commits into from

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Jun 24, 2020

This PR probably needs some debate due to the WooCommerce rule, but giving you the option :)

  • Uses codeframe formatter to improve output of linting errors
  • Adds a linting rule to ensure the order of dependencies is External, WooCommerce, Internal.
  • Adds a linting rule to enforce @woocommerce dependencies under their own section

I've updated one file to check the rules pass.

GitHub Desktop 2020-06-24 11-22-52

Closes #2052

Note: WooCommerce admin uses this structure in it's dependencies too.

@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 1.59 MB

ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 7.24 kB 0 B
build/active-filters.js 7.95 kB 0 B
build/all-products-frontend.js 41.3 kB 0 B
build/all-products.js 25 kB 0 B
build/all-reviews-legacy.js 9.29 kB 0 B
build/all-reviews.js 9.6 kB 0 B
build/attribute-filter-frontend.js 16.8 kB 0 B
build/attribute-filter.js 11.6 kB 0 B
build/block-error-boundary-legacy.js 775 B 0 B
build/block-error-boundary.js 775 B 0 B
build/blocks-legacy.js 2.92 kB 0 B
build/blocks.js 2.92 kB 0 B
build/cart-frontend.js 63.8 kB 0 B
build/cart.js 33.1 kB 0 B
build/checkout-frontend.js 80.4 kB 0 B
build/checkout.js 38.6 kB 0 B
build/custom-select-control-style-legacy.js 782 B 0 B
build/custom-select-control-style.js 783 B 0 B
build/editor-legacy-rtl.css 12.5 kB 0 B
build/editor-legacy.css 12.5 kB 0 B
build/editor-rtl.css 13.5 kB 0 B
build/editor.css 13.5 kB 0 B
build/featured-category-legacy.js 7.27 kB 0 B
build/featured-category.js 7.59 kB 0 B
build/featured-product-legacy.js 9.51 kB 0 B
build/featured-product.js 9.84 kB 0 B
build/handpicked-products-legacy.js 6.91 kB 0 B
build/handpicked-products.js 7.24 kB 0 B
build/price-filter-frontend.js 14.1 kB 0 B
build/price-filter.js 10.1 kB 0 B
build/product-best-sellers-legacy.js 6.99 kB 0 B
build/product-best-sellers.js 7.3 kB 0 B
build/product-categories-legacy.js 3.23 kB 0 B
build/product-categories.js 3.22 kB 0 B
build/product-category-legacy.js 7.91 kB 0 B
build/product-category.js 8.25 kB 0 B
build/product-list-style-legacy.js 775 B 0 B
build/product-new-legacy.js 7.15 kB 0 B
build/product-new.js 7.47 kB 0 B
build/product-on-sale-legacy.js 7.52 kB 0 B
build/product-on-sale.js 7.87 kB 0 B
build/product-search-legacy.js 3.14 kB 0 B
build/product-search.js 3.43 kB 0 B
build/product-tag-legacy.js 6.08 kB 0 B
build/product-tag.js 6.39 kB 0 B
build/product-top-rated-legacy.js 7.12 kB 0 B
build/product-top-rated.js 7.45 kB 0 B
build/products-by-attribute-legacy.js 7.88 kB 0 B
build/products-by-attribute.js 8.2 kB 0 B
build/reviews-by-category-legacy.js 11.3 kB 0 B
build/reviews-by-category.js 11.6 kB 0 B
build/reviews-by-product-legacy.js 12.8 kB 0 B
build/reviews-by-product.js 13.1 kB 0 B
build/reviews-frontend-legacy.js 8.16 kB 0 B
build/reviews-frontend.js 9.01 kB 0 B
build/single-product-frontend.js 44.1 kB 0 B
build/single-product.js 18.3 kB 0 B
build/snackbar-notice-style-legacy.js 778 B 0 B
build/snackbar-notice-style.js 779 B 0 B
build/spinner-style-legacy.js 772 B 0 B
build/spinner-style.js 772 B 0 B
build/style-legacy-rtl.css 5.56 kB 0 B
build/style-legacy.css 5.57 kB 0 B
build/style-rtl.css 17.9 kB 0 B
build/style.css 17.9 kB 0 B
build/vendors-legacy.js 367 kB 0 B
build/vendors-style-legacy-rtl.css 1.03 kB 0 B
build/vendors-style-legacy.css 1.03 kB 0 B
build/vendors-style-legacy.js 102 B 0 B
build/vendors-style-rtl.css 1.03 kB 0 B
build/vendors-style.css 1.03 kB 0 B
build/vendors-style.js 102 B 0 B
build/vendors.js 415 kB 0 B
build/wc-blocks-data.js 7.09 kB 0 B
build/wc-blocks-middleware.js 932 B 0 B
build/wc-blocks-registry.js 2.19 kB 0 B
build/wc-payment-method-cheque.js 794 B 0 B
build/wc-payment-method-paypal.js 830 B 0 B
build/wc-payment-method-stripe.js 11.9 kB 0 B
build/wc-settings.js 2.14 kB 0 B
build/wc-shared-context.js 1.51 kB 0 B

compressed-size-action

@nerrad
Copy link
Contributor

nerrad commented Jun 24, 2020

I still think external/woocommerce/internal is too many unnecessary groupings. But I care more about consistency across projects. Personally, I don't think we should make this decision isolated from other teams and it'd be worth a P2 to settle the question.

],
"*.js": [
"prettier --write",
"npm run lint:js"
"npm run lint:js -s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I don't think I've seen the -s flag before (nor see it defined in the cli args list)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd it worked... silent mode for npm to avoid all the error text added after the lint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh, so an npm flag (not eslint) 👍

@nerrad
Copy link
Contributor

nerrad commented Jun 25, 2020

I started an internal discussion on creating a @woocommerce/eslint-plugin package that will among other things import a variation of this custom rule (See p6q6po-aLM-p2).

We'll keep this pull open in the meantime as I will use some of the code here in the custom plugin (and we can repurpose the pull to pull from the package when it's published).

@nerrad
Copy link
Contributor

nerrad commented Jul 2, 2020

Just a heads up that I created a pull for adding a @woocommerce/eslint-plugin package that will supersede much of the work in here.

@mikejolley
Copy link
Member Author

Unassigning myself. This can be closed when that other change is made I presume.

@mikejolley mikejolley removed their assignment Jul 13, 2020
@senadir
Copy link
Member

senadir commented Jul 29, 2020

We can close this now that woocommerce/woocommerce-admin#4714 is merged.

@senadir senadir closed this Jul 29, 2020
@ralucaStan ralucaStan deleted the update/dependency-rules branch August 4, 2021 14:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review usage of imports and be consistent for external vs internal dependency sequence.
3 participants