]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Tweak ESLint rules.
authorXhmikosR <xhmikosr@gmail.com>
Thu, 27 Jul 2017 10:39:55 +0000 (13:39 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 22 Aug 2017 21:05:38 +0000 (00:05 +0300)
21 files changed:
assets/js/ie-emulation-modes-warning.js
js/.eslintrc.json
js/src/carousel.js
js/src/collapse.js
js/src/dropdown.js
js/src/modal.js
js/src/popover.js
js/src/scrollspy.js
js/src/tab.js
js/src/tooltip.js
js/src/util.js
js/tests/unit/alert.js
js/tests/unit/button.js
js/tests/unit/carousel.js
js/tests/unit/collapse.js
js/tests/unit/dropdown.js
js/tests/unit/modal.js
js/tests/unit/popover.js
js/tests/unit/scrollspy.js
js/tests/unit/tab.js
js/tests/unit/tooltip.js

index c8f0bcac50904ea3bc614a533daf793bb55eeb64..1b4716bf5ecb3b98ceb202cb084af2054a65eb4d 100644 (file)
@@ -27,7 +27,7 @@
     // IE JavaScript conditional compilation docs: https://msdn.microsoft.com/library/121hztk3%28v=vs.94%29.aspx
     // @cc_on docs: https://msdn.microsoft.com/library/8ka90k2e%28v=vs.94%29.aspx
     var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // eslint-disable-line no-new-func
-    if (jscriptVersion === undefined) {
+    if (typeof jscriptVersion === 'undefined') {
       return 11 // IE11+ not in emulation mode
     }
     if (jscriptVersion < 9) {
index 72029797a333af2d8121803ecd3d3316c192f690..fdca9c1dd2762fc1bebc2c88822463cd2a118f54 100644 (file)
@@ -14,9 +14,8 @@
   "rules": {
     // Possible Errors
     "no-await-in-loop": "error",
-    "no-compare-neg-zero": "error",
     "no-extra-parens": "error",
-    "no-prototype-builtins": "off",
+    "no-prototype-builtins": "error",
     "no-template-curly-in-string": "error",
     "valid-jsdoc": "error",
 
@@ -85,7 +84,6 @@
     "no-unused-expressions": "error",
     "no-useless-call": "error",
     "no-useless-concat": "error",
-    "no-useless-escape": "error",
     "no-useless-return": "off",
     "no-void": "error",
     "no-warning-comments": "off",
     "no-shadow": "off",
     "no-shadow-restricted-names": "error",
     "no-undef-init": "error",
-    "no-undefined": "off",
+    "no-undefined": "error",
     "no-use-before-define": "off",
 
     // Node.js and CommonJS
     "wrap-regex": "off",
 
     // ECMAScript 6
-    "arrow-body-style": "off",
+    "arrow-body-style": ["error", "as-needed"],
     "arrow-parens": "error",
     "arrow-spacing": "error",
     "generator-star-spacing": "error",
index 6bcf470f98fb08526e66294a70ff4907b0cc6db7..87366051903f59c49020c71be0b0dd35be1d921d 100644 (file)
@@ -443,7 +443,7 @@ const Carousel = (($) => {
         if (typeof config === 'number') {
           data.to(config)
         } else if (typeof action === 'string') {
-          if (data[action] === undefined) {
+          if (typeof data[action] === 'undefined') {
             throw new Error(`No method named "${action}"`)
           }
           data[action]()
index 2f00b98cb6fd4736e09a3112e3ec79033134a2ef..718630bd37918e17ae66ffe6abfb3f89e78fea01 100644 (file)
@@ -343,7 +343,7 @@ const Collapse = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index 5e792a527f977248996e9368353d08abcd60bffc..e1c48ac6e5a46f85a78e3098665bdb6da7d739dd 100644 (file)
@@ -204,7 +204,7 @@ const Dropdown = (($) => {
 
     _getConfig(config) {
       const elementData = $(this._element).data()
-      if (elementData.placement !== undefined) {
+      if (typeof elementData.placement !== 'undefined') {
         elementData.placement = AttachmentMap[elementData.placement.toUpperCase()]
       }
 
@@ -287,7 +287,7 @@ const Dropdown = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index 9f17fafc8f5a9f2b6aa7b7cdc24633cc7d71d6d0..d21a137fb6e3d0ca0af16cd08ee5cfc3d9fbfe32 100644 (file)
@@ -507,7 +507,7 @@ const Modal = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config](relatedTarget)
index 0e8953f771d486dc04ad79b786e71a327a225ffb..7639e3e2036894aa5ff1db412a1dc81badecd20a 100644 (file)
@@ -162,7 +162,7 @@ const Popover = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index b70b7e477e3c41d024da767fd2435b56d0d7ad1b..588f65298868b2a2e9c9043ad33158874b569bf1 100644 (file)
@@ -231,7 +231,7 @@ const ScrollSpy = (($) => {
       for (let i = this._offsets.length; i--;) {
         const isActiveTarget = this._activeTarget !== this._targets[i]
             && scrollTop >= this._offsets[i]
-            && (this._offsets[i + 1] === undefined ||
+            && (typeof this._offsets[i + 1] === 'undefined' ||
                 scrollTop < this._offsets[i + 1])
 
         if (isActiveTarget) {
@@ -246,6 +246,7 @@ const ScrollSpy = (($) => {
       this._clear()
 
       let queries = this._selector.split(',')
+      // eslint-disable-next-line arrow-body-style
       queries     = queries.map((selector) => {
         return `${selector}[data-target="${target}"],` +
                `${selector}[href="${target}"]`
@@ -287,7 +288,7 @@ const ScrollSpy = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index 4c3091495112084f95e09a424b9f045793767b7c..c32cd3776fff6a1044e700ef4d9da85c439e22fa 100644 (file)
@@ -238,7 +238,7 @@ const Tab = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index 2060cebbb94b3885f4919760cc258c9d0773db02..721f0448187412bad5169da9c3dac1542a4c10de 100644 (file)
@@ -698,7 +698,7 @@ const Tooltip = (($) => {
         }
 
         if (typeof config === 'string') {
-          if (data[config] === undefined) {
+          if (typeof data[config] === 'undefined') {
             throw new Error(`No method named "${config}"`)
           }
           data[config]()
index 387c7d2ed5d877490a952b7cf04eefd926993f17..69fb8283cc03d5b2ae165a2d3df864af68fb7174 100644 (file)
@@ -42,7 +42,7 @@ const Util = (($) => {
         if ($(event.target).is(this)) {
           return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
         }
-        return undefined
+        return undefined // eslint-disable-line no-undefined
       }
     }
   }
@@ -55,7 +55,7 @@ const Util = (($) => {
     const el = document.createElement('bootstrap')
 
     for (const name in TransitionEndEvent) {
-      if (el.style[name] !== undefined) {
+      if (typeof el.style[name] !== 'undefined') {
         return {
           end: TransitionEndEvent[name]
         }
@@ -138,7 +138,7 @@ const Util = (($) => {
 
     typeCheckConfig(componentName, config, configTypes) {
       for (const property in configTypes) {
-        if (configTypes.hasOwnProperty(property)) {
+        if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
           const expectedTypes = configTypes[property]
           const value         = config[property]
           const valueType     = value && isElement(value) ?
index e078082c3c87e36c0d6e802308d08a91599f8d0d..aee2b70d5fa9e4098e1cb405a75ef6ac87fb887d 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.alert, 'undefined', 'alert was set back to undefined (org value)')
   })
 
   QUnit.test('should return jquery collection containing the element', function (assert) {
index 489d400a6ce7bd08101d82c9af7057f679ad1ceb..e2a51bb4d48b1cf0047561d127980a806595b274 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.button, undefined, 'button was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.button, 'undefined', 'button was set back to undefined (org value)')
   })
 
   QUnit.test('should return jquery collection containing the element', function (assert) {
index b110fbd65d1c192f453071a8717e33cab85dd82c..521b24ca45a54b0cc754cdd7b757c5369b2bbff2 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)')
+    assert.strictEqual(typeof $.fn.carousel, 'undefined', 'carousel was set back to undefined (orig value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
@@ -371,14 +371,14 @@ $(function () {
     var done = assert.async()
     $(template)
       .on('slid.bs.carousel', function (e) {
-        assert.ok(e.from !== undefined, 'from present')
-        assert.ok(e.to !== undefined, 'to present')
+        assert.ok(typeof e.from !== 'undefined', 'from present')
+        assert.ok(typeof e.to !== 'undefined', 'to present')
         $(this).off()
         done()
       })
       .on('slide.bs.carousel', function (e) {
-        assert.ok(e.from !== undefined, 'from present')
-        assert.ok(e.to !== undefined, 'to present')
+        assert.ok(typeof e.from !== 'undefined', 'from present')
+        assert.ok(typeof e.to !== 'undefined', 'to present')
         $(this).off('slide.bs.carousel')
       })
       .bootstrapCarousel('next')
index 0e9e8b6a73dd6b43852f51d62740a1443b303a7a..4470a18c2792d87f71fdab0b59dd69d8ae5c3190 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.collapse, 'undefined', 'collapse was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
index e44e47bbcb998f7e72ee5cf6478a9e74d5edeead..0b808cc4877a267a92144d0b0466b105361bdccf 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.dropdown, 'undefined', 'dropdown was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
@@ -644,7 +644,7 @@ $(function () {
     $triggerDropdown
       .parent('.dropdown')
       .on('shown.bs.dropdown', function () {
-        assert.ok($dropdownMenu.attr('style') === undefined, 'No inline style applied by Popper.js')
+        assert.ok(typeof $dropdownMenu.attr('style') === 'undefined', 'No inline style applied by Popper.js')
         done()
       })
     $triggerDropdown.trigger($.Event('click'))
index fc6c4f38c7c66294999ea1d8c45e58979dabfe54..09c3524434dd8b1c857572e5058de1bbf6fe269b 100644 (file)
@@ -34,7 +34,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)')
+    assert.strictEqual(typeof $.fn.modal, 'undefined', 'modal was set back to undefined (orig value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
@@ -380,7 +380,7 @@ $(function () {
 
     $('<div id="modal-test"/>')
       .on('hidden.bs.modal', function () {
-        assert.strictEqual($body.data('padding-right'), undefined, 'data-padding-right should be cleared after closing')
+        assert.strictEqual(typeof $body.data('padding-right'), 'undefined', 'data-padding-right should be cleared after closing')
         $body.removeAttr('style')
         done()
       })
@@ -422,7 +422,7 @@ $(function () {
 
     $('<div id="modal-test"/>')
       .on('hidden.bs.modal', function () {
-        assert.strictEqual($element.data('padding-right'), undefined, 'data-padding-right should be cleared after closing')
+        assert.strictEqual(typeof $element.data('padding-right'), 'undefined', 'data-padding-right should be cleared after closing')
         $element.remove()
         done()
       })
@@ -464,7 +464,7 @@ $(function () {
 
     $('<div id="modal-test"/>')
       .on('hidden.bs.modal', function () {
-        assert.strictEqual($element.data('margin-right'), undefined, 'data-margin-right should be cleared after closing')
+        assert.strictEqual(typeof $element.data('margin-right'), 'undefined', 'data-margin-right should be cleared after closing')
         $element.remove()
         done()
       })
index f9c1b429dd3d4251532517a99cd0344ff164aec5..a06c1b1a2e8932bc02305a6668ce4f5be71c4aa2 100644 (file)
@@ -22,7 +22,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.popover, 'undefined', 'popover was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
@@ -304,7 +304,7 @@ $(function () {
         assert.ok(false, 'should not fire any popover events')
       })
       .bootstrapPopover('hide')
-    assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
+    assert.strictEqual(typeof $popover.data('bs.popover'), 'undefined', 'should not initialize the popover')
   })
 
   QUnit.test('should fire inserted event', function (assert) {
index a6a72e7a6784985ca76e4e3c85a041aa36b4de49..96cf54eef0981b05ae54b2cd6722801ced9c96e8 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.scrollspy, undefined, 'scrollspy was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.scrollspy, 'undefined', 'scrollspy was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
index 6f52e4042f5ca369c1e5375f8c3b6bd16bf2527f..3093299b017d68e03407b94e5e7e7533ed57252e 100644 (file)
@@ -21,7 +21,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.tab, undefined, 'tab was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.tab, 'undefined', 'tab was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
index c0cafefe5128ace2e0cc8d7bf8a42553b93fc0b7..89d5b70e8b9db51861b11738877af4d8a4a952bf 100644 (file)
@@ -22,7 +22,7 @@ $(function () {
 
   QUnit.test('should provide no conflict', function (assert) {
     assert.expect(1)
-    assert.strictEqual($.fn.tooltip, undefined, 'tooltip was set back to undefined (org value)')
+    assert.strictEqual(typeof $.fn.tooltip, 'undefined', 'tooltip was set back to undefined (org value)')
   })
 
   QUnit.test('should throw explicit error on undefined method', function (assert) {
@@ -382,7 +382,7 @@ $(function () {
       .on('inserted.bs.tooltip', function () {
         var $tooltip = $($(this).data('bs.tooltip').tip)
         assert.ok($tooltip.hasClass('bs-tooltip-right'))
-        assert.ok($tooltip.attr('style') === undefined)
+        assert.ok(typeof $tooltip.attr('style') === 'undefined')
         $styles.remove()
         done()
       })
@@ -701,7 +701,7 @@ $(function () {
         assert.ok(false, 'should not fire any tooltip events')
       })
       .bootstrapTooltip('hide')
-    assert.strictEqual($tooltip.data('bs.tooltip'), undefined, 'should not initialize the tooltip')
+    assert.strictEqual(typeof $tooltip.data('bs.tooltip'), 'undefined', 'should not initialize the tooltip')
   })
 
   QUnit.test('should not remove tooltip if multiple triggers are set and one is still active', function (assert) {