Browse Source

Upgrade ESLint and fix issues

Glen Cheney 3 months ago
parent
commit
4884e668d8

+ 28
- 2
.eslintrc.js View File

@@ -1,4 +1,30 @@
1 1
 module.exports = {
2
-  extends: '@odopod',
3
-};
2
+  extends: 'airbnb-base',
3
+  env: {
4
+    node: true,
5
+    browser: true,
6
+  },
7
+  rules: {
8
+    // We like _private methods and variables. It's easier to refactor code
9
+    // when you know other components shouldn't be using private methods + props.
10
+    'no-underscore-dangle': 'off',
11
+
12
+    // Prefer template is nice, but tedious for things like: width + 'px'
13
+    'prefer-template': 'off',
14
+
15
+    // Allow + and - in the same line.
16
+    'no-mixed-operators': 'off',
17
+
18
+    // Shadowing is a nice language feature. Naming is hard.
19
+    'no-shadow': 'off',
4 20
 
21
+    // Make inheritance annoying sometimes.
22
+    'class-methods-use-this': 'off',
23
+
24
+    // Allow `i++` in loops.
25
+    'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
26
+
27
+    // Allow reassigning properties of objects.
28
+    'no-param-reassign': ['error', { props: false }],
29
+  },
30
+};

+ 10
- 4
dist/shuffle.js View File

@@ -991,10 +991,16 @@
991 991
         // If column width is a string, treat is as a selector and search for the
992 992
         // sizer element within the outermost container
993 993
         if (typeof option === 'string') {
994
-          return this.element.querySelector(option); // Check for an element
995
-        } else if (option && option.nodeType && option.nodeType === 1) {
996
-          return option; // Check for jQuery object
997
-        } else if (option && option.jquery) {
994
+          return this.element.querySelector(option);
995
+        } // Check for an element
996
+
997
+
998
+        if (option && option.nodeType && option.nodeType === 1) {
999
+          return option;
1000
+        } // Check for jQuery object
1001
+
1002
+
1003
+        if (option && option.jquery) {
998 1004
           return option[0];
999 1005
         }
1000 1006
 

+ 1
- 1
dist/shuffle.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
dist/shuffle.min.js.map
File diff suppressed because it is too large
View File


+ 10
- 4
docs/dist/shuffle.js View File

@@ -991,10 +991,16 @@
991 991
         // If column width is a string, treat is as a selector and search for the
992 992
         // sizer element within the outermost container
993 993
         if (typeof option === 'string') {
994
-          return this.element.querySelector(option); // Check for an element
995
-        } else if (option && option.nodeType && option.nodeType === 1) {
996
-          return option; // Check for jQuery object
997
-        } else if (option && option.jquery) {
994
+          return this.element.querySelector(option);
995
+        } // Check for an element
996
+
997
+
998
+        if (option && option.nodeType && option.nodeType === 1) {
999
+          return option;
1000
+        } // Check for jQuery object
1001
+
1002
+
1003
+        if (option && option.jquery) {
998 1004
           return option[0];
999 1005
         }
1000 1006
 

+ 1
- 1
docs/dist/shuffle.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
docs/dist/shuffle.min.js.map
File diff suppressed because it is too large
View File


+ 3
- 2
package.json View File

