From 4932c078edbe0ad90a7b410e98576c8eedca0b73 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 2 Aug 2017 11:33:50 +0100 Subject: [PATCH] Correct eslint offences --- .../javascripts/admin/adapters/channel.js.es6 | 1 - .../admin/components/channel-details.js.es6 | 10 +++---- .../admin/components/rule-row.js.es6 | 12 ++++---- .../admin-plugins-chat-provider.js.es6 | 7 +---- .../admin-plugins-chat-edit-channel.js.es6 | 14 ++++----- .../admin-plugins-chat-edit-rule.js.es6 | 9 ++---- .../modals/admin-plugins-chat-test.js.es6 | 16 +++++----- .../javascripts/admin/models/provider.js.es6 | 2 -- assets/javascripts/admin/models/rule.js.es6 | 2 +- .../routes/admin-plugins-chat-index.js.es6 | 4 +-- .../routes/admin-plugins-chat-provider.js.es6 | 9 +++--- .../admin/routes/admin-plugins-chat.js.es6 | 4 +-- .../acceptance/chat-integration-test.js.es6 | 30 +++++++++---------- 13 files changed, 50 insertions(+), 70 deletions(-) diff --git a/assets/javascripts/admin/adapters/channel.js.es6 b/assets/javascripts/admin/adapters/channel.js.es6 index 8287b75..4b0cbd4 100644 --- a/assets/javascripts/admin/adapters/channel.js.es6 +++ b/assets/javascripts/admin/adapters/channel.js.es6 @@ -1,5 +1,4 @@ import buildPluginAdapter from 'admin/adapters/build-plugin'; -import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule' export default buildPluginAdapter('chat').extend({ diff --git a/assets/javascripts/admin/components/channel-details.js.es6 b/assets/javascripts/admin/components/channel-details.js.es6 index 3b9195c..7cc2b6c 100644 --- a/assets/javascripts/admin/components/channel-details.js.es6 +++ b/assets/javascripts/admin/components/channel-details.js.es6 @@ -12,25 +12,25 @@ export default Ember.Component.extend({ if (result) { channel.destroyRecord().then(() => { this.send('refresh'); - }).catch(popupAjaxError) + }).catch(popupAjaxError); } }); }, edit(channel){ - this.sendAction('edit', channel) + this.sendAction('edit', channel); }, test(channel){ - this.sendAction('test', channel) + this.sendAction('test', channel); }, createRule(channel){ - this.sendAction('createRule', channel) + this.sendAction('createRule', channel); }, editRule(rule){ - this.sendAction('editRule', rule, this.get('channel')) + this.sendAction('editRule', rule, this.get('channel')); }, showError(error_key){ diff --git a/assets/javascripts/admin/components/rule-row.js.es6 b/assets/javascripts/admin/components/rule-row.js.es6 index f246e98..63c9df7 100644 --- a/assets/javascripts/admin/components/rule-row.js.es6 +++ b/assets/javascripts/admin/components/rule-row.js.es6 @@ -4,31 +4,29 @@ export default Ember.Component.extend({ tagName: 'tr', isCategory: function(){ - return this.get('rule.type') == 'normal' + return this.get('rule.type') === 'normal'; }.property('rule.type'), isMessage: function(){ - return this.get('rule.type') == 'group_message' + return this.get('rule.type') === 'group_message'; }.property('rule.type'), isMention: function(){ - return this.get('rule.type') == 'group_mention' + return this.get('rule.type') === 'group_mention'; }.property('rule.type'), actions: { edit: function(){ - this.sendAction('edit', this.get('rule')) + this.sendAction('edit', this.get('rule')); }, delete(rule){ rule.destroyRecord().then(() => { this.send('refresh'); - }).catch(popupAjaxError) + }).catch(popupAjaxError); }, refresh: function(){ this.sendAction('refresh'); } - - } }); \ No newline at end of file diff --git a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 index 1d15db3..29684a1 100644 --- a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 +++ b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 @@ -1,9 +1,4 @@ -import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule' -import { ajax } from 'discourse/lib/ajax'; -import computed from "ember-addons/ember-computed-decorators"; import showModal from 'discourse/lib/show-modal'; -import { popupAjaxError } from 'discourse/lib/ajax-error'; - export default Ember.Controller.extend({ modalShowing: false, @@ -31,7 +26,7 @@ export default Ember.Controller.extend({ }, testChannel(channel){ this.set('modalShowing', true); - var model = {channel:channel} + var model = {channel:channel}; showModal('admin-plugins-chat-test', { model: model, admin: true }); }, diff --git a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-channel.js.es6 b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-channel.js.es6 index 3098a6e..5eb4c0c 100644 --- a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-channel.js.es6 +++ b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-channel.js.es6 @@ -1,6 +1,4 @@ -import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule' import ModalFunctionality from 'discourse/mixins/modal-functionality'; -import { ajax } from 'discourse/lib/ajax'; import { extractError } from 'discourse/lib/ajax-error'; import InputValidation from 'discourse/models/input-validation'; @@ -29,11 +27,11 @@ export default Ember.Controller.extend(ModalFunctionality, { var regex = new RegExp(regString); var val = this.get('model.channel.data.'+parameter.key); - if(val==undefined){ + if(val===undefined){ val = ""; } - if(val == ""){ // Fail silently if field blank + if(val === ""){ // Fail silently if field blank return InputValidation.create({ failed: true, }); @@ -56,7 +54,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }, _paramValidation: function(){ - var response = {} + var response = {}; var parameters = this.get('model.provider.channel_parameters'); parameters.forEach(parameter => { response[parameter.key] = this.validate(parameter); @@ -67,7 +65,7 @@ export default Ember.Controller.extend(ModalFunctionality, { saveDisabled: function(){ var validations = this.get('paramValidation'); - if(!validations){ return true } + if(!validations){ return true; } var invalid = false; @@ -89,11 +87,11 @@ export default Ember.Controller.extend(ModalFunctionality, { }, save: function(){ - if(this.get('saveDisabled')){return}; + if(this.get('saveDisabled')){return;}; const self = this; - this.get('model.channel').save().then(function(result) { + this.get('model.channel').save().then(function() { self.send('closeModal'); }).catch(function(error) { self.flash(extractError(error), 'error'); diff --git a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 index aa32187..f4fc0ee 100644 --- a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 +++ b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 @@ -1,8 +1,5 @@ -import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule' import ModalFunctionality from 'discourse/mixins/modal-functionality'; -import { ajax } from 'discourse/lib/ajax'; import { extractError } from 'discourse/lib/ajax-error'; -import InputValidation from 'discourse/models/input-validation'; import computed from "ember-addons/ember-computed-decorators"; export default Ember.Controller.extend(ModalFunctionality, { @@ -22,7 +19,7 @@ export default Ember.Controller.extend(ModalFunctionality, { @computed('model.rule.type') showCategory: function(type){ - return (type == "normal") + return (type === "normal"); }, actions: { @@ -31,11 +28,11 @@ export default Ember.Controller.extend(ModalFunctionality, { }, save: function(){ - if(this.get('saveDisabled')){return}; + if(this.get('saveDisabled')){return;}; const self = this; - this.get('model.rule').save().then(function(result) { + this.get('model.rule').save().then(function() { self.send('closeModal'); }).catch(function(error) { self.flash(extractError(error), 'error'); diff --git a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 index 3dba135..31a9968 100644 --- a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 +++ b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 @@ -14,15 +14,15 @@ export default Ember.Controller.extend(ModalFunctionality, { sendDisabled: function(){ if(this.get('model').topic_id){ - return false + return false; } - return true + return true; }.property('model.topic_id'), actions: { send: function(){ - if(this.get('sendDisabled')){return}; + if(this.get('sendDisabled')){return;}; self = this; this.set('loading', true); ajax("/admin/plugins/chat/test", { @@ -30,17 +30,17 @@ export default Ember.Controller.extend(ModalFunctionality, { topic_id: this.get('model.topic_id') }, type: 'POST' - }).then(function (result) { - self.set('loading', false) + }).then(function () { + self.set('loading', false); self.flash(I18n.t('chat_integration.test_modal.success'), 'success'); }, function(e) { self.set('loading', false); - var response = e.jqXHR.responseJSON - var error_key = 'chat_integration.test_modal.error' + var response = e.jqXHR.responseJSON; + var error_key = 'chat_integration.test_modal.error'; if(response['error_key']){ - error_key = response['error_key'] + error_key = response['error_key']; } self.flash(I18n.t(error_key), 'error'); diff --git a/assets/javascripts/admin/models/provider.js.es6 b/assets/javascripts/admin/models/provider.js.es6 index 70f1166..7a43358 100644 --- a/assets/javascripts/admin/models/provider.js.es6 +++ b/assets/javascripts/admin/models/provider.js.es6 @@ -1,6 +1,4 @@ import RestModel from 'discourse/models/rest'; -import Category from 'discourse/models/category'; -import computed from "ember-addons/ember-computed-decorators"; export default RestModel.extend({ diff --git a/assets/javascripts/admin/models/rule.js.es6 b/assets/javascripts/admin/models/rule.js.es6 index 70fab17..f3c4770 100644 --- a/assets/javascripts/admin/models/rule.js.es6 +++ b/assets/javascripts/admin/models/rule.js.es6 @@ -25,7 +25,7 @@ export default RestModel.extend({ removeUnneededInfo: function(){ const type=this.get('type'); - if(type=='normal'){ + if(type==='normal'){ this.set('group_id', null); }else{ this.set('category_id', null); diff --git a/assets/javascripts/admin/routes/admin-plugins-chat-index.js.es6 b/assets/javascripts/admin/routes/admin-plugins-chat-index.js.es6 index 8889117..313e65c 100644 --- a/assets/javascripts/admin/routes/admin-plugins-chat-index.js.es6 +++ b/assets/javascripts/admin/routes/admin-plugins-chat-index.js.es6 @@ -1,7 +1,5 @@ -import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider' - export default Discourse.Route.extend({ - afterModel(model, transition) { + afterModel(model) { if(model.totalRows > 0){ this.transitionTo('adminPlugins.chat.provider', model.get('firstObject').name); diff --git a/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 b/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 index 216f407..eefbe83 100644 --- a/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 +++ b/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 @@ -1,9 +1,8 @@ -import { ajax } from 'discourse/lib/ajax'; import Group from 'discourse/models/group'; export default Discourse.Route.extend({ - model(params, transition) { + model(params) { return Ember.RSVP.hash({ channels: this.store.findAll('channel', {provider: params.provider}), provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider), @@ -22,12 +21,12 @@ export default Discourse.Route.extend({ }); }, - serialize: function(model, params) { + serialize: function(model) { return { provider: model['provider'].get('id')}; }, actions: { - closeModal: function(data){ + closeModal: function(){ if(this.get('controller.modalShowing')){ this.refresh(); this.set('controller.modalShowing', false); @@ -36,7 +35,7 @@ export default Discourse.Route.extend({ return true; // Continue bubbling up, so the modal actually closes }, - refresh: function(data){ + refresh: function(){ this.refresh(); } diff --git a/assets/javascripts/admin/routes/admin-plugins-chat.js.es6 b/assets/javascripts/admin/routes/admin-plugins-chat.js.es6 index 98aab8d..7975516 100644 --- a/assets/javascripts/admin/routes/admin-plugins-chat.js.es6 +++ b/assets/javascripts/admin/routes/admin-plugins-chat.js.es6 @@ -1,7 +1,5 @@ -import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider' - export default Discourse.Route.extend({ - model(params, transition) { + model() { return this.store.findAll('provider'); }, diff --git a/test/javascripts/acceptance/chat-integration-test.js.es6 b/test/javascripts/acceptance/chat-integration-test.js.es6 index f286203..776af81 100644 --- a/test/javascripts/acceptance/chat-integration-test.js.es6 +++ b/test/javascripts/acceptance/chat-integration-test.js.es6 @@ -10,34 +10,34 @@ acceptance("Chat Integration", { object ]; }; - server.get('/admin/plugins/chat/providers', () => { + server.get('/admin/plugins/chat/providers', () => { // eslint-disable-line no-undef return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] }); }); - server.get('/admin/plugins/chat/channels', () => { + server.get('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef return response({"channels":[{"id":97,"provider":"dummy","data":{val:"#general"},"rules":[{"id":98,"channel_id":97,"category_id":null,"tags":[],"filter":"watch","error_key":null}]}]}); }); - server.post('/admin/plugins/chat/channels', () => { + server.post('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef return response({ }); }); - server.put('/admin/plugins/chat/channels/:id', () => { + server.put('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef + return response({ }); + }); + server.delete('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef return response({ }); }); - server.delete('/admin/plugins/chat/channels/:id', () => { + server.post('/admin/plugins/chat/rules', () => { // eslint-disable-line no-undef return response({ }); }); - server.post('/admin/plugins/chat/rules', () => { + server.put('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef return response({ }); }); - server.put('/admin/plugins/chat/rules/:id', () => { + server.delete('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef return response({ }); }); - server.delete('/admin/plugins/chat/rules/:id', () => { + server.post('/admin/plugins/chat/test', () => { // eslint-disable-line no-undef return response({ }); }); - server.post('/admin/plugins/chat/test', () => { - return response({ }); - }); - server.get('/groups/search.json', () => { + server.get('/groups/search.json', () => { // eslint-disable-line no-undef return response([]); }); @@ -69,7 +69,7 @@ test("Create channel works", assert => { andThen(() => { assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button'); - }) + }); andThen(() => { click('#save_channel'); @@ -77,7 +77,7 @@ test("Create channel works", assert => { andThen(() => { assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save'); - }) + }); }); @@ -166,6 +166,6 @@ test("Test provider works", assert => { andThen(() => { assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send'); assert.ok(exists('#modal-alert.alert-success'), 'success message displayed'); - }) + }); }); \ No newline at end of file