From 975edceff497ee219ac43e4a980e5e53e417ac7f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 15 Sep 2015 17:08:50 -0400 Subject: [PATCH] Add semi colon linting to Javascript --- .eslintrc | 5 +---- .../admin/controllers/admin-dashboard.js.es6 | 2 +- .../modals/admin-edit-badge-groupings.js.es6 | 4 ++-- app/assets/javascripts/discourse.js | 14 +++++++------- .../discourse/components/category-drop.js.es6 | 2 +- .../discourse/components/group-selector.js.es6 | 2 +- .../discourse/components/search-menu.js.es6 | 2 +- .../discourse/components/track-selected.js.es6 | 2 +- .../discourse/controllers/full-page-search.js.es6 | 6 +++--- .../controllers/reorder-categories.js.es6 | 2 +- .../javascripts/discourse/lib/censored-words.js | 2 +- .../discourse/lib/key-value-store.js.es6 | 2 +- .../javascripts/discourse/lib/screen-track.js.es6 | 2 +- app/assets/javascripts/discourse/lib/search.js.es6 | 2 +- app/assets/javascripts/discourse/lib/utilities.js | 2 +- .../discourse/mixins/stale-local-storage.js.es6 | 6 +++--- .../javascripts/discourse/models/nav-item.js.es6 | 2 +- .../discourse/routes/build-category-route.js.es6 | 2 +- .../discourse/routes/full-page-search.js.es6 | 2 +- .../javascripts/discourse/routes/user.js.es6 | 4 ++-- .../javascripts/discourse/views/composer.js.es6 | 2 +- .../discourse/views/full-page-search.js.es6 | 2 +- test/javascripts/components/d-link-test.js.es6 | 2 +- test/javascripts/components/menu-panel-test.js.es6 | 4 ++-- 24 files changed, 37 insertions(+), 40 deletions(-) diff --git a/.eslintrc b/.eslintrc index 149d84248..d2a13ae26 100644 --- a/.eslintrc +++ b/.eslintrc @@ -90,10 +90,7 @@ "no-undef": 2, "no-unused-vars": 2, "no-with": 2, - "semi": [ - 0, - "never" - ], + "semi": 2, "strict": 0, "valid-typeof": 2, "wrap-iife": [ diff --git a/app/assets/javascripts/admin/controllers/admin-dashboard.js.es6 b/app/assets/javascripts/admin/controllers/admin-dashboard.js.es6 index ab304adc7..c712a8ac5 100644 --- a/app/assets/javascripts/admin/controllers/admin-dashboard.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-dashboard.js.es6 @@ -13,7 +13,7 @@ export default Ember.Controller.extend({ }.property('problems'), thereWereProblems: function() { - if(!Discourse.User.currentProp('admin')) { return false } + if(!Discourse.User.currentProp('admin')) { return false; } if( this.get('foundProblems') ) { this.set('hadProblems', true); return true; diff --git a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 index 2034d1036..74c4f79e6 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 @@ -56,8 +56,8 @@ export default Ember.Controller.extend({ saveAll: function(){ var self = this; var items = this.get('workingCopy'); - var groupIds = items.map(function(i){return i.get("id") || -1}); - var names = items.map(function(i){return i.get("name")}); + var groupIds = items.map(function(i){return i.get("id") || -1;}); + var names = items.map(function(i){return i.get("name");}); Discourse.ajax('/admin/badges/badge_groupings',{ data: {ids: groupIds, names: names}, diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index 57165d9d2..ebe4da3ee 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -152,10 +152,10 @@ function proxyDep(propName, moduleFunc, msg) { }); } -proxyDep('computed', function() { return require('discourse/lib/computed') }); -proxyDep('Formatter', function() { return require('discourse/lib/formatter') }); -proxyDep('PageTracker', function() { return require('discourse/lib/page-tracker').default }); -proxyDep('URL', function() { return require('discourse/lib/url').default }); -proxyDep('Quote', function() { return require('discourse/lib/quote').default }); -proxyDep('debounce', function() { return require('discourse/lib/debounce').default }); -proxyDep('View', function() { return Ember.View }, "Use `Ember.View` instead"); +proxyDep('computed', function() { return require('discourse/lib/computed'); }); +proxyDep('Formatter', function() { return require('discourse/lib/formatter'); }); +proxyDep('PageTracker', function() { return require('discourse/lib/page-tracker').default; }); +proxyDep('URL', function() { return require('discourse/lib/url').default; }); +proxyDep('Quote', function() { return require('discourse/lib/quote').default; }); +proxyDep('debounce', function() { return require('discourse/lib/debounce').default; }); +proxyDep('View', function() { return Ember.View; }, "Use `Ember.View` instead"); diff --git a/app/assets/javascripts/discourse/components/category-drop.js.es6 b/app/assets/javascripts/discourse/components/category-drop.js.es6 index 696991853..b82411795 100644 --- a/app/assets/javascripts/discourse/components/category-drop.js.es6 +++ b/app/assets/javascripts/discourse/components/category-drop.js.es6 @@ -47,7 +47,7 @@ export default Ember.Component.extend({ if (color) { var style = ""; - if (color) { style += "background-color: #" + color + ";" } + if (color) { style += "background-color: #" + color + ";"; } return style.htmlSafe(); } } diff --git a/app/assets/javascripts/discourse/components/group-selector.js.es6 b/app/assets/javascripts/discourse/components/group-selector.js.es6 index e88505ca9..dc23f0f1e 100644 --- a/app/assets/javascripts/discourse/components/group-selector.js.es6 +++ b/app/assets/javascripts/discourse/components/group-selector.js.es6 @@ -25,7 +25,7 @@ export default Ember.Component.extend({ } return groups.filter(function(group){ - return !selectedGroups.any(function(s){return s === group.name}); + return !selectedGroups.any(function(s){return s === group.name;}); }); }); }, diff --git a/app/assets/javascripts/discourse/components/search-menu.js.es6 b/app/assets/javascripts/discourse/components/search-menu.js.es6 index 413525280..be80d20a2 100644 --- a/app/assets/javascripts/discourse/components/search-menu.js.es6 +++ b/app/assets/javascripts/discourse/components/search-menu.js.es6 @@ -61,7 +61,7 @@ export default Ember.Component.extend({ @observes('searchService.term', 'typeFilter') newSearchNeeded() { this.set('noResults', false); - const term = this.get('searchService.term') + const term = this.get('searchService.term'); if (isValidSearchTerm(term)) { this.set('loading', true); Ember.run.debounce(this, 'searchTerm', term, this.get('typeFilter'), 400); diff --git a/app/assets/javascripts/discourse/components/track-selected.js.es6 b/app/assets/javascripts/discourse/components/track-selected.js.es6 index ded975509..20f05bef6 100644 --- a/app/assets/javascripts/discourse/components/track-selected.js.es6 +++ b/app/assets/javascripts/discourse/components/track-selected.js.es6 @@ -11,4 +11,4 @@ export default Ember.Component.extend({ list.removeObject(id); } }.observes('selected') -}) +}); diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index f4fb1e787..d5ba0ad2f 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -24,7 +24,7 @@ export default Ember.Controller.extend({ return (!skip && context) || skip === "false"; }, set(val) { - this.set('skip_context', val ? "false" : "true" ) + this.set('skip_context', val ? "false" : "true" ); } }, @@ -100,7 +100,7 @@ export default Ember.Controller.extend({ const model = translateResults(results) || {}; router.transientCache('lastSearch', { searchKey, model }, 5); this.set("model", model); - }).finally(() => {this._searching = false}); + }).finally(() => this._searching = false); }, actions: { @@ -116,7 +116,7 @@ export default Ember.Controller.extend({ }, clearAll() { - this.get('selected').clear() + this.get('selected').clear(); $('.fps-result input[type=checkbox]').prop('checked', false); }, diff --git a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 index 0debb1e70..59d9e197a 100644 --- a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 @@ -34,7 +34,7 @@ export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, { showApplyAll: function() { let anyChanged = false; - this.get('categoriesBuffered').forEach(bc => { anyChanged = anyChanged || bc.get('hasBufferedChanges') }); + this.get('categoriesBuffered').forEach(bc => { anyChanged = anyChanged || bc.get('hasBufferedChanges'); }); return anyChanged; }.property('categoriesBuffered.@each.hasBufferedChanges'), diff --git a/app/assets/javascripts/discourse/lib/censored-words.js b/app/assets/javascripts/discourse/lib/censored-words.js index 840c3093b..246bc2a0b 100644 --- a/app/assets/javascripts/discourse/lib/censored-words.js +++ b/app/assets/javascripts/discourse/lib/censored-words.js @@ -22,4 +22,4 @@ Discourse.CensoredWords = { } return text; } -} +}; diff --git a/app/assets/javascripts/discourse/lib/key-value-store.js.es6 b/app/assets/javascripts/discourse/lib/key-value-store.js.es6 index 243146833..80b99327d 100644 --- a/app/assets/javascripts/discourse/lib/key-value-store.js.es6 +++ b/app/assets/javascripts/discourse/lib/key-value-store.js.es6 @@ -14,7 +14,7 @@ try { const KeyValueStore = function(ctx) { this.context = ctx; -} +}; KeyValueStore.prototype = { abandonLocal() { diff --git a/app/assets/javascripts/discourse/lib/screen-track.js.es6 b/app/assets/javascripts/discourse/lib/screen-track.js.es6 index 4bac0e521..975d835b9 100644 --- a/app/assets/javascripts/discourse/lib/screen-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/screen-track.js.es6 @@ -30,7 +30,7 @@ const ScreenTrack = Ember.Object.extend({ self.tick(); }, 1000)); - $(window).on('scroll.screentrack', function(){self.scrolled()}); + $(window).on('scroll.screentrack', function(){self.scrolled();}); } this.set('topicId', topicId); diff --git a/app/assets/javascripts/discourse/lib/search.js.es6 b/app/assets/javascripts/discourse/lib/search.js.es6 index 9d7bec2d6..4b4c083d6 100644 --- a/app/assets/javascripts/discourse/lib/search.js.es6 +++ b/app/assets/javascripts/discourse/lib/search.js.es6 @@ -103,7 +103,7 @@ const searchContextDescription = function(type, name){ const getSearchKey = function(args){ return args.q + "|" + ((args.searchContext && args.searchContext.type) || "") + "|" + - ((args.searchContext && args.searchContext.id) || "") + ((args.searchContext && args.searchContext.id) || ""); }; const isValidSearchTerm = function(searchTerm) { diff --git a/app/assets/javascripts/discourse/lib/utilities.js b/app/assets/javascripts/discourse/lib/utilities.js index 20d9c53f5..672c75237 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js +++ b/app/assets/javascripts/discourse/lib/utilities.js @@ -99,7 +99,7 @@ Discourse.Utilities = { div.innerHTML = html; var $div = $(div); // Find all emojis and replace with its title attribute. - $div.find('img.emoji').replaceWith(function() { return this.title }); + $div.find('img.emoji').replaceWith(function() { return this.title; }); $('.clicks', $div).remove(); var text = div.textContent || div.innerText || ""; diff --git a/app/assets/javascripts/discourse/mixins/stale-local-storage.js.es6 b/app/assets/javascripts/discourse/mixins/stale-local-storage.js.es6 index 07dcd548a..19d849516 100644 --- a/app/assets/javascripts/discourse/mixins/stale-local-storage.js.es6 +++ b/app/assets/javascripts/discourse/mixins/stale-local-storage.js.es6 @@ -10,7 +10,7 @@ export default { findStale(store, type, findArgs, opts) { const staleResult = new StaleResult(); - const key = (opts && opts.storageKey) || this.storageKey(type, findArgs) + const key = (opts && opts.storageKey) || this.storageKey(type, findArgs); try { const stored = this.keyValueStore.getItem(key); if (stored) { @@ -24,11 +24,11 @@ export default { }, find(store, type, findArgs, opts) { - const key = (opts && opts.storageKey) || this.storageKey(type, findArgs) + const key = (opts && opts.storageKey) || this.storageKey(type, findArgs); return this._super(store, type, findArgs).then((results) => { this.keyValueStore.setItem(key, JSON.stringify(results)); return results; }); } -} +}; diff --git a/app/assets/javascripts/discourse/models/nav-item.js.es6 b/app/assets/javascripts/discourse/models/nav-item.js.es6 index ee81b705e..64cb9fea4 100644 --- a/app/assets/javascripts/discourse/models/nav-item.js.es6 +++ b/app/assets/javascripts/discourse/models/nav-item.js.es6 @@ -104,7 +104,7 @@ NavItem.reopenClass({ buildList(category, args) { args = args || {}; - if (category) { args.category = category } + if (category) { args.category = category; } let items = Discourse.SiteSettings.top_menu.split("|"); diff --git a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 index 58f945ac9..e3d2e89a8 100644 --- a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 @@ -103,4 +103,4 @@ export default (filter, params) => { } } }); -} +}; diff --git a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 index 3464250a7..9c95de0aa 100644 --- a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 @@ -11,7 +11,7 @@ export default Discourse.Route.extend({ args.search_context = { type: params.context, id: params.context_id - } + }; } const searchKey = getSearchKey(args); diff --git a/app/assets/javascripts/discourse/routes/user.js.es6 b/app/assets/javascripts/discourse/routes/user.js.es6 index c0d4507ad..7fb8fffe6 100644 --- a/app/assets/javascripts/discourse/routes/user.js.es6 +++ b/app/assets/javascripts/discourse/routes/user.js.es6 @@ -61,7 +61,7 @@ export default Discourse.Route.extend({ setupController(controller, user) { controller.set('model', user); - this.searchService.set('searchContext', user.get('searchContext')) + this.searchService.set('searchContext', user.get('searchContext')); }, activate() { @@ -77,7 +77,7 @@ export default Discourse.Route.extend({ this.messageBus.unsubscribe("/users/" + this.modelFor('user').get('username_lower')); // Remove the search context - this.searchService.set('searchContext', null) + this.searchService.set('searchContext', null); } }); diff --git a/app/assets/javascripts/discourse/views/composer.js.es6 b/app/assets/javascripts/discourse/views/composer.js.es6 index 076c02ab9..093af4174 100644 --- a/app/assets/javascripts/discourse/views/composer.js.es6 +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -272,7 +272,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, { position: "absolute", left: toolbarPos.left + pos.left, top: toolbarPos.top + pos.top, - } + }; controller.send('showOptions', location); } }]; diff --git a/app/assets/javascripts/discourse/views/full-page-search.js.es6 b/app/assets/javascripts/discourse/views/full-page-search.js.es6 index f0b71073a..7a8aa550e 100644 --- a/app/assets/javascripts/discourse/views/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/views/full-page-search.js.es6 @@ -1 +1 @@ -export default Ember.View.extend({}); +export default Ember.View.extend(); diff --git a/test/javascripts/components/d-link-test.js.es6 b/test/javascripts/components/d-link-test.js.es6 index d0b969269..fc17333d3 100644 --- a/test/javascripts/components/d-link-test.js.es6 +++ b/test/javascripts/components/d-link-test.js.es6 @@ -56,6 +56,6 @@ componentTest('with an action', { assert.ok(true, 'it fired the action'); }); - click('a') + click('a'); } }); diff --git a/test/javascripts/components/menu-panel-test.js.es6 b/test/javascripts/components/menu-panel-test.js.es6 index 45607dc2b..6c586eed7 100644 --- a/test/javascripts/components/menu-panel-test.js.es6 +++ b/test/javascripts/components/menu-panel-test.js.es6 @@ -24,7 +24,7 @@ componentTest('as a dropdown', { assert.ok(!exists(".menu-panel.hidden"), "toggling visible makes it appear"); }); - click('#outside-area') + click('#outside-area'); andThen(() => { assert.ok(exists(".menu-panel.hidden"), "clicking the body hides the menu"); assert.equal(this.get('panelVisible'), false, 'it updates the bound variable'); @@ -54,7 +54,7 @@ componentTest('as a slide-in', { assert.ok(!exists(".menu-panel.hidden"), "toggling visible makes it appear"); }); - click('#outside-area') + click('#outside-area'); andThen(() => { assert.ok(exists(".menu-panel.hidden"), "clicking the body hides the menu"); assert.equal(this.get('panelVisible'), false, 'it updates the bound variable');