@@ -51,13 +51,14 @@
51 51
   "devDependencies": {
52 52
     "@babel/core": "^7.1.6",
53 53
     "@babel/preset-env": "^7.1.6",
54
-    "@odopod/eslint-config": "^2.0.0",
55 54
     "autoprefixer": "^9.1.2",
56 55
     "chai": "^4.0.1",
57 56
     "chai-dom": "^1.7.0",
58 57
     "core-js": "^2.5.3",
59 58
     "cssnano": "^4.0.5",
60
-    "eslint": "^4.11.0",
59
+    "eslint": "^5.9.0",
60
+    "eslint-config-airbnb-base": "^13.1.0",
61
+    "eslint-plugin-import": "^2.14.0",
61 62
     "gulp": "^4.0.0",
62 63
     "gulp-mocha-phantomjs": "^0.12.2",
63 64
     "gulp-postcss": "^8.0.0",

+ 8
- 8
src/get-number-style.js View File

@@ -19,15 +19,15 @@ export default function getNumberStyle(
19 19
 
20 20
   // Support IE<=11 and W3C spec.
21 21
   if (!testComputedSize() && style === 'width') {
22
-    value += getNumber(styles.paddingLeft) +
23
-      getNumber(styles.paddingRight) +
24
-      getNumber(styles.borderLeftWidth) +
25
-      getNumber(styles.borderRightWidth);
22
+    value += getNumber(styles.paddingLeft)
23
+      + getNumber(styles.paddingRight)
24
+      + getNumber(styles.borderLeftWidth)
25
+      + getNumber(styles.borderRightWidth);
26 26
   } else if (!testComputedSize() && style === 'height') {
27
-    value += getNumber(styles.paddingTop) +
28
-      getNumber(styles.paddingBottom) +
29
-      getNumber(styles.borderTopWidth) +
30
-      getNumber(styles.borderBottomWidth);
27
+    value += getNumber(styles.paddingTop)
28
+      + getNumber(styles.paddingBottom)
29
+      + getNumber(styles.borderTopWidth)
30
+      + getNumber(styles.borderBottomWidth);
31 31
   }
32 32
 
33 33
   return value;

+ 2
- 2
src/rect.js View File

@@ -33,7 +33,7 @@ export default class Rect {
33 33
    */
34 34
   static intersects(a, b) {
35 35
     return (
36
-      a.left < b.left + b.width && b.left < a.left + a.width &&
37
-      a.top < b.top + b.height && b.top < a.top + a.height);
36
+      a.left < b.left + b.width && b.left < a.left + a.width
37
+      && a.top < b.top + b.height && b.top < a.top + a.height);
38 38
   }
39 39
 }

+ 12
- 10
src/shuffle.js View File

@@ -125,9 +125,9 @@ class Shuffle extends TinyEmitter {
125 125
    */
126 126
   _getResizeFunction() {
127 127
     const resizeFunction = this._handleResize.bind(this);
128
-    return this.options.throttle ?
129
-      this.options.throttle(resizeFunction, this.options.throttleTime) :
130
-      resizeFunction;
128
+    return this.options.throttle
129
+      ? this.options.throttle(resizeFunction, this.options.throttleTime)
130
+      : resizeFunction;
131 131
   }
132 132
 
133 133
   /**
@@ -141,13 +141,15 @@ class Shuffle extends TinyEmitter {
141 141
     // sizer element within the outermost container
142 142
     if (typeof option === 'string') {
143 143
       return this.element.querySelector(option);
144
+    }
144 145
 
145 146
     // Check for an element
146
-    } else if (option && option.nodeType && option.nodeType === 1) {
147
+    if (option && option.nodeType && option.nodeType === 1) {
147 148
       return option;
149
+    }
148 150
 
149 151
     // Check for jQuery object
150
-    } else if (option && option.jquery) {
152
+    if (option && option.jquery) {
151 153
       return option[0];
152 154
     }
153 155
 
@@ -245,9 +247,9 @@ class Shuffle extends TinyEmitter {
245 247
 
246 248
     // Check each element's data-groups attribute against the given category.
247 249
     const attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);
248
-    const keys = this.options.delimiter ?
249
-      attr.split(this.options.delimiter) :
250
-      JSON.parse(attr);
250
+    const keys = this.options.delimiter
251
+      ? attr.split(this.options.delimiter)
252
+      : JSON.parse(attr);
251 253
 
252 254
     function testCategory(category) {
253 255
       return keys.includes(category);
@@ -428,8 +430,8 @@ class Shuffle extends TinyEmitter {
428 430
     let calculatedColumns = (containerWidth + gutter) / columnWidth;
429 431
 
430 432
     // Widths given from getStyles are not precise enough...
431
-    if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) <
432
-        this.options.columnThreshold) {
433
+    if (Math.abs(Math.round(calculatedColumns) - calculatedColumns)
434
+        < this.options.columnThreshold) {
433 435
       // e.g. calculatedColumns = 11.998876
434 436
       calculatedColumns = Math.round(calculatedColumns);
435 437
     }

Loading…
Cancel
Save