Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Make codeclimate happiest code checked ever

dominik-zeglen2ab8aea00b5d
diff --git a/saleor/static/dashboard/js/components/async-form.js b/saleor/static/dashboard/js/components/async-form.js
index 1aa219003c..26d94a9338 100644
--- a/saleor/static/dashboard/js/components/async-form.js
+++ b/saleor/static/dashboard/js/components/async-form.js
@@ -1,3 +1,5 @@
+import {initSelects} from './utils';
+
export default $(document).on('submit', '.form-async', function (e) {
let that = this;
$.ajax({
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.js
index 39b6baa929..103de4a5e1 100644
--- a/saleor/static/dashboard/js/components/misc.js
+++ b/saleor/static/dashboard/js/components/misc.js
@@ -1,6 +1,6 @@
import SVGInjector from 'svg-injector-2';
-import {initSelects} from "./utils";
+import {initSelects} from './utils';
export default $(document).ready((e) => {
new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));
@@ -18,5 +18,4 @@ export default $(document).ready((e) => {
let target = $(this).parent();
window.location.href = target.data('action-go');
});
-
});
diff --git a/saleor/static/dashboard/js/components/modal.js b/saleor/static/dashboard/js/components/modal.js
index 5ff5b2d42b..6254728217 100644
--- a/saleor/static/dashboard/js/components/modal.js
+++ b/saleor/static/dashboard/js/components/modal.js
@@ -1,4 +1,4 @@
-import {initSelects} from "./utils";
+import {initSelects} from './utils';
export default $(document).ready((e) => {
$('body').on('click', '.modal-trigger-custom', function (e) {
diff --git a/saleor/static/dashboard/js/components/side-menu.js b/saleor/static/dashboard/js/components/side-menu.js
index 250718bc62..a73044cdb6 100644
--- a/saleor/static/dashboard/js/components/side-menu.js
+++ b/saleor/static/dashboard/js/components/side-menu.js
@@ -1,4 +1,4 @@
-import {onScroll} from "./utils";
+import {onScroll} from './utils';
export default $(document).ready((e) => {
let mainNavTop = $('.side-nav');
diff --git a/saleor/static/js/components/address-form.js b/saleor/static/js/components/address-form.js
index eb254c944a..3d61fd5d44 100644
--- a/saleor/static/js/components/address-form.js
+++ b/saleor/static/js/components/address-form.js
@@ -47,5 +47,4 @@ export default $(document).ready((e) => {
} else {
$addressForm.slideUp(0);
}
-
});
diff --git a/saleor/static/js/components/cart.js b/saleor/static/js/components/cart.js
index 7a2212b3a8..917c24c679 100644
--- a/saleor/static/js/components/cart.js
+++ b/saleor/static/js/components/cart.js
@@ -1,4 +1,4 @@
-import {getAjaxError} from "./misc";
+import {getAjaxError} from './misc';
export const summaryLink = '/cart/summary/';
export const $cartDropdown = $('.cart-dropdown');
@@ -81,8 +81,8 @@ export default $(document).ready((e) => {
method: 'POST',
data: {quantity: newQuantity},
success: (response) => {
- if (newQuantity == 0) {
- if (response.cart.numLines == 0) {
+ if (newQuantity === 0) {
+ if (response.cart.numLines === 0) {
$.cookie('alert', 'true', {path: '/cart'});
location.reload();
} else {
diff --git a/saleor/static/js/components/misc.js b/saleor/static/js/components/misc.js
index 7f6383ac40..9a4f8c96ef 100644
--- a/saleor/static/js/components/misc.js
+++ b/saleor/static/js/components/misc.js
@@ -1,5 +1,5 @@
import SVGInjector from 'svg-injector-2';
-import {$removeProductSuccess} from "./cart";
+import {$removeProductSuccess} from './cart';
export const getAjaxError = (response) => {
let ajaxError = $.parseJSON(response.responseText).error.quantity;
@@ -31,5 +31,4 @@ export default $(document).ready((e) => {
let hash = window.location.hash;
$('.nav-tabs a[href="' + hash + '"]').tab('show');
-
});
diff --git a/saleor/static/js/mobile/filters-menu.js b/saleor/static/js/components/mobile/filters-menu.js
similarity index 100%
rename from saleor/static/js/mobile/filters-menu.js
rename to saleor/static/js/components/mobile/filters-menu.js
diff --git a/saleor/static/js/mobile/navbar.js b/saleor/static/js/components/mobile/navbar.js
similarity index 100%
rename from saleor/static/js/mobile/navbar.js
rename to saleor/static/js/components/mobile/navbar.js
diff --git a/saleor/static/js/mobile/search.js b/saleor/static/js/components/mobile/search.js
similarity index 100%
rename from saleor/static/js/mobile/search.js
rename to saleor/static/js/components/mobile/search.js
diff --git a/saleor/static/js/components/password-input.js b/saleor/static/js/components/password-input.js
index e5e02c6e0f..51ae1e7e1e 100644
--- a/saleor/static/js/components/password-input.js
+++ b/saleor/static/js/components/password-input.js
@@ -3,11 +3,11 @@ import passwordVisible from '../../images/pass_visible.svg';
export default $(document).ready((e) => {
let $inputPassword = $('input[type=password]');
- $("<img class='passIcon' src=" + passwordIvisible + " />").insertAfter($inputPassword);
+ $('<img class="passIcon" src=' + passwordIvisible + ' />').insertAfter($inputPassword);
$inputPassword.parent().addClass('relative');
$('.passIcon').on('click', (e) => {
let $input = $(e.target).parent().find('input');
- if ($input.attr('type') == 'password') {
+ if ($input.attr('type') === 'password') {
$input.attr('type', 'text');
$(e.target).attr('src', passwordVisible);
} else {
diff --git a/saleor/static/js/components/sorter.js b/saleor/static/js/components/sorter.js
index 2c7b6c44c1..879edd5640 100644
--- a/saleor/static/js/components/sorter.js
+++ b/saleor/static/js/components/sorter.js
@@ -1,19 +1,19 @@
export default $(document).ready((e) => {
$(document).ready((e) => {
- $('.sort-by button').on('click', (e) => {
- const t = $(e.currentTarget).parent();
- const l = t.find('.sort-list');
- if (l.hasClass('d-none')) {
- l.removeClass('d-none');
- t.find('.click-area').removeClass('d-none');
- } else {
- l.addClass('d-none');
- t.find('.click-area').addClass('d-none');
- }
+ $('.sort-by button').on('click', (e) => {
+ const t = $(e.currentTarget).parent();
+ const l = t.find('.sort-list');
+ if (l.hasClass('d-none')) {
+ l.removeClass('d-none');
+ t.find('.click-area').removeClass('d-none');
+ } else {
+ l.addClass('d-none');
+ t.find('.click-area').addClass('d-none');
+ }
+ });
+ $('.sort-by .click-area').on('click', (e) => {
+ $('.sort-by .sort-list').addClass('d-none');
+ $(e.currentTarget).addClass('d-none');
+ });
});
- $('.sort-by .click-area').on('click', (e) => {
- $('.sort-by .sort-list').addClass('d-none');
- $(e.currentTarget).addClass('d-none');
- });
-});
});
diff --git a/saleor/static/js/components/styleguide.js b/saleor/static/js/components/styleguide.js
index 8f8333c75c..8f2e786207 100644
--- a/saleor/static/js/components/styleguide.js
+++ b/saleor/static/js/components/styleguide.js
@@ -2,9 +2,9 @@ export default $(document).ready(function () {
let styleGuideMenu = $('.styleguide__nav');
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
- styleGuideMenu.addClass("fixed");
+ styleGuideMenu.addClass('fixed');
} else {
- styleGuideMenu.removeClass("fixed");
+ styleGuideMenu.removeClass('fixed');
}
});
});
diff --git a/saleor/static/js/components/variant-picker.js b/saleor/static/js/components/variant-picker.js
index 304063fa2c..7864f1889e 100644
--- a/saleor/static/js/components/variant-picker.js
+++ b/saleor/static/js/components/variant-picker.js
@@ -5,7 +5,7 @@ import VariantPicker from './variantPicker/VariantPicker';
import VariantPrice from './variantPicker/VariantPrice';
import variantPickerStore from '../stores/variantPicker';
-import {onAddToCartSuccess, onAddToCartError} from "./cart";
+import {onAddToCartSuccess, onAddToCartError} from './cart';
export default $(document).ready((e) => {
const variantPickerContainer = document.getElementById('variant-picker');
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 7dfd4fa4b3..15bccab89e 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -1,8 +1,8 @@
import '../scss/storefront.scss';
-import './mobile/navbar';
-import './mobile/search';
-import './mobile/filters-menu';
+import './components/mobile/navbar';
+import './components/mobile/search';
+import './components/mobile/filters-menu';
import './components/cart';
import './components/sorter';
import './components/variant-picker';