Skip to content

Commit a85b4b6

Browse files
authored
Update to eslint 8 (#2570)
1 parent 907b8e5 commit a85b4b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+22131
-10619
lines changed

.eslintrc

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
2-
"parser": "babel-eslint",
2+
"parser": "@babel/eslint-parser",
3+
"parserOptions": {
4+
"requireConfigFile": false,
5+
"babelOptions": {
6+
"presets": [
7+
"@babel/preset-env"
8+
]
9+
}
10+
},
311
"rules": {
412
"indent": [
513
2,
@@ -24,15 +32,39 @@
2432
"prefer-destructuring": 0,
2533
"import/no-named-as-default": 0,
2634
"import/no-named-as-default-member": 0,
27-
"import/prefer-default-export": "off"
35+
"import/prefer-default-export": "off",
36+
"no-tabs": "warn",
37+
"no-mixed-spaces-and-tabs": "warn",
38+
"import/order": "warn"
2839
},
40+
"overrides": [
41+
{
42+
"files": [
43+
"**/*.spec.js"
44+
],
45+
"rules": {
46+
"no-multi-str": "warn"
47+
}
48+
},
49+
{
50+
"files": [
51+
"assets/js/theme/*.js"
52+
],
53+
"rules": {
54+
"object-curly-newline": "warn",
55+
"no-else-return": "warn"
56+
}
57+
}
58+
],
2959
"globals": {
3060
"$": true,
3161
"jQuery": true
3262
},
3363
"env": {
3464
"es6": true,
35-
"browser": true
65+
"browser": true,
66+
"jasmine": true,
67+
"jest": true
3668
},
3769
"extends": "airbnb/base"
3870
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
- Add net-new "order.pickup_addresses" to unify objects used on Order Details and Order Invoice pages [#2557](https://github.com/bigcommerce/cornerstone/pull/2557)
99
- Removed banner widget configuration and related translations [#2561](https://github.com/bigcommerce/cornerstone/pull/2561)
1010
- Add support for shipping discounts in "order.total_rows" for use on the Order Details and Order Invoice pages [#2568](https://github.com/bigcommerce/cornerstone/pull/2568)
11+
- Updates eslint to v8 [#2570](https://github.com/bigcommerce/cornerstone/pull/2570)
1112

1213
## 6.16.2 (06-18-2025)
1314
- Restore indentation and quote rules to match BC Sass Style Guide [#2554](https://github.com/bigcommerce/cornerstone/pull/2554)

assets/js/test-unit/theme/carousel.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import $ from 'jquery';
12
import carousel from '../../theme/common/carousel';
2-
import $ from 'jquery'
33
import 'slick-carousel';
44

55
describe('carousel', () => {
6-
it('should generate carousel WITH dots if carousel has more than one slide', () => {
7-
var multipleSlidesElement = $("<section class='heroCarousel' data-slick='{}'>\
6+
it('should generate carousel WITH dots if carousel has more than one slide', () => {
7+
const multipleSlidesElement = $("<section class='heroCarousel' data-slick='{}'>\
88
<a href=''>\
99
<div class='heroCarousel-slide heroCarousel-slide--first'>\
1010
<div class='heroCarousel-image-wrapper' style='height: 42.868654311039485vw'>\
@@ -24,21 +24,21 @@ describe('carousel', () => {
2424
</div>\
2525
</div>\
2626
</a>\
27-
</section>")
27+
</section>");
2828

2929
spyOn(jQuery.fn, 'find').and.returnValue(multipleSlidesElement);
30-
var slickSpy = spyOn(multipleSlidesElement, 'slick');
30+
const slickSpy = spyOn(multipleSlidesElement, 'slick');
3131
carousel();
3232
expect(slickSpy).toHaveBeenCalledWith({
3333
accessibility: false,
3434
arrows: true,
3535
customPaging: expect.any(Function),
3636
dots: true,
37-
});
37+
});
3838
});
3939

40-
it('should generate carousel WITHOUT dots if carousel has one slide', () => {
41-
var multipleSlidesElement = $("<section class='heroCarousel' data-slick='{}'>\
40+
it('should generate carousel WITHOUT dots if carousel has one slide', () => {
41+
const multipleSlidesElement = $("<section class='heroCarousel' data-slick='{}'>\
4242
<a href=''>\
4343
<div class='heroCarousel-slide heroCarousel-slide--first'>\
4444
<div class='heroCarousel-image-wrapper' style='height: 42.868654311039485vw'>\
@@ -51,16 +51,16 @@ describe('carousel', () => {
5151
</div>\
5252
</div>\
5353
</a>\
54-
</section>")
54+
</section>");
5555

5656
spyOn(jQuery.fn, 'find').and.returnValue(multipleSlidesElement);
57-
var slickSpy = spyOn(multipleSlidesElement, 'slick');
57+
const slickSpy = spyOn(multipleSlidesElement, 'slick');
5858
carousel();
5959
expect(slickSpy).toHaveBeenCalledWith({
6060
accessibility: false,
6161
arrows: false,
6262
customPaging: expect.any(Function),
63-
dots: false,
64-
});
63+
dots: false,
64+
});
6565
});
6666
});

assets/js/test-unit/theme/cart.spec.js

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import $ from 'jquery'
1+
import $ from 'jquery';
22
import utils from '@bigcommerce/stencil-utils';
3-
import Cart from '../../theme/cart.js';
3+
import Cart from '../../theme/cart';
44

5-
var dataSpy;
6-
var UpdateSpy;
7-
var c = new Cart();
5+
let dataSpy;
6+
let UpdateSpy;
7+
const c = new Cart();
88
c.context = {
9-
shippingCountryErrorMessage: `The 'Country' field cannot be blank.`,
10-
shippingProvinceErrorMessage: `The 'State/Province' field cannot be blank.`,
9+
shippingCountryErrorMessage: 'The \'Country\' field cannot be blank.',
10+
shippingProvinceErrorMessage: 'The \'State/Province\' field cannot be blank.',
1111
};
12-
beforeEach(function() {
13-
UpdateSpy = spyOn(utils.api.cart, 'itemUpdate');
12+
beforeEach(() => {
13+
UpdateSpy = spyOn(utils.api.cart, 'itemUpdate');
1414

15-
dataSpy = function(requestedAction = null) {
16-
spyOn(jQuery.fn, 'data').and.callFake(function() {
17-
var param = arguments[0];
15+
dataSpy = function (requestedAction = null) {
16+
spyOn(jQuery.fn, 'data').and.callFake((...args) => {
17+
const param = args[0];
1818
switch (param) {
1919
case 'action':
2020
return requestedAction;
@@ -31,11 +31,11 @@ beforeEach(function() {
3131
default:
3232
return null;
3333
}
34-
})
35-
};
34+
});
35+
};
3636
});
3737

38-
var $dom = $('<table class="cart" data-cart-quantity="2">\
38+
const $dom = $('<table class="cart" data-cart-quantity="2">\
3939
<thead class="cart-header">\
4040
<tr>\
4141
<th class="cart-header-item" colspan="2">Item</th>\
@@ -90,37 +90,34 @@ var $dom = $('<table class="cart" data-cart-quantity="2">\
9090
</td>\
9191
</tr>\
9292
</tbody>\
93-
</table>')
93+
</table>');
9494

9595
c.onReady();
9696

9797
describe('cartUpdate', () => {
98-
it('should INCRIMENT qty', () => {
99-
dataSpy
100-
dataSpy('inc');
101-
spyOn(jQuery.fn, 'val').and.returnValue(2);
102-
c.cartUpdate($dom);
103-
104-
expect(UpdateSpy).toHaveBeenCalledWith('11111', 3, jasmine.any(Function));
105-
});
98+
it('should INCRIMENT qty', () => {
99+
dataSpy('inc');
100+
spyOn(jQuery.fn, 'val').and.returnValue(2);
101+
c.cartUpdate($dom);
106102

107-
it('should DECREMENT qty', () => {
108-
dataSpy
109-
dataSpy('dec');
110-
spyOn(jQuery.fn, 'val').and.returnValue(2);
111-
c.cartUpdate($dom);
112-
113-
expect(UpdateSpy).toHaveBeenCalledWith('11111', 1, jasmine.any(Function));
114-
});
103+
expect(UpdateSpy).toHaveBeenCalledWith('11111', 3, jasmine.any(Function));
104+
});
105+
106+
it('should DECREMENT qty', () => {
107+
dataSpy('dec');
108+
spyOn(jQuery.fn, 'val').and.returnValue(2);
109+
c.cartUpdate($dom);
110+
111+
expect(UpdateSpy).toHaveBeenCalledWith('11111', 1, jasmine.any(Function));
112+
});
115113
});
116114

117115
describe('cartUpdateQtyTextChange', () => {
118-
it('should CHANGE qty completly based on the cart-item-qty-input', () => {
119-
dataSpy
120-
dataSpy('manualQtyChange');
121-
spyOn(jQuery.fn, 'val').and.returnValue(5, 2);
122-
c.cartUpdateQtyTextChange($dom);
123-
124-
expect(UpdateSpy).toHaveBeenCalledWith('11111', 5, jasmine.any(Function));
125-
});
116+
it('should CHANGE qty completly based on the cart-item-qty-input', () => {
117+
dataSpy('manualQtyChange');
118+
spyOn(jQuery.fn, 'val').and.returnValue(5, 2);
119+
c.cartUpdateQtyTextChange($dom);
120+
121+
expect(UpdateSpy).toHaveBeenCalledWith('11111', 5, jasmine.any(Function));
122+
});
126123
});

assets/js/test-unit/theme/common/collapsible-group.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import $ from 'jquery';
12
import collapsibleGroupFactory from '../../../theme/common/collapsible-group';
23
import { CollapsibleEvents } from '../../../theme/common/collapsible';
3-
import $ from 'jquery';
4-
54

65
describe('CollapsibleGroup', () => {
76
let collapsibleGroup;
@@ -27,7 +26,7 @@ describe('CollapsibleGroup', () => {
2726
beforeEach(() => {
2827
collapsible = {
2928
close: jest.fn(),
30-
hasCollapsible: jest.fn()
29+
hasCollapsible: jest.fn(),
3130
};
3231
childCollapsible = {};
3332

@@ -51,15 +50,14 @@ describe('CollapsibleGroup', () => {
5150
});
5251
});
5352

54-
5553
describe('when a collapsible is closed', () => {
5654
let collapsible;
5755
let childCollapsible;
5856

5957
beforeEach(() => {
6058
collapsible = {
6159
close: jest.fn(),
62-
hasCollapsible: jest.fn()
60+
hasCollapsible: jest.fn(),
6361
};
6462
childCollapsible = {};
6563

assets/js/test-unit/theme/common/collapsible.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import collapsibleFactory, { CollapsibleEvents } from '../../../theme/common/collapsible';
21
import $ from 'jquery';
2+
import collapsibleFactory, { CollapsibleEvents } from '../../../theme/common/collapsible';
33

44
describe('Collapsible', () => {
55
let collapsible;

0 commit comments

Comments
 (0)