From d5314850325146f928f4dc02e39e9fb6d9e573ab Mon Sep 17 00:00:00 2001 From: Chris LoPresto Date: Tue, 22 Dec 2015 17:52:11 -0500 Subject: [PATCH] Perform a big JSCS suave cleanup - Update to ember-suave 1.2.3 - Use default ember-suave jscs preset - Appease, appease, appease --- .jscsrc | 9 +--- addon/components/modal-dialog.js | 2 +- addon/components/positioned-container.js | 30 +++++++------ addon/components/tether-dialog.js | 2 +- package.json | 4 +- tests/acceptance/modal-dialog-test.js | 24 +++++----- tests/acceptance/tether-dialog-test.js | 22 +++++----- tests/dummy/app/app.js | 4 +- .../component-that-uses-modal-dialog.js | 4 +- tests/dummy/app/controllers/application.js | 44 +++++++++---------- .../register-subclassed-modals.js | 4 +- tests/dummy/app/router.js | 2 +- tests/helpers/modal-asserts.js | 16 +++---- tests/helpers/resolver.js | 2 +- tests/helpers/start-app.js | 4 +- 15 files changed, 85 insertions(+), 88 deletions(-) diff --git a/.jscsrc b/.jscsrc index 71bd3a23..e24512d0 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,10 +1,3 @@ { - "preset": "ember-suave", - "disallowVar": null, - "requireBlocksOnNewline": null, - "requireEnhancedObjectLiterals": null, - "requireObjectDestructuring": null, - "requireSpaceAfterBinaryOperators": null, - "requireSpaceBeforeBinaryOperators": null, - "requireTemplateStringsForConcatenation": null + "preset": "ember-suave" } diff --git a/addon/components/modal-dialog.js b/addon/components/modal-dialog.js index 54e5019a..a13f66cf 100644 --- a/addon/components/modal-dialog.js +++ b/addon/components/modal-dialog.js @@ -13,7 +13,7 @@ const computedJoin = function(prop) { export default Ember.Component.extend({ tagName: '', - layout: layout, + layout, modalService: inject.service('modal-dialog'), destinationElementId: oneWay('modalService.destinationElementId'), diff --git a/addon/components/positioned-container.js b/addon/components/positioned-container.js index 414134b2..3c9a6b6f 100644 --- a/addon/components/positioned-container.js +++ b/addon/components/positioned-container.js @@ -23,7 +23,9 @@ export default Ember.Component.extend({ }), didGetPositioned: observer('isPositioned', on('didInsertElement', function() { - if (this._state !== 'inDOM') { return; } + if (this._state !== 'inDOM') { + return; + } if (this.get('isPositioned')) { this.updateTargetAttachment(); @@ -32,9 +34,11 @@ export default Ember.Component.extend({ } })), - getWrappedTargetAttachmentElement: function() { + getWrappedTargetAttachmentElement() { const target = this.get('target'); - if (!target) { return null; } + if (!target) { + return null; + } if (Ember.typeOf(target) === 'string') { const targetSelector = target; @@ -52,7 +56,7 @@ export default Ember.Component.extend({ return Ember.$(target); }, - updateTargetAttachment: function() { + updateTargetAttachment() { let targetAttachment = this.get('targetAttachment'); // Convert tether-styled values like 'middle right' to 'right' targetAttachment = targetAttachment.split(' ').slice(-1)[0]; @@ -60,13 +64,13 @@ export default Ember.Component.extend({ `Positioned container supports targetAttachments of ${SUPPORTED_TARGET_ATTACHMENTS.join(', ')}`, SUPPORTED_TARGET_ATTACHMENTS.indexOf(targetAttachment) > -1 ); - const targetAttachmentMethod = 'align' + capitalize(targetAttachment); + const targetAttachmentMethod = `align${capitalize(targetAttachment)}`; const targetAttachmentElement = this.getWrappedTargetAttachmentElement(); this[targetAttachmentMethod](targetAttachmentElement); }, - alignCenter: function() { + alignCenter() { const elementWidth = this.$().outerWidth(); const elementHeight = this.$().outerHeight(); @@ -76,7 +80,7 @@ export default Ember.Component.extend({ .css('margin-top', elementHeight * -0.5); }, - alignLeft: function(targetAttachmentElement) { + alignLeft(targetAttachmentElement) { Ember.assert('Left targetAttachment requires a target', targetAttachmentElement.length > 0); const elementWidth = this.$().outerWidth(); @@ -87,7 +91,7 @@ export default Ember.Component.extend({ .css('top', originOffsetTop); }, - alignRight: function(targetAttachmentElement) { + alignRight(targetAttachmentElement) { Ember.assert('Right targetAttachment requires a target', targetAttachmentElement.length > 0); const targetWidth = targetAttachmentElement.outerWidth(); @@ -98,7 +102,7 @@ export default Ember.Component.extend({ .css('top', originOffsetTop); }, - alignTop: function(targetAttachmentElement) { + alignTop(targetAttachmentElement) { Ember.assert('Top targetAttachment requires a target', targetAttachmentElement.length > 0); const elementWidth = this.$().outerWidth(); @@ -107,11 +111,11 @@ export default Ember.Component.extend({ const originOffsetTop = originOffset.top - Ember.$(window).scrollTop(); const targetWidth = targetAttachmentElement.outerWidth(); - this.$().css('left', (originOffset.left + targetWidth/2 - elementWidth/2)) + this.$().css('left', (originOffset.left + targetWidth / 2 - elementWidth / 2)) .css('top', originOffsetTop - elementHeight); }, - alignBottom: function(targetAttachmentElement) { + alignBottom(targetAttachmentElement) { Ember.assert('Bottom targetAttachment requires a target', targetAttachmentElement.length > 0); const elementWidth = this.$().outerWidth(); @@ -120,9 +124,9 @@ export default Ember.Component.extend({ const targetWidth = targetAttachmentElement.outerWidth(); const targetHeight = targetAttachmentElement.outerHeight(); - this.$().css('left', (originOffset.left + targetWidth/2 - elementWidth/2)) + this.$().css('left', (originOffset.left + targetWidth / 2 - elementWidth / 2)) .css('top', originOffsetTop + targetHeight); }, - alignNone: function() {} + alignNone() {} }); diff --git a/addon/components/tether-dialog.js b/addon/components/tether-dialog.js index b020ffae..f53ad625 100644 --- a/addon/components/tether-dialog.js +++ b/addon/components/tether-dialog.js @@ -7,7 +7,7 @@ const { computed, get } = Ember; const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); export default ModalDialog.extend({ - layout: layout, + layout, targetAttachmentClass: computed('targetAttachment', function() { let targetAttachment = this.get('targetAttachment') || ''; diff --git a/package.json b/package.json index 5da1f96c..3eaa573e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "ember-disable-proxy-controllers": "^1.0.0", "ember-export-application-global": "^1.0.3", "ember-legacy-views": "0.2.0", - "ember-suave": "1.2.0", + "ember-suave": "1.2.3", "ember-tether": "^0.1.3", "ember-truth-helpers": "1.2.0", "ember-try": "0.0.6", @@ -57,4 +57,4 @@ "configPath": "tests/dummy/config", "demoURL": "http://yapplabs.github.io/ember-modal-dialog/" } -} \ No newline at end of file +} diff --git a/tests/acceptance/modal-dialog-test.js b/tests/acceptance/modal-dialog-test.js index 6909619e..5d49562c 100644 --- a/tests/acceptance/modal-dialog-test.js +++ b/tests/acceptance/modal-dialog-test.js @@ -2,20 +2,20 @@ import Ember from 'ember'; import { module, test } from 'qunit'; import startApp from '../helpers/start-app'; -var application; +let application; const modalRootElementSelector = '#modal-overlays'; const overlaySelector = '.ember-modal-overlay'; const dialogSelector = '.ember-modal-dialog'; const dialogCloseButton = [dialogSelector, 'button'].join(' '); module('Acceptance: Display Modal Dialogs', { - beforeEach: function() { + beforeEach() { application = startApp(); visit('/'); click('button:contains(Change to modal-dialog)'); }, - afterEach: function() { + afterEach() { Ember.run(application, 'destroy'); } }); @@ -59,7 +59,7 @@ test('modal with custom styles', function(assert) { openSelector: '#example-custom-styles button', dialogText: 'Custom Styles', closeSelector: overlaySelector, - whileOpen: function() { + whileOpen() { assert.ok(Ember.$(`${modalRootElementSelector} ${overlaySelector}`).hasClass('custom-styles-modal'), 'has provided overlay-class'); assert.ok(Ember.$(`${modalRootElementSelector} ${dialogSelector}`).hasClass('custom-styles-modal-container'), 'has provided container-class'); } @@ -77,7 +77,7 @@ test('target - selector', function(assert) { dialogText: 'Target - Selector', closeSelector: dialogCloseButton, tethered: true, - whileOpen: function() { + whileOpen() { assert.ok(Ember.$(dialogSelector).hasClass('ember-modal-dialog-target-attachment-left'), 'has targetAttachment class name'); } }); @@ -106,7 +106,7 @@ test('subclassed modal', function(assert) { openSelector: '#example-subclass button', dialogText: 'Via Subclass', closeSelector: overlaySelector, - whileOpen: function() { + whileOpen() { assert.ok(Ember.$(dialogSelector).hasClass('my-cool-modal'), 'has provided containerClassNames'); } }); @@ -114,12 +114,12 @@ test('subclassed modal', function(assert) { test('in place', function(assert) { click('#example-in-place button'); - var dialogText = 'In Place'; - var defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' '); - var inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place'; - var inPlaceRootSelector = '#container-in-place'; - var inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' '); - var inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' '); + let dialogText = 'In Place'; + let defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' '); + let inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place'; + let inPlaceRootSelector = '#container-in-place'; + let inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' '); + let inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' '); andThen(function() { assert.equal(Ember.$(dialogSelector).css('position'), 'relative', 'not absolutely positioned'); assert.equal(Ember.$(dialogSelector).css('left'), 'auto', 'should not be positioned (left)'); diff --git a/tests/acceptance/tether-dialog-test.js b/tests/acceptance/tether-dialog-test.js index ea8d1395..c515cce5 100644 --- a/tests/acceptance/tether-dialog-test.js +++ b/tests/acceptance/tether-dialog-test.js @@ -2,19 +2,19 @@ import Ember from 'ember'; import { module, test } from 'qunit'; import startApp from '../helpers/start-app'; -var application; +let application; const modalRootElementSelector = '#modal-overlays'; const overlaySelector = '.ember-modal-overlay'; const dialogSelector = '.ember-modal-dialog'; const dialogCloseButton = [dialogSelector, 'button'].join(' '); module('Acceptance: Display Tether Dialogs', { - beforeEach: function() { + beforeEach() { application = startApp(); visit('/'); }, - afterEach: function() { + afterEach() { Ember.run(application, 'destroy'); } }); @@ -79,7 +79,7 @@ test('target - selector', function(assert) { closeSelector: dialogCloseButton, hasOverlay: false, tethered: true, - whileOpen: function() { + whileOpen() { assert.ok(Ember.$(dialogSelector).hasClass('ember-tether-target-attached-left'), 'has targetAttachment class name'); } }); @@ -111,7 +111,7 @@ test('subclassed modal', function(assert) { dialogText: 'Via Subclass', closeSelector: overlaySelector, hasOverlay: true, - whileOpen: function() { + whileOpen() { assert.ok(Ember.$(dialogSelector).hasClass('my-cool-modal'), 'has provided containerClassNames'); } }); @@ -119,12 +119,12 @@ test('subclassed modal', function(assert) { test('in place', function(assert) { click('#example-in-place button'); - var dialogText = 'In Place'; - var defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' '); - var inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place'; - var inPlaceRootSelector = '#container-in-place'; - var inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' '); - var inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' '); + let dialogText = 'In Place'; + let defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' '); + let inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place'; + let inPlaceRootSelector = '#container-in-place'; + let inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' '); + let inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' '); andThen(function() { assert.equal(Ember.$(dialogSelector).css('position'), 'relative', 'not absolutely positioned'); assert.equal(Ember.$(dialogSelector).css('left'), 'auto', 'should not be positioned'); diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js index 8d66b958..8b234d6d 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -3,14 +3,14 @@ import Resolver from 'ember/resolver'; import loadInitializers from 'ember/load-initializers'; import config from './config/environment'; -var App; +let App; Ember.MODEL_FACTORY_INJECTIONS = true; App = Ember.Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, - Resolver: Resolver + Resolver }); loadInitializers(App, config.modulePrefix); diff --git a/tests/dummy/app/components/component-that-uses-modal-dialog.js b/tests/dummy/app/components/component-that-uses-modal-dialog.js index bf55ad90..410421e4 100644 --- a/tests/dummy/app/components/component-that-uses-modal-dialog.js +++ b/tests/dummy/app/components/component-that-uses-modal-dialog.js @@ -3,10 +3,10 @@ import Ember from 'ember'; export default Ember.Component.extend({ isShowingModalDialog: false, actions: { - openModalDialog: function() { + openModalDialog() { this.set('isShowingModalDialog', true); }, - closeModalDialog: function() { + closeModalDialog() { this.set('isShowingModalDialog', false); } } diff --git a/tests/dummy/app/controllers/application.js b/tests/dummy/app/controllers/application.js index bd700b16..7b47301a 100644 --- a/tests/dummy/app/controllers/application.js +++ b/tests/dummy/app/controllers/application.js @@ -19,7 +19,7 @@ export default Ember.Controller.extend({ exampleTargetAttachment: 'middle left', exampleAttachment: 'middle right', customContainerClassNames: 'custom-styles-modal-container', - nextAttachment: function(val) { + nextAttachment(val) { switch (val) { case 'middle right': return 'bottom center'; @@ -40,25 +40,25 @@ export default Ember.Controller.extend({ set(this, 'activeComponent', 'modal-dialog'); } }, - toggleBasic: function() { + toggleBasic() { this.toggleProperty('isShowingBasic'); }, - toggleTranslucent: function() { + toggleTranslucent() { this.toggleProperty('isShowingTranslucent'); }, - toggleWithoutOverlay: function() { + toggleWithoutOverlay() { this.toggleProperty('isShowingWithoutOverlay'); }, - toggleWithoutOverlayClickOutsideToClose: function() { + toggleWithoutOverlayClickOutsideToClose() { this.toggleProperty('isShowingWithoutOverlayClickOutsideToClose'); }, - toggleCustomStyles: function() { + toggleCustomStyles() { this.toggleProperty('isShowingCustomStyles'); }, - toggleTargetSelector: function() { + toggleTargetSelector() { if (this.get('isShowingTargetSelector')) { - var newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); - var newAttachment = this.nextAttachment(this.get('exampleAttachment')); + let newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); + let newAttachment = this.nextAttachment(this.get('exampleAttachment')); this.set('exampleTargetAttachment', newTargetAttachment); this.set('exampleAttachment', newAttachment); if (newTargetAttachment !== 'middle left') { @@ -67,10 +67,10 @@ export default Ember.Controller.extend({ } this.toggleProperty('isShowingTargetSelector'); }, - toggleTargetView: function() { + toggleTargetView() { if (this.get('isShowingTargetView')) { - var newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); - var newAttachment = this.nextAttachment(this.get('exampleAttachment')); + let newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); + let newAttachment = this.nextAttachment(this.get('exampleAttachment')); this.set('exampleTargetAttachment', newTargetAttachment); this.set('exampleAttachment', newAttachment); if (newTargetAttachment !== 'middle left') { @@ -79,10 +79,10 @@ export default Ember.Controller.extend({ } this.toggleProperty('isShowingTargetView'); }, - toggleTargetElement: function() { + toggleTargetElement() { if (this.get('isShowingTargetElement')) { - var newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); - var newAttachment = this.nextAttachment(this.get('exampleAttachment')); + let newTargetAttachment = this.nextAttachment(this.get('exampleTargetAttachment')); + let newAttachment = this.nextAttachment(this.get('exampleAttachment')); this.set('exampleTargetAttachment', newTargetAttachment); this.set('exampleAttachment', newAttachment); if (newTargetAttachment !== 'middle left') { @@ -91,16 +91,16 @@ export default Ember.Controller.extend({ } this.toggleProperty('isShowingTargetElement'); }, - toggleSubclassed: function() { + toggleSubclassed() { this.toggleProperty('isShowingSubclassed'); }, - toggleInPlace: function() { + toggleInPlace() { this.toggleProperty('isShowingInPlace'); }, - toggleIsInPlace: function() { + toggleIsInPlace() { this.toggleProperty('isInPlace'); }, - toggleCenteredScrolling: function() { + toggleCenteredScrolling() { this.toggleProperty('isShowingCenteredScrolling'); if (this.get('isShowingCenteredScrolling')) { @@ -111,17 +111,17 @@ export default Ember.Controller.extend({ Ember.$('body').removeClass('centered-modal-showing'); } }, - closeTargetSelector: function() { + closeTargetSelector() { this.set('isShowingTargetSelector', false); this.set('exampleTargetAttachment', 'middle left'); this.set('exampleAttachment', 'middle right'); }, - closeTargetView: function() { + closeTargetView() { this.set('isShowingTargetView', false); this.set('exampleTargetAttachment', 'middle left'); this.set('exampleAttachment', 'middle right'); }, - closeTargetElement: function() { + closeTargetElement() { this.set('isShowingTargetElement', false); this.set('exampleTargetAttachment', 'middle left'); this.set('exampleAttachment', 'middle right'); diff --git a/tests/dummy/app/initializers/register-subclassed-modals.js b/tests/dummy/app/initializers/register-subclassed-modals.js index d57383b7..29f4b5ea 100644 --- a/tests/dummy/app/initializers/register-subclassed-modals.js +++ b/tests/dummy/app/initializers/register-subclassed-modals.js @@ -2,9 +2,9 @@ export default { after: 'add-modals-container', name: 'custom-modals', initialize(_, application) { - var customModals = ['my-cool-modal-dialog']; + let customModals = ['my-cool-modal-dialog']; customModals.forEach(function(customModal) { - application.inject('component:' + customModal, + application.inject(`component:${customModal}`, 'destinationElementId', 'config:modals-container-id'); }); diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index cef554b3..3bba78eb 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import config from './config/environment'; -var Router = Ember.Router.extend({ +const Router = Ember.Router.extend({ location: config.locationType }); diff --git a/tests/helpers/modal-asserts.js b/tests/helpers/modal-asserts.js index 77084551..d56a875d 100644 --- a/tests/helpers/modal-asserts.js +++ b/tests/helpers/modal-asserts.js @@ -2,29 +2,29 @@ import Ember from 'ember'; import QUnit from 'qunit'; export default function registerAssertHelpers() { - const assert = QUnit.assert; + const { assert } = QUnit; const overlaySelector = '.ember-modal-overlay'; const dialogSelector = '.ember-modal-dialog'; assert.isPresentOnce = function(selector, message) { - message = message || selector + ' is present in DOM once'; + message = message || `${selector} is present in DOM once`; return this.equal(Ember.$(selector).length, 1, message); }; assert.isAbsent = function(selector, message) { - message = message || selector + ' is absent from DOM'; + message = message || `${selector} is absent from DOM`; return this.equal(find(selector).length, 0, message); }; assert.isVisible = function(selector, message) { - message = message || selector + ' is not visible'; + message = message || `${selector} is not visible`; return this.ok(findWithAssert(selector).is(':visible'), message); }; assert.dialogOpensAndCloses = function(options, message) { - message = message || 'Dialog triggered by ' + options.openSelector + ' failed to open and close'; - var dialogContent = [dialogSelector, ':contains(' + options.dialogText + ')'].join(''); - var self = this; + message = message || `Dialog triggered by ${options.openSelector} failed to open and close`; + const dialogContent = [dialogSelector, `:contains(${options.dialogText})`].join(''); + const self = this; return click(options.openSelector, options.context).then(function() { if (options.hasOverlay) { self.isPresentOnce(overlaySelector); @@ -39,7 +39,7 @@ export default function registerAssertHelpers() { // HACK: Click open button 4 more times to let the modal go around // the horn and then disappear. This is obviously tightly coupled // to arbitrary demo behavior. - for (var i = 1; i <= 4; i++) { + for (let i = 1; i <= 4; i++) { click(options.openSelector, options.context); } andThen(function() { diff --git a/tests/helpers/resolver.js b/tests/helpers/resolver.js index 28f4ece4..ebfb4e4d 100644 --- a/tests/helpers/resolver.js +++ b/tests/helpers/resolver.js @@ -1,7 +1,7 @@ import Resolver from 'ember/resolver'; import config from '../../config/environment'; -var resolver = Resolver.create(); +const resolver = Resolver.create(); resolver.namespace = { modulePrefix: config.modulePrefix, diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index 60abee7d..3fe35b97 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -4,9 +4,9 @@ import config from '../../config/environment'; import registerAssertHelpers from './modal-asserts'; export default function startApp(attrs) { - var application; + let application; - var attributes = Ember.merge({}, config.APP); + let attributes = Ember.merge({}, config.APP); attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; Ember.run(function() {