diff options
author | XhmikosR <xhmikosr@gmail.com> | 2017-07-27 13:39:55 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2017-08-23 00:05:38 +0300 |
commit | ef8c77d8dcebd13559a141e419d003c2d10cc5f3 (patch) | |
tree | fa0efba9d60de5570eeac2b7ae0262916d64401d /js | |
parent | 0492c3a4cd0aed19f46c5472a54ee8700c1a328e (diff) |
Tweak ESLint rules.
Diffstat (limited to 'js')
-rw-r--r-- | js/.eslintrc.json | 8 | ||||
-rw-r--r-- | js/src/carousel.js | 2 | ||||
-rw-r--r-- | js/src/collapse.js | 2 | ||||
-rw-r--r-- | js/src/dropdown.js | 4 | ||||
-rw-r--r-- | js/src/modal.js | 2 | ||||
-rw-r--r-- | js/src/popover.js | 2 | ||||
-rw-r--r-- | js/src/scrollspy.js | 5 | ||||
-rw-r--r-- | js/src/tab.js | 2 | ||||
-rw-r--r-- | js/src/tooltip.js | 2 | ||||
-rw-r--r-- | js/src/util.js | 6 | ||||
-rw-r--r-- | js/tests/unit/alert.js | 2 | ||||
-rw-r--r-- | js/tests/unit/button.js | 2 | ||||
-rw-r--r-- | js/tests/unit/carousel.js | 10 | ||||
-rw-r--r-- | js/tests/unit/collapse.js | 2 | ||||
-rw-r--r-- | js/tests/unit/dropdown.js | 4 | ||||
-rw-r--r-- | js/tests/unit/modal.js | 8 | ||||
-rw-r--r-- | js/tests/unit/popover.js | 4 | ||||
-rw-r--r-- | js/tests/unit/scrollspy.js | 2 | ||||
-rw-r--r-- | js/tests/unit/tab.js | 2 | ||||
-rw-r--r-- | js/tests/unit/tooltip.js | 6 |
20 files changed, 38 insertions, 39 deletions
diff --git a/js/.eslintrc.json b/js/.eslintrc.json index 72029797a3..fdca9c1dd2 100644 --- a/js/.eslintrc.json +++ b/js/.eslintrc.json @@ -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", @@ -108,7 +106,7 @@ "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 @@ -213,7 +211,7 @@ "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", diff --git a/js/src/carousel.js b/js/src/carousel.js index 6bcf470f98..8736605190 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -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]() diff --git a/js/src/collapse.js b/js/src/collapse.js index 2f00b98cb6..718630bd37 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -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]() diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 5e792a527f..e1c48ac6e5 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -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]() diff --git a/js/src/modal.js b/js/src/modal.js index 9f17fafc8f..d21a137fb6 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -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) diff --git a/js/src/popover.js b/js/src/popover.js index 0e8953f771..7639e3e203 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -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]() diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index b70b7e477e..588f652988 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -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]() diff --git a/js/src/tab.js b/js/src/tab.js index 4c30914951..c32cd3776f 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -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]() diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2060cebbb9..721f044818 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -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]() diff --git a/js/src/util.js b/js/src/util.js index 387c7d2ed5..69fb8283cc 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -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) ? diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index e078082c3c..aee2b70d5f 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -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) { diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 489d400a6c..e2a51bb4d4 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -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) { diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index b110fbd65d..521b24ca45 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -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') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 0e9e8b6a73..4470a18c27 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -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) { diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index e44e47bbcb..0b808cc487 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -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')) diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index fc6c4f38c7..09c3524434 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -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() }) diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index f9c1b429dd..a06c1b1a2e 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -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) { diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index a6a72e7a67..96cf54eef0 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -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) { diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 6f52e4042f..3093299b01 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -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) { diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index c0cafefe51..89d5b70e8b 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -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) { |