Skip to content

Commit 0b08c6a

Browse files
authored
refactor: add more rules to ESLint config, fix warnings (#3801)
1 parent 0c0d5ea commit 0b08c6a

38 files changed

Lines changed: 136 additions & 151 deletions

‎.eslintrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"no-unused-expressions": "error",
8484
"no-useless-return": "error",
8585
"no-var": "error",
86+
"object-shorthand": ["error", "always"],
8687
"operator-assignment": ["error", "always"],
8788
"prefer-arrow-callback": ["error", { "allowNamedFunctions": false, "allowUnboundThis": false }],
8889
"prefer-const": ["error", { "ignoreReadBeforeAssign": true }],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class ComboBoxDropdown extends PolymerElement {
174174
_fireTouchAction(sourceEvent) {
175175
this.dispatchEvent(
176176
new CustomEvent('vaadin-overlay-touch-action', {
177-
detail: { sourceEvent: sourceEvent },
177+
detail: { sourceEvent },
178178
}),
179179
);
180180
}

‎packages/component-base/src/gestures.js‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ register({
567567
* @this {GestureRecognizer}
568568
* @return {void}
569569
*/
570-
reset: function () {
570+
reset() {
571571
untrackDocument(this.info);
572572
},
573573

@@ -576,7 +576,7 @@ register({
576576
* @param {MouseEvent} e
577577
* @return {void}
578578
*/
579-
mousedown: function (e) {
579+
mousedown(e) {
580580
if (!hasLeftMouseButton(e)) {
581581
return;
582582
}
@@ -604,7 +604,7 @@ register({
604604
* @param {TouchEvent} e
605605
* @return {void}
606606
*/
607-
touchstart: function (e) {
607+
touchstart(e) {
608608
downupFire('down', _findOriginalTarget(e), e.changedTouches[0], e);
609609
},
610610

@@ -613,7 +613,7 @@ register({
613613
* @param {TouchEvent} e
614614
* @return {void}
615615
*/
616-
touchend: function (e) {
616+
touchend(e) {
617617
downupFire('up', _findOriginalTarget(e), e.changedTouches[0], e);
618618
},
619619
});
@@ -633,8 +633,8 @@ function downupFire(type, target, event, preventer) {
633633
x: event.clientX,
634634
y: event.clientY,
635635
sourceEvent: event,
636-
preventer: preventer,
637-
prevent: function (e) {
636+
preventer,
637+
prevent(e) {
638638
return prevent(e);
639639
},
640640
});
@@ -657,7 +657,7 @@ register({
657657
started: false,
658658
moves: [],
659659
/** @this {GestureInfo} */
660-
addMove: function (move) {
660+
addMove(move) {
661661
if (this.moves.length > TRACK_LENGTH) {
662662
this.moves.shift();
663663
}
@@ -672,7 +672,7 @@ register({
672672
* @this {GestureRecognizer}
673673
* @return {void}
674674
*/
675-
reset: function () {
675+
reset() {
676676
this.info.state = 'start';
677677
this.info.started = false;
678678
this.info.moves = [];
@@ -687,7 +687,7 @@ register({
687687
* @param {MouseEvent} e
688688
* @return {void}
689689
*/
690-
mousedown: function (e) {
690+
mousedown(e) {
691691
if (!hasLeftMouseButton(e)) {
692692
return;
693693
}
@@ -704,7 +704,7 @@ register({
704704
// If and only if tracking, always prevent tap
705705
prevent('tap');
706706
}
707-
self.info.addMove({ x: x, y: y });
707+
self.info.addMove({ x, y });
708708
if (!hasLeftMouseButton(e)) {
709709
// Always fire "end"
710710
self.info.state = 'end';
@@ -735,7 +735,7 @@ register({
735735
* @param {TouchEvent} e
736736
* @return {void}
737737
*/
738-
touchstart: function (e) {
738+
touchstart(e) {
739739
const ct = e.changedTouches[0];
740740
this.info.x = ct.clientX;
741741
this.info.y = ct.clientY;
@@ -746,7 +746,7 @@ register({
746746
* @param {TouchEvent} e
747747
* @return {void}
748748
*/
749-
touchmove: function (e) {
749+
touchmove(e) {
750750
const t = _findOriginalTarget(e);
751751
const ct = e.changedTouches[0];
752752
const x = ct.clientX,
@@ -756,7 +756,7 @@ register({
756756
// If and only if tracking, always prevent tap
757757
prevent('tap');
758758
}
759-
this.info.addMove({ x: x, y: y });
759+
this.info.addMove({ x, y });
760760
trackFire(this.info, t, ct);
761761
this.info.state = 'track';
762762
this.info.started = true;
@@ -768,7 +768,7 @@ register({
768768
* @param {TouchEvent} e
769769
* @return {void}
770770
*/
771-
touchend: function (e) {
771+
touchend(e) {
772772
const t = _findOriginalTarget(e);
773773
const ct = e.changedTouches[0];
774774
// Only trackend if track was started and not aborted
@@ -823,12 +823,12 @@ function trackFire(info, target, touch) {
823823
state: info.state,
824824
x: touch.clientX,
825825
y: touch.clientY,
826-
dx: dx,
827-
dy: dy,
828-
ddx: ddx,
829-
ddy: ddy,
826+
dx,
827+
dy,
828+
ddx,
829+
ddy,
830830
sourceEvent: touch,
831-
hover: function () {
831+
hover() {
832832
return deepTargetFind(touch.clientX, touch.clientY);
833833
},
834834
});
@@ -852,7 +852,7 @@ register({
852852
* @this {GestureRecognizer}
853853
* @return {void}
854854
*/
855-
reset: function () {
855+
reset() {
856856
this.info.x = NaN;
857857
this.info.y = NaN;
858858
this.info.prevent = false;
@@ -863,7 +863,7 @@ register({
863863
* @param {MouseEvent} e
864864
* @return {void}
865865
*/
866-
mousedown: function (e) {
866+
mousedown(e) {
867867
if (hasLeftMouseButton(e)) {
868868
this.info.x = e.clientX;
869869
this.info.y = e.clientY;
@@ -875,7 +875,7 @@ register({
875875
* @param {MouseEvent} e
876876
* @return {void}
877877
*/
878-
click: function (e) {
878+
click(e) {
879879
if (hasLeftMouseButton(e)) {
880880
trackForward(this.info, e);
881881
}
@@ -886,7 +886,7 @@ register({
886886
* @param {TouchEvent} e
887887
* @return {void}
888888
*/
889-
touchstart: function (e) {
889+
touchstart(e) {
890890
const touch = e.changedTouches[0];
891891
this.info.x = touch.clientX;
892892
this.info.y = touch.clientY;
@@ -897,7 +897,7 @@ register({
897897
* @param {TouchEvent} e
898898
* @return {void}
899899
*/
900-
touchend: function (e) {
900+
touchend(e) {
901901
trackForward(this.info, e.changedTouches[0], e);
902902
},
903903
});
@@ -924,7 +924,7 @@ function trackForward(info, e, preventer) {
924924
x: e.clientX,
925925
y: e.clientY,
926926
sourceEvent: e,
927-
preventer: preventer,
927+
preventer,
928928
});
929929
}
930930
}

0 commit comments

Comments
 (0)