Skip to content

Commit 7a16f0f

Browse files
authored
refactor: add more rules to ESLint config, fix warnings (#3728)
1 parent c20dc46 commit 7a16f0f

88 files changed

Lines changed: 281 additions & 300 deletions

File tree

Some content is hidden

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

‎.eslintrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"prefer-object-spread": "error",
8484
"prefer-rest-params": "error",
8585
"prefer-spread": "error",
86+
"prefer-template": "error",
8687
"space-in-parens": ["error", "never"],
8788
"spaced-comment": ["error", "always"]
8889
},

‎packages/app-layout/src/detect-ios-navbar.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function _detectIosNavbar() {
1313
const landscape = innerWidth > innerHeight;
1414
const clientHeight = document.documentElement.clientHeight;
1515
if (landscape && clientHeight > innerHeight) {
16-
document.documentElement.style.setProperty('--vaadin-viewport-offset-bottom', clientHeight - innerHeight + 'px');
16+
document.documentElement.style.setProperty('--vaadin-viewport-offset-bottom', `${clientHeight - innerHeight}px`);
1717
} else {
1818
document.documentElement.style.setProperty('--vaadin-viewport-offset-bottom', '');
1919
}

‎packages/app-layout/src/vaadin-app-layout.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,13 @@ class AppLayout extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElemen
588588
const navbarBottom = this.$.navbarBottom;
589589
const navbarBottomRect = navbarBottom.getBoundingClientRect();
590590

591-
this.style.setProperty('--_vaadin-app-layout-navbar-offset-size', navbarRect.height + 'px');
592-
this.style.setProperty('--_vaadin-app-layout-navbar-offset-size-bottom', navbarBottomRect.height + 'px');
591+
this.style.setProperty('--_vaadin-app-layout-navbar-offset-size', `${navbarRect.height}px`);
592+
this.style.setProperty('--_vaadin-app-layout-navbar-offset-size-bottom', `${navbarBottomRect.height}px`);
593593

594594
const drawer = this.$.drawer;
595595
const drawerRect = drawer.getBoundingClientRect();
596596

597-
this.style.setProperty('--_vaadin-app-layout-drawer-offset-size', drawerRect.width + 'px');
597+
this.style.setProperty('--_vaadin-app-layout-drawer-offset-size', `${drawerRect.width}px`);
598598
}
599599

600600
/** @protected */

‎packages/avatar-group/src/vaadin-avatar-group.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,19 +564,19 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement)
564564
const isRtl = this.getAttribute('dir') === 'rtl';
565565

566566
if (isRtl) {
567-
this._overlayElement.style.right = document.documentElement.clientWidth - btnRect.right + 'px';
567+
this._overlayElement.style.right = `${document.documentElement.clientWidth - btnRect.right}px`;
568568
} else {
569-
this._overlayElement.style.left = btnRect.left + 'px';
569+
this._overlayElement.style.left = `${btnRect.left}px`;
570570
}
571571

572572
if (bottomAlign) {
573573
this._overlayElement.setAttribute('bottom-aligned', '');
574574
this._overlayElement.style.removeProperty('top');
575-
this._overlayElement.style.bottom = viewportHeight - btnRect.top + 'px';
575+
this._overlayElement.style.bottom = `${viewportHeight - btnRect.top}px`;
576576
} else {
577577
this._overlayElement.removeAttribute('bottom-aligned');
578578
this._overlayElement.style.removeProperty('bottom');
579-
this._overlayElement.style.top = btnRect.bottom + 'px';
579+
this._overlayElement.style.top = `${btnRect.bottom}px`;
580580
}
581581
}
582582
}

‎packages/board/src/vaadin-board-row.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ class BoardRow extends ResizeMixin(ElementMixin(PolymerElement)) {
136136
}
137137
let flexBasis = (colSpan / colsInRow) * 100;
138138
flexBasis = flexBasis > 100 ? 100 : flexBasis;
139-
return flexBasis + '%';
139+
return `${flexBasis}%`;
140140
}
141141

142142
/** @private */
143143
_reportError() {
144144
const errorMessage = 'The column configuration is not valid; column count should add up to 3 or 4.';
145-
console.warn(errorMessage, 'check: \r\n' + this.outerHTML);
145+
console.warn(errorMessage, `check: \r\n${this.outerHTML}`);
146146
}
147147

148148
/**

‎packages/charts/src/vaadin-chart-series.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class ChartSeries extends PolymerElement {
434434

435435
/** @private */
436436
__showWarn(propertyName, acceptedValues) {
437-
console.warn('<vaadin-chart-series> Acceptable values for "' + propertyName + '" are ' + acceptedValues);
437+
console.warn(`<vaadin-chart-series> Acceptable values for "${propertyName}" are ${acceptedValues}`);
438438
}
439439
}
440440

‎packages/charts/src/vaadin-chart.js‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,10 @@ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
12331233
if (attr.indexOf('_fn_') === 0 && (typeof targetProperty === 'string' || targetProperty instanceof String)) {
12341234
try {
12351235
// eslint-disable-next-line no-eval
1236-
jsonConfiguration[attr.substr(4)] = eval('(' + targetProperty + ')');
1236+
jsonConfiguration[attr.substr(4)] = eval(`(${targetProperty})`);
12371237
} catch (e) {
12381238
// eslint-disable-next-line no-eval
1239-
jsonConfiguration[attr.substr(4)] = eval('(function(){' + targetProperty + '})');
1239+
jsonConfiguration[attr.substr(4)] = eval(`(function(){${targetProperty}})`);
12401240
}
12411241
delete jsonConfiguration[attr];
12421242
} else if (targetProperty instanceof Object) {
@@ -1353,12 +1353,11 @@ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
13531353

13541354
// Zoom out a bit to avoid clipping the chart's edge on paper
13551355
effectiveCss =
1356-
effectiveCss +
1357-
'body {' +
1358-
' -moz-transform: scale(0.9, 0.9);' + // Mozilla
1359-
' zoom: 0.9;' + // Others
1360-
' zoom: 90%;' + // Webkit
1361-
'}';
1356+
`${effectiveCss}body {` +
1357+
` -moz-transform: scale(0.9, 0.9);` + // Mozilla
1358+
` zoom: 0.9;` + // Others
1359+
` zoom: 90%;` + // Webkit
1360+
`}`;
13621361

13631362
this.tempBodyStyle = document.createElement('style');
13641363
this.tempBodyStyle.textContent = effectiveCss;
@@ -1789,7 +1788,7 @@ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
17891788

17901789
/** @private */
17911790
__showWarn(propertyName, acceptedValues) {
1792-
console.warn('<vaadin-chart> Acceptable values for "' + propertyName + '" are ' + acceptedValues);
1791+
console.warn(`<vaadin-chart> Acceptable values for "${propertyName}" are ${acceptedValues}`);
17931792
}
17941793

17951794
/** @private */

‎packages/combo-box/src/vaadin-combo-box-dropdown.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class ComboBoxDropdown extends PolymerElement {
285285
if (!this.positionTarget) {
286286
return;
287287
}
288-
const inputWidth = this.positionTarget.clientWidth + 'px';
288+
const inputWidth = `${this.positionTarget.clientWidth}px`;
289289
const propPrefix = `${this.__hostTagName}-overlay`;
290290
const customWidth = getComputedStyle(this).getPropertyValue(`--${propPrefix}-width`);
291291

‎packages/combo-box/test/dynamic-size.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('dynamic size change', () => {
1212
function dataProvider(params, callback) {
1313
const items = Array(...new Array(params.pageSize)).map((_, i) => {
1414
return {
15-
label: 'Item ' + (params.pageSize * params.page + i)
15+
label: `Item ${params.pageSize * params.page + i}`
1616
};
1717
});
1818

‎packages/combo-box/test/lazy-loading.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ describe('lazy loading', () => {
286286
});
287287

288288
it('should render all visible items after delayed response', (done) => {
289-
const items = [...Array(10)].map((_, i) => 'item ' + i);
289+
const items = [...Array(10)].map((_, i) => `item ${i}`);
290290
comboBox.dataProvider = (params, callback) => {
291291
setTimeout(() => {
292292
callback(items, 10);

0 commit comments

Comments
 (0)