Skip to content

Commit

Permalink
Fix linting errors (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Berthe committed Apr 19, 2018
1 parent fc5dd03 commit 9f99da8
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 177 deletions.
12 changes: 8 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
"jest": true
},
"rules": {
"no-console": 0,
"node/shebang": 0,
"babel/no-invalid-this": 0,
"import/no-anonymous-default-export": 0,
"import/no-unresolved": ["error", {"ignore": ["^jquery"]}]
"import/no-unresolved": ["error", {"ignore": ["^jquery"]}],
"no-alert": 0,
"no-console": 0,
"no-new": 0,
"node/shebang": 0
},
"globals": {
"document": true,
"window": true,
"Shopify": true
"Shopify": true,
"theme": true
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"dependencies": {
"@shopify/theme-a11y": "^1.0.0-alpha.3",
"@shopify/theme-cart": "^1.0.0-alpha.3",
"@shopify/theme-currency": "^1.0.0-alpha.3",
"@shopify/theme-images": "^1.0.0-alpha.3",
"@shopify/theme-rte": "^1.0.0-alpha.3",
"@shopify/theme-sections": "^1.0.0-alpha.3",
"@shopify/theme-sections": "^1.0.0-alpha.4",
"@shopify/theme-variants": "^1.0.0-alpha.4",
"jquery": "^3.2.1",
"lazysizes": "^4.0.2",
"lodash-es": "^4.17.4",
Expand Down
26 changes: 13 additions & 13 deletions src/assets/scripts/sections/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import $ from 'jquery';
import Variants from '../slate/variants';
import images from '../slate/images';
import currency from '../slate/currency';
import Variants from '@shopify/theme-variants';
import images from '@shopify/theme-images';
import currency from '@shopify/theme-currency';

const selectors = {
addToCart: '[data-add-to-cart]',
Expand Down Expand Up @@ -39,9 +39,8 @@ export default function Product(container) {
return;
}

const sectionId = this.$container.attr('data-section-id');
this.productSingleObject = JSON.parse(
$(selectors.productJson, this.$container).html()
$(selectors.productJson, this.$container).html(),
);

const options = {
Expand All @@ -59,11 +58,11 @@ export default function Product(container) {

this.$container.on(
`variantChange${this.namespace}`,
this.updateAddToCartState.bind(this)
this.updateAddToCartState.bind(this),
);
this.$container.on(
`variantPriceChange${this.namespace}`,
this.updateProductPrices.bind(this)
this.updateProductPrices.bind(this),
);

if (this.$featuredImage.length > 0) {
Expand All @@ -72,12 +71,13 @@ export default function Product(container) {

this.$container.on(
`variantImageChange${this.namespace}`,
this.updateProductImage.bind(this)
this.updateProductImage.bind(this),
);
}
}

Product.prototype = $.extend({}, Product.prototype, {

/**
* Updates the DOM state of the add to cart button
*
Expand All @@ -92,7 +92,7 @@ Product.prototype = $.extend({}, Product.prototype, {
} else {
$(selectors.addToCart, this.$container).prop('disabled', true);
$(selectors.addToCartText, this.$container).html(
theme.strings.unavailable
theme.strings.unavailable,
);
$(selectors.priceWrapper, this.$container).addClass('hide');
return;
Expand All @@ -118,16 +118,16 @@ Product.prototype = $.extend({}, Product.prototype, {
const $comparePrice = $(selectors.comparePrice, this.$container);
const $compareEls = $comparePrice.add(
selectors.comparePriceText,
this.$container
this.$container,
);

$(selectors.productPrice, this.$container).html(
currency.formatMoney(variant.price, theme.moneyFormat)
currency.formatMoney(variant.price, theme.moneyFormat),
);

if (variant.compare_at_price > variant.price) {
$comparePrice.html(
currency.formatMoney(variant.compare_at_price, theme.moneyFormat)
currency.formatMoney(variant.compare_at_price, theme.moneyFormat),
);
$compareEls.removeClass('hide');
} else {
Expand All @@ -145,7 +145,7 @@ Product.prototype = $.extend({}, Product.prototype, {
const variant = evt.variant;
const sizedImgUrl = images.getSizedImageUrl(
variant.featured_image.src,
this.settings.imageSize
this.settings.imageSize,
);

this.$featuredImage.attr('src', sizedImgUrl);
Expand Down
6 changes: 4 additions & 2 deletions src/assets/scripts/templates/customers/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if ($newAddressForm.length) {
'AddressProvinceNew',
{
hideElement: 'AddressProvinceContainerNew',
}
},
);
}

Expand Down Expand Up @@ -50,7 +50,9 @@ if ($newAddressForm.length) {
const formId = $el.data('form-id');
const confirmMessage = $el.data('confirm-message');
if (
confirm(confirmMessage || 'Are you sure you wish to delete this address?')
window.confirm(
confirmMessage || 'Are you sure you wish to delete this address?',
)
) {
Shopify.postLink(`/account/addresses/${formId}`, {
parameters: {_method: 'delete'},
Expand Down
66 changes: 33 additions & 33 deletions src/assets/scripts/templates/customers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,52 @@

import $ from 'jquery';

const config = {
const selectors = {
recoverPasswordForm: '#RecoverPassword',
hideRecoverPasswordLink: '#HideRecoverPasswordLink',
};

if ($(config.recoverPasswordForm).length) {
checkUrlHash();
resetPasswordSuccess();
function onShowHidePasswordForm(evt) {
evt.preventDefault();
toggleRecoverPasswordForm();
}

$(config.recoverPasswordForm).on('click', onShowHidePasswordForm);
$(config.hideRecoverPasswordLink).on('click', onShowHidePasswordForm);
function checkUrlHash() {
const hash = window.location.hash;

function onShowHidePasswordForm(evt) {
evt.preventDefault();
// Allow deep linking to recover password form
if (hash === '#recover') {
toggleRecoverPasswordForm();
}
}

function checkUrlHash() {
const hash = window.location.hash;
/**
* Show/Hide recover password form
*/
function toggleRecoverPasswordForm() {
$('#RecoverPasswordForm').toggleClass('hide');
$('#CustomerLoginForm').toggleClass('hide');
}

// Allow deep linking to recover password form
if (hash === '#recover') {
toggleRecoverPasswordForm();
}
}
/**
* Show reset password success message
*/
function resetPasswordSuccess() {
const $formState = $('.reset-password-success');

/**
* Show/Hide recover password form
*/
function toggleRecoverPasswordForm() {
$('#RecoverPasswordForm').toggleClass('hide');
$('#CustomerLoginForm').toggleClass('hide');
// check if reset password form was successfully submited.
if (!$formState.length) {
return;
}

/**
* Show reset password success message
*/
function resetPasswordSuccess() {
const $formState = $('.reset-password-success');
// show success message
$('#ResetSuccess').removeClass('hide');
}

// check if reset password form was successfully submited.
if (!$formState.length) {
return;
}
if ($(selectors.recoverPasswordForm).length) {
checkUrlHash();
resetPasswordSuccess();

// show success message
$('#ResetSuccess').removeClass('hide');
}
$(selectors.recoverPasswordForm).on('click', onShowHidePasswordForm);
$(selectors.hideRecoverPasswordLink).on('click', onShowHidePasswordForm);
}
4 changes: 0 additions & 4 deletions src/assets/scripts/templates/gift_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const config = {
giftCardCode: '.giftcard__code',
};

const $qrCode = $(config.qrCode);

// new QRCode($qrCode[0], {
// text: $qrCode.attr('data-identifier'),
// width: 120,
Expand Down Expand Up @@ -43,5 +41,3 @@ function selectText(evt) {
selection.addRange(range);
}
}

console.log('hey');
32 changes: 21 additions & 11 deletions src/locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"404": {
"title": "404 Siden findes ikke",
"subtext_html": "Siden du leder efter findes ikke. Klik <a href=\"/collections/all\">her</a> for at fortsætte med at handle."
"subtext_html":
"Siden du leder efter findes ikke. Klik <a href=\"/collections/all\">her</a> for at fortsætte med at handle."
},
"password_page": {
"opening_soon": "Åbner Snart",
Expand All @@ -23,7 +24,8 @@
"signup_form_email_placeholder": "Din email",
"signup_form_submit": "Send",
"signup_form_success": "Vi sender dig en email lige inden vi åbner!",
"admin_link_html": "Ejer du denne butik? <a href=\"/admin\">Log ind her</a>",
"admin_link_html":
"Ejer du denne butik? <a href=\"/admin\">Log ind her</a>",
"password_link": "Åben ved brug af adgangskode",
"powered_by_shopify_html": "Denne butik vil blive drevet af {{ shopify }}"
},
Expand All @@ -38,7 +40,8 @@
}
},
"search": {
"no_results_html": "Din søgning for \"{{ terms }}\" fandt ikke nogle resultater.",
"no_results_html":
"Din søgning for \"{{ terms }}\" fandt ikke nogle resultater.",
"results_for_html": "Din søgning for \"{{ terms }}\" fandt følgende:",
"title": "Søg efter produkter på vores site",
"placeholder": "Søg på vores butik",
Expand All @@ -57,8 +60,10 @@
"email": "Email",
"message": "Besked",
"post": "Skriv kommentar",
"moderated": "Bemærk venligst at, kommentarer skal godkendes inden de vises",
"success_moderated": "Din kommentar er modtaget. Vi offentliggør den inden længe.",
"moderated":
"Bemærk venligst at, kommentarer skal godkendes inden de vises",
"success_moderated":
"Din kommentar er modtaget. Vi offentliggør den inden længe.",
"success": "Din kommentar er modtaget! Mange tak!",
"with_count": {
"one": "{{ count }} kommentar",
Expand All @@ -75,12 +80,14 @@
"remove": "Fjern",
"note": "Specielle instruktioner for sælger",
"subtotal": "Sub total",
"shipping_at_checkout": "Forsendelse og skatter bliver beregnet ved betaling",
"shipping_at_checkout":
"Forsendelse og skatter bliver beregnet ved betaling",
"update": "Opdater Kurv",
"checkout": "Gå til betaling",
"empty": "Din kurv er i øjeblikket tom.",
"cookies_required": "Slå cookies til for at bruge indkøbskurven",
"continue_browsing_html": "Fortsæt med at handle <a href=\"/collections/all\">her</a>.",
"continue_browsing_html":
"Fortsæt med at handle <a href=\"/collections/all\">her</a>.",
"item_quantity": "Produkt antal",
"savings": "Du sparer"
},
Expand All @@ -106,7 +113,8 @@
"phone": "Telefonnummer",
"message": "Besked",
"send": "Send",
"post_success": "Tak for din henvendelse. Vi vender tilbage hurtigst muligt"
"post_success":
"Tak for din henvendelse. Vi vender tilbage hurtigst muligt"
}
},
"customer": {
Expand Down Expand Up @@ -196,7 +204,8 @@
"submit": "Send",
"cancel": "Annuller",
"subtext": "Vil vil sende dig en email for at nulstille din adgangskode.",
"success": "Vi har sendt dig en email med et link hvor du kan opdatere din adgangskode."
"success":
"Vi har sendt dig en email med et link hvor du kan opdatere din adgangskode."
},
"reset_password": {
"title": "Nulstil din adgangskode",
Expand All @@ -219,7 +228,8 @@
"onboarding": {
"product_title": "Produkt Titel Eksempel",
"collection_title": "Samling Titel Eksempel",
"no_content": "Denne afdeling indeholder i øjeblikket ikke noget indhold. Tilføj indhold til denne afdeling ved at bruge sidebaren."
"no_content":
"Denne afdeling indeholder i øjeblikket ikke noget indhold. Tilføj indhold til denne afdeling ved at bruge sidebaren."
}
},
"layout": {
Expand Down Expand Up @@ -270,7 +280,7 @@
"initial_value": "Gavekortets værdi: {{ value }}"
}
},
"date_formats":{
"date_formats": {
"month_day_year": "%d. %B, %Y"
}
}
Loading

0 comments on commit 9f99da8

Please sign in to comment.