Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store: Fix ESLint errors in WCS, tests, lib, and components directories #24571

Merged
merged 4 commits into from
May 3, 2018

Conversation

justinshreve
Copy link
Contributor

See #24504.

This fixes the eslint issues in the following files:

  • client/extensions/woocommerce/components/bulk-select/index.js (2 err, 0 warn)
  • client/extensions/woocommerce/components/form-click-to-edit-input/index.js (2 err, 0 warn)
  • client/extensions/woocommerce/components/form-location-select/countries.js (2 err, 0 warn)
  • client/extensions/woocommerce/components/location-flag/index.js (1 err, 0 warn)
  • client/extensions/woocommerce/lib/generate-variations/test/index.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/data-layer/ui/products/index.js (3 err, 0 warn)
  • client/extensions/woocommerce/state/sites/payment-methods/test/reducer.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/sites/review-replies/test/handlers.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/sites/reviews/test/handlers.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/ui/payments/methods/test/selectors.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/ui/shipping/zones/locations/test/selectors.js (1 err, 0 warn)
  • client/extensions/woocommerce/state/ui/shipping/zones/methods/selectors.js (2 err, 0 warn)
  • client/extensions/woocommerce/woocommerce-services/views/label-settings/label-settings.js (1 err, 0 warn)
  • client/extensions/woocommerce/woocommerce-services/views/packages/edit-package.js (1 err, 0 warn)
  • client/extensions/woocommerce/woocommerce-services/views/shipping-label/label-item.js (3 err, 0 warn)
  • client/extensions/woocommerce/woocommerce-services/views/shipping-label/label-purchase-modal/address-step/suggestion.js (3 err, 0 warn)
  • client/extensions/woocommerce/woocommerce-services/views/shipping-label/label-purchase-modal/packages-step/list.js (2 err, 0 warn)

Some of these are around duplicate test descriptions, indentation, and buttons vs links. No functionality should be changed so testing can just be spot checking.

To Test:

  • Run tests npm run test-client client/extensions/woocommerce
  • Click around store. Specifically, I've touched the following pages (via components or selectors):
    • SKU Edit Component
    • Address Dialog (Country/State Selection)
    • Shipping zone & method dialogs
    • Product reviews & review replies
    • Label & package dialogs and flow

@justinshreve justinshreve added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Store labels Apr 30, 2018
@justinshreve justinshreve self-assigned this Apr 30, 2018
@justinshreve justinshreve requested a review from a team April 30, 2018 17:44
@matticbot
Copy link
Contributor

Copy link
Member

@ryelle ryelle left a comment

Choose a reason for hiding this comment

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

Just a few tweaks requested, but otherwise looks good 🙂

@@ -98,6 +98,20 @@ class FormCountrySelectFromApi extends Component {
}
}

const getLocationsListFromContinents = ( state, continents, siteId ) => {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the PR for it, but this should probably be moved to a selector in sites/data/locations, maybe called getContinentsWithCountries.

@@ -127,12 +127,15 @@ const overlayShippingZoneMethods = ( state, zone, siteId, extraEdits ) => {
enabled = getShippingZoneMethod( state, method._originalId, siteId ).enabled;
}

// Prettier formatting indents the schema line in a way eslint doesn't like.
Copy link
Member

Choose a reason for hiding this comment

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

Prettier seems to format it as following, which isn't super intuitive IMO but is valid for the linter. I think we should either update this comment, or use the prettier/eslint format

const defaultValues = startsWith( method.methodType, 'wc_services' )
	? getDefaultSettingsValues(
		getShippingMethodSchema( state, method.methodType, siteId ).formSchema
	)
	: {};

@@ -42,12 +43,13 @@ const PackageList = ( props ) => {
const onOpenClick = () => props.openPackage( orderId, siteId, pckgId );
return (
<div className="packages-step__list-item" key={ pckgId }>
<div
<Button
borderless
Copy link
Member

Choose a reason for hiding this comment

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

Now that this is a button, the contrast is a bit light:

screen shot 2018-05-01 at 1 15 37 pm

Can you use the $gray-text color for this?

@justinshreve justinshreve force-pushed the fix/eslint-store-wcs-test-comp branch from e1aabf7 to 749a1dc Compare May 2, 2018 15:02
@justinshreve
Copy link
Contributor Author

@ryelle Thanks for the review.

I updated the text color for the packages dialog. I also added a TODO to make that a proper selector which I can handle in a follow-up PR.

For the indent/linter one -- I've tried formatting that line a few different ways. Prettier keeps updating it on commit to:

		const defaultValues = startsWith( method.methodType, 'wc_services' )
			? getDefaultSettingsValues(
					getShippingMethodSchema( state, method.methodType, siteId ).formSchema
				)
			: {};

which is slightly different from what you pasted above.

The linter will complain "Expected indentation of 4 tabs but found 5" without disabling the line there. I've at least updated the comment to be a bit clearer.

@blowery
Copy link
Contributor

blowery commented May 2, 2018

@justinshreve I wonder if #24551 would help there at all.. /cc @jsnajdr

// https://github.com/Automattic/wp-calypso/pull/24571#discussion_r185268996
const getContinentsWithCountries = ( state, continents, siteId ) => {
const locationsList = [];
continents.forEach( continent => {
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be a map instead a forEach with pushes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! In this PR I'm just going to move it out of connect, but I plan on making this a proper selector + add some tests in a follow-up, so I can do some code cleanup there.

@blowery
Copy link
Contributor

blowery commented May 2, 2018

@justinshreve #24635 should help with the weird formatting cases.

@jsnajdr
Copy link
Member

jsnajdr commented May 2, 2018

I wonder if #24551 would help there at all.

The indenting of ternaries isn't a bug, it's a difference of opinion between Prettier and ESLint. The ESLint indent rule doesn't like what Prettier (intentionally) does, that's all. Prettier upgrade won't change that.

@blowery
Copy link
Contributor

blowery commented May 2, 2018

@jsnajdr #24635 should resolve that difference of opinion. :)

@ryelle
Copy link
Member

ryelle commented May 2, 2018

@justinshreve apparently I had a setting on in my editor that ran eslint --fix after formatting, so when I used Atom to format the file, it did so with the eslint indentation... but when I ran prettier from CLI it indents like you said. Sorry about any confusion from my comment 😣

Copy link
Contributor

@blowery blowery left a comment

Choose a reason for hiding this comment

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

LGTM!

@timmyc timmyc added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 2, 2018
@justinshreve justinshreve merged commit 1a1a65e into master May 3, 2018
@justinshreve justinshreve deleted the fix/eslint-store-wcs-test-comp branch May 3, 2018 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants