From 34a8cb1c66958290f1ee9ee6f2b5bf6d41f926ad Mon Sep 17 00:00:00 2001 From: Bj Date: Wed, 12 Oct 2016 17:53:56 -0400 Subject: [PATCH] [Cleanup] eslint `ember-suave/no-const-outside-module-scope` `const` -> `let` (inside modules) Part of #732. --- app/components/custom-form.js | 6 ++-- app/components/role-select.js | 14 +++++----- app/controllers/navigation.js | 2 +- app/mixins/charge-route.js | 2 +- app/mixins/navigation.js | 2 +- app/mixins/pagination-props.js | 2 +- app/mixins/patient-id.js | 14 +++++----- app/mixins/setup-user-role.js | 4 +-- app/models/inventory.js | 4 +-- app/patients/edit/controller.js | 18 ++++++------ app/patients/notes/controller.js | 10 +++---- app/routes/application.js | 4 +-- app/services/config.js | 28 +++++++++---------- app/services/database.js | 2 +- app/utils/item-condition.js | 2 +- tests/acceptance/admin-test.js | 2 +- tests/acceptance/patients-test.js | 14 +++++----- tests/helpers/authenticate-user.js | 2 +- tests/helpers/run-with-pouch-dump.js | 12 ++++---- .../components/inventory/rank-select-test.js | 2 +- 20 files changed, 73 insertions(+), 73 deletions(-) diff --git a/app/components/custom-form.js b/app/components/custom-form.js index f1d12a51b8..eda453ca81 100644 --- a/app/components/custom-form.js +++ b/app/components/custom-form.js @@ -4,10 +4,10 @@ export default Ember.Component.extend(SelectValues, { classNames: 'detail-section-content', fieldsByRow: function() { let rows = []; - const form = this.get('form'); + let form = this.get('form'); if (!Ember.isEmpty(form)) { - const fields = form.fields; - const numberOfColumns = this.getWithDefault('form.columns', 1); + let fields = form.fields; + let numberOfColumns = this.getWithDefault('form.columns', 1); let currentRow = []; let colCount = 0; diff --git a/app/components/role-select.js b/app/components/role-select.js index a7cac37233..9ff872bf68 100644 --- a/app/components/role-select.js +++ b/app/components/role-select.js @@ -20,21 +20,21 @@ export default Ember.Component.extend({ actions: { change() { - const selectEl = this.$('select')[0]; - const selectedIndex = selectEl.selectedIndex; - const content = this.get('content'); + let selectEl = this.$('select')[0]; + let selectedIndex = selectEl.selectedIndex; + let content = this.get('content'); // decrement index by 1 if we have a prompt - const hasPrompt = !!this.get('prompt'); - const contentIndex = hasPrompt ? selectedIndex - 1 : selectedIndex; + let hasPrompt = !!this.get('prompt'); + let contentIndex = hasPrompt ? selectedIndex - 1 : selectedIndex; - const selection = content[contentIndex].roles; + let selection = content[contentIndex].roles; // set the local, shadowed selection to avoid leaking // changes to `selection` out via 2-way binding this.set('_selection', selection); - const changeCallback = this.get('action'); + let changeCallback = this.get('action'); changeCallback(selection); } } diff --git a/app/controllers/navigation.js b/app/controllers/navigation.js index 6ba36ddbce..286b58f676 100644 --- a/app/controllers/navigation.js +++ b/app/controllers/navigation.js @@ -30,7 +30,7 @@ export default Ember.Controller.extend(HospitalRunVersion, ModalHelper, Progress }, invalidateSession: function() { - const session = this.get('session'); + let session = this.get('session'); if (session.get('isAuthenticated')) { session.invalidate(); } diff --git a/app/mixins/charge-route.js b/app/mixins/charge-route.js index f1de0db662..de8f411c26 100644 --- a/app/mixins/charge-route.js +++ b/app/mixins/charge-route.js @@ -10,7 +10,7 @@ export default Ember.Mixin.create({ afterModel: function() { return new Ember.RSVP.Promise(function(resolve, reject) { - const database = this.get('database'); + let database = this.get('database'); let maxId = database.getPouchId({}, 'pricing'), minId = database.getPouchId(null, 'pricing'), pricingCategory = this.get('pricingCategory'), diff --git a/app/mixins/navigation.js b/app/mixins/navigation.js index e2478dfe85..5b3b731cb3 100644 --- a/app/mixins/navigation.js +++ b/app/mixins/navigation.js @@ -292,7 +292,7 @@ export default Ember.Mixin.create({ // Navigation items get mapped localizations localizedNavItems: Ember.computed('navItems.[]', function() { - const localizationPrefix = 'navigation.'; + let localizationPrefix = 'navigation.'; // Supports unlocalized keys for now, otherwise we would get: // "Missing translation: key.etc.path" let translationOrOriginal = (translation, original) => { diff --git a/app/mixins/pagination-props.js b/app/mixins/pagination-props.js index efdf9474e6..04d538e521 100644 --- a/app/mixins/pagination-props.js +++ b/app/mixins/pagination-props.js @@ -1,7 +1,7 @@ import Ember from 'ember'; export default Ember.Mixin.create({ paginationProps: function() { - const paginationProperties = [ + let paginationProperties = [ 'disableNextPage', 'disablePreviousPage', 'showFirstPageButton', diff --git a/app/mixins/patient-id.js b/app/mixins/patient-id.js index e78d0ab8ea..894acf0ab5 100644 --- a/app/mixins/patient-id.js +++ b/app/mixins/patient-id.js @@ -14,19 +14,19 @@ export default Ember.Mixin.create(PouchDbMixin, { * id will be automatically generated via Ember data. */ generateFriendlyId() { - const config = this.get('config'); - const database = this.get('database'); - const maxValue = this.get('maxValue'); + let config = this.get('config'); + let database = this.get('database'); + let maxValue = this.get('maxValue'); - const findUnusedId = (sequence) => { + let findUnusedId = (sequence) => { let current, id; return config.getPatientPrefix() .then(function(prefix) { current = sequence.get('value'); id = sequenceId(prefix, current); - const query = { - startkey: [ id, null ], - endkey: [ id, maxValue ] + let query = { + startkey: [id, null], + endkey: [id, maxValue] }; return database.queryMainDB(query, 'patient_by_display_id'); }) diff --git a/app/mixins/setup-user-role.js b/app/mixins/setup-user-role.js index ca469ed9d5..b90425b6e0 100644 --- a/app/mixins/setup-user-role.js +++ b/app/mixins/setup-user-role.js @@ -1,8 +1,8 @@ import Ember from 'ember'; export default Ember.Mixin.create({ setupUserRole() { - const session = this.get('session'); - const userRole = session.get('data.authenticated.role'); + let session = this.get('session'); + let userRole = session.get('data.authenticated.role'); return this.get('store').find('user-role', userRole.dasherize()).then((userCaps) => { session.set('data.authenticated.userCaps', userCaps.get('capabilities')); let sessionStore = session.get('store'); diff --git a/app/models/inventory.js b/app/models/inventory.js index a760b78c6c..182d3e0ed6 100644 --- a/app/models/inventory.js +++ b/app/models/inventory.js @@ -57,8 +57,8 @@ export default AbstractModel.extend(LocationName, { }), condition: computed('rank', 'estimatedDaysOfStock', function() { - const estimatedDaysOfStock = this.get('estimatedDaysOfStock'); - const multiplier = rankToMultiplier(this.get('rank')); + let estimatedDaysOfStock = this.get('estimatedDaysOfStock'); + let multiplier = rankToMultiplier(this.get('rank')); return getCondition(estimatedDaysOfStock, multiplier); }), diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index a2e5e9cc3f..b240a94fa3 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -529,16 +529,16 @@ export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession, }, _updateSequence: function(record) { - const config = this.get('config'); - const friendlyId = record.get('friendlyId'); + let config = this.get('config'); + let friendlyId = record.get('friendlyId'); return config.getPatientPrefix().then((prefix) => { - const re = new RegExp(`^${prefix}\\d{5}$`); + let re = new RegExp(`^${prefix}\\d{5}$`); if (!re.test(friendlyId)) { return; } return this.store.find('sequence', 'patient').then((sequence) => { - const sequenceNumber = sequence.get('value'); - const patientNumber = parseInt(friendlyId.slice(prefix.length)); + let sequenceNumber = sequence.get('value'); + let patientNumber = parseInt(friendlyId.slice(prefix.length)); if (patientNumber > sequenceNumber) { sequence.set('value', patientNumber); return sequence.save(); @@ -551,10 +551,10 @@ export default AbstractEditController.extend(BloodTypes, ReturnTo, UserSession, if (!this.get('model.isNew')) { return Ember.RSVP.resolve(); } - const database = this.get('database'); - const id = this.get('model.friendlyId'); - const maxValue = this.get('maxValue'); - const query = { + let database = this.get('database'); + let id = this.get('model.friendlyId'); + let maxValue = this.get('maxValue'); + let query = { startkey: [id, null], endkey: [id, maxValue] }; diff --git a/app/patients/notes/controller.js b/app/patients/notes/controller.js index 27ff17c022..397b5806c3 100644 --- a/app/patients/notes/controller.js +++ b/app/patients/notes/controller.js @@ -33,14 +33,14 @@ export default AbstractEditController.extend(IsUpdateDisabled, UserSession, Pati }, actions: { changeVisit: function() { - const selectEl = $('select[name="note-visits"]')[0]; - const selectedIndex = selectEl.selectedIndex; - const content = this.get('patientVisitsForSelect'); + let selectEl = $('select[name="note-visits"]')[0]; + let selectedIndex = selectEl.selectedIndex; + let content = this.get('patientVisitsForSelect'); // decrement index by 1 if we have a prompt - const contentIndex = selectedIndex - 1; + let contentIndex = selectedIndex - 1; - const selection = content[contentIndex].selectObject; + let selection = content[contentIndex].selectObject; // set the local, shadowed selection to avoid leaking // changes to `selection` out via 2-way binding diff --git a/app/routes/application.js b/app/routes/application.js index ff338ac970..4918c4b589 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -40,8 +40,8 @@ let ApplicationRoute = Route.extend(ApplicationRouteMixin, SetupUserRole, { }, model: function(params, transition) { - const session = this.get('session'); - const isAuthenticated = session && session.get('isAuthenticated'); + let session = this.get('session'); + let isAuthenticated = session && session.get('isAuthenticated'); return this.get('config').setup().then(function(configs) { if (transition.targetName !== 'finishgauth' && transition.targetName !== 'login') { this.set('shouldSetupUserRole', true); diff --git a/app/services/config.js b/app/services/config.js index 31b86749eb..4933509696 100644 --- a/app/services/config.js +++ b/app/services/config.js @@ -9,8 +9,8 @@ export default Ember.Service.extend({ sessionData: Ember.computed.alias('session.data'), setup() { - const replicateConfigDB = this.replicateConfigDB.bind(this); - const loadConfig = this.loadConfig.bind(this); + let replicateConfigDB = this.replicateConfigDB.bind(this); + let loadConfig = this.loadConfig.bind(this); let db = this.createDB(); this.set('configDB', db); this.setCurrentUser(); @@ -21,14 +21,14 @@ export default Ember.Service.extend({ return new PouchDB('config'); }, replicateConfigDB(db) { - const promise = new Ember.RSVP.Promise((resolve) => { - const url = `${document.location.protocol}//${document.location.host}/db/config`; + let promise = new Ember.RSVP.Promise((resolve) => { + let url = `${document.location.protocol}//${document.location.host}/db/config`; db.replicate.from(url).then(resolve).catch(resolve); }); return promise; }, loadConfig() { - const config = this.get('configDB'); + let config = this.get('configDB'); let options = { include_docs: true, keys: [ @@ -46,7 +46,7 @@ export default Ember.Service.extend({ console.log('Could not get configDB configs:', err); reject(err); } - const configObj = {}; + let configObj = {}; for (let i = 0; i < response.rows.length; i++) { if (!response.rows[i].error && response.rows[i].doc) { configObj[response.rows[i].id] = response.rows[i].doc.value; @@ -57,7 +57,7 @@ export default Ember.Service.extend({ }, 'getting configuration from the database'); }, getFileLink(id) { - const config = this.get('configDB'); + let config = this.get('configDB'); return new Ember.RSVP.Promise(function(resolve, reject) { config.get(`file-link_${id}`, function(err, doc) { if (err) { @@ -68,13 +68,13 @@ export default Ember.Service.extend({ }); }, removeFileLink(id) { - const config = this.get('configDB'); + let config = this.get('configDB'); return this.getFileLink(id).then(function(fileLink) { config.remove(fileLink); }); }, saveFileLink(fileName, id) { - const config = this.get('configDB'); + let config = this.get('configDB'); return new Ember.RSVP.Promise(function(resolve, reject) { config.put({ fileName }, `file-link_${id}`, function(err, doc) { if (err) { @@ -85,7 +85,7 @@ export default Ember.Service.extend({ }); }, saveOauthConfigs: function(configs) { - const configDB = this.get('configDB'); + let configDB = this.get('configDB'); let configKeys = Object.keys(configs); let savePromises = []; return this._getOauthConfigs(configKeys).then(function(records) { @@ -118,7 +118,7 @@ export default Ember.Service.extend({ }, getConfigValue(id, defaultValue) { - const configDB = this.get('configDB'); + let configDB = this.get('configDB'); return new Ember.RSVP.Promise(function(resolve) { configDB.get('config_' + id).then(function(doc) { run(null, resolve, doc.value); @@ -130,7 +130,7 @@ export default Ember.Service.extend({ }, _getOauthConfigs: function(configKeys) { - const configDB = this.get('configDB'); + let configDB = this.get('configDB'); let options = { include_docs: true, keys: configKeys @@ -139,8 +139,8 @@ export default Ember.Service.extend({ }, setCurrentUser: function(userName) { - const config = this.get('configDB'); - const sessionData = this.get('sessionData'); + let config = this.get('configDB'); + let sessionData = this.get('sessionData'); if (!userName && sessionData.authenticated) { userName = sessionData.authenticated.name; } diff --git a/app/services/database.js b/app/services/database.js index efe37e6d02..c5ac8816fe 100644 --- a/app/services/database.js +++ b/app/services/database.js @@ -42,7 +42,7 @@ export default Ember.Service.extend(PouchAdapterUtils, { pouchOptions.ajax.headers = headers; } } - const url = `${document.location.protocol}//${document.location.host}/db/main`; + let url = `${document.location.protocol}//${document.location.host}/db/main`; this._createRemoteDB(url, pouchOptions) .catch((err) => { diff --git a/app/utils/item-condition.js b/app/utils/item-condition.js index 8dff54723a..670c2c2f1d 100644 --- a/app/utils/item-condition.js +++ b/app/utils/item-condition.js @@ -16,7 +16,7 @@ const rankMultiplierValues = [ ]; export function rankToMultiplier(rank = 'B') { - const rankModel = Ember.A(rankMultiplierValues).findBy('rank', rank); + let rankModel = Ember.A(rankMultiplierValues).findBy('rank', rank); return rankModel.value; } diff --git a/tests/acceptance/admin-test.js b/tests/acceptance/admin-test.js index 0b56a4a2a4..8a5862352c 100644 --- a/tests/acceptance/admin-test.js +++ b/tests/acceptance/admin-test.js @@ -93,7 +93,7 @@ test('Update address options', function(assert) { }); test('Update workflow options', function(assert) { - const selector = 'input[type=checkbox]'; + let selector = 'input[type=checkbox]'; runWithPouchDump('admin', function() { authenticateUser(); diff --git a/tests/acceptance/patients-test.js b/tests/acceptance/patients-test.js index 1c4205a6d9..dabd7b5d03 100644 --- a/tests/acceptance/patients-test.js +++ b/tests/acceptance/patients-test.js @@ -18,9 +18,9 @@ test('visiting /patients route', function(assert) { visit('/patients'); andThen(function() { assert.equal(currentURL(), '/patients'); - const noPatientsFound = find('[data-test-selector="no-patients-found"]'); + let noPatientsFound = find('[data-test-selector="no-patients-found"]'); assert.equal(noPatientsFound.text().trim(), 'No patients found. Create a new patient record?', 'no records found'); - const newPatientButton = find('button:contains(+ new patient)'); + let newPatientButton = find('button:contains(+ new patient)'); assert.equal(newPatientButton.length, 1, 'Add new patient button is visible'); }); click('button:contains(+ new patient)'); @@ -39,7 +39,7 @@ test('View reports tab', function(assert) { let generateReportButton = find('button:contains(Generate Report)'); assert.equal(currentURL(), '/patients/reports'); assert.equal(generateReportButton.length, 1, 'Generate Report button is visible'); - const reportType = find('[data-test-selector="select-report-type"]'); + let reportType = find('[data-test-selector="select-report-type"]'); assert.equal(reportType.length, 1, 'Report type select is visible'); assert.equal(reportType.find(':selected').text().trim(), 'Admissions Detail', 'Default value selected"'); }); @@ -62,7 +62,7 @@ test('View reports tab | Patient Status', function(assert) { let generateReportButton = find('button:contains(Generate Report)'); assert.equal(currentURL(), '/patients/reports'); assert.equal(generateReportButton.length, 1, 'Generate Report button is visible'); - const reportType = find('[data-test-selector="select-report-type"] select'); + let reportType = find('[data-test-selector="select-report-type"] select'); assert.equal(reportType.length, 1, 'Report type select is visible'); assert.equal(reportType.find(':selected').text().trim(), 'Patient Status', 'Default value selected"'); }); @@ -106,11 +106,11 @@ function testSimpleReportForm(reportName) { select('[data-test-selector="select-report-type"] select', reportName); andThen(function() { - const reportStartDate = find('[data-test-selector="select-report-start-date"]'); - const reportEndDate = find('[data-test-selector="select-report-end-date"]'); + let reportStartDate = find('[data-test-selector="select-report-start-date"]'); + let reportEndDate = find('[data-test-selector="select-report-end-date"]'); assert.equal(reportStartDate.length, 1, 'Report start date select is visible'); assert.equal(reportEndDate.length, 1, 'Report end date select is visible'); - const reportType = find('[data-test-selector="select-report-type"] select'); + let reportType = find('[data-test-selector="select-report-type"] select'); assert.equal(reportType.find(':selected').text().trim(), reportName, `${reportName} option selected`); }); }); diff --git a/tests/helpers/authenticate-user.js b/tests/helpers/authenticate-user.js index f2d46c1531..4c13b0e798 100644 --- a/tests/helpers/authenticate-user.js +++ b/tests/helpers/authenticate-user.js @@ -7,7 +7,7 @@ const { } = Ember; Ember.Test.registerHelper('authenticateUser', function(app, attrs = {}) { - const expiresAt = new Date().getTime() + 600000; + let expiresAt = new Date().getTime() + 600000; authenticateSession(app, merge({ name: 'hradmin', roles: ['System Administrator','admin','user'], diff --git a/tests/helpers/run-with-pouch-dump.js b/tests/helpers/run-with-pouch-dump.js index 39c5dc26f1..34bb4e0784 100644 --- a/tests/helpers/run-with-pouch-dump.js +++ b/tests/helpers/run-with-pouch-dump.js @@ -33,16 +33,16 @@ function destroyDatabases(dbs) { function runWithPouchDumpAsyncHelper(app, dumpName, functionToRun) { - const db = new PouchDB('hospitalrun-test-database', { + let db = new PouchDB('hospitalrun-test-database', { adapter: 'memory' }); - const configDB = new PouchDB('hospitalrun-test-config-database', { + let configDB = new PouchDB('hospitalrun-test-config-database', { adapter: 'memory' }); - const dump = require(`hospitalrun/tests/fixtures/${dumpName}`).default; - const promise = db.load(dump); + let dump = require(`hospitalrun/tests/fixtures/${dumpName}`).default; + let promise = db.load(dump); - const InMemoryDatabaseService = DatabaseService.extend({ + let InMemoryDatabaseService = DatabaseService.extend({ createDB() { return promise.then(function() { return db; @@ -50,7 +50,7 @@ function runWithPouchDumpAsyncHelper(app, dumpName, functionToRun) { } }); - const InMemoryConfigService = ConfigService.extend({ + let InMemoryConfigService = ConfigService.extend({ createDB() { return configDB; }, diff --git a/tests/integration/components/inventory/rank-select-test.js b/tests/integration/components/inventory/rank-select-test.js index 2ed942f332..9d00627b93 100644 --- a/tests/integration/components/inventory/rank-select-test.js +++ b/tests/integration/components/inventory/rank-select-test.js @@ -14,7 +14,7 @@ test('it renders correctly', function(assert) { }}`); // options - const $options = this.$('option'); + let $options = this.$('option'); assert.equal($options.length, 4, 'Should render 4 options'); assert.equal($options[0].value, '', 'First option value is empty (prompt)'); assert.equal($options[0].innerHTML.trim(), 'n/a', 'First option label is prompt');