FIX: eslint deprecations

This commit is contained in:
Robin Ward 2015-08-13 15:14:08 -04:00
parent 946e34f65c
commit b0541500b4
23 changed files with 59 additions and 70 deletions

View file

@ -1,12 +1,3 @@
/**
This controller supports the interface for granting and revoking badges from
individual users.
@class AdminUserBadgesController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend({
needs: ["adminUser"],
user: Em.computed.alias('controllers.adminUser'),
@ -14,12 +5,12 @@ export default Ember.ArrayController.extend({
sortAscending: false,
groupedBadges: function(){
const badges = this.get('model');
const allBadges = this.get('model');
var grouped = _.groupBy(badges, badge => badge.badge_id);
var grouped = _.groupBy(allBadges, badge => badge.badge_id);
var expanded = [];
const expandedBadges = badges.get('expandedBadges');
const expandedBadges = allBadges.get('expandedBadges');
_(grouped).each(function(badges){
var lastGranted = badges[0].granted_at;

View file

@ -8,8 +8,8 @@ export default Ember.Component.extend({
const filterMode = this.get('filterMode'),
navItems = this.get('navItems');
var item = navItems.find(function(item){
return item.get('filterMode').indexOf(filterMode) === 0;
var item = navItems.find(function(i){
return i.get('filterMode').indexOf(filterMode) === 0;
});
return item || navItems[0];

View file

@ -45,8 +45,8 @@ export default Ember.Component.extend({
this.rerender();
});
on('th.sortable', function(e){
this.sendAction('changeSort', e.data('sort-order'));
on('th.sortable', function(e2){
this.sendAction('changeSort', e2.data('sort-order'));
this.rerender();
});
}

View file

@ -19,8 +19,8 @@ Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) {
/*
* Used when we only have a template
*/
Em.Handlebars.helper('bound-avatar-template', function(avatarTemplate, size) {
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: avatarTemplate }));
Em.Handlebars.helper('bound-avatar-template', function(at, size) {
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: at }));
});
registerUnbound('raw-date', function(dt) {

View file

@ -12,8 +12,8 @@ export default {
const messageBus = container.lookup('message-bus:main');
if (!messageBus) { return; }
messageBus.subscribe("/site/banner", function (banner) {
site.set("banner", Em.Object.create(banner));
messageBus.subscribe("/site/banner", function (ban) {
site.set("banner", Em.Object.create(ban));
});
}
};

View file

@ -12,7 +12,7 @@ var dummy = document.createElement("div"),
ms: "MSTransitionEnd"
};
var transitionEnd = function() {
var transitionEnd = (function() {
var retValue;
retValue = "transitionend";
Object.keys(eventNameHash).some(function(vendor) {
@ -22,7 +22,7 @@ var transitionEnd = function() {
}
});
return retValue;
}();
})();
export default function (element, callback) {
return $(element).on(transitionEnd, callback);

View file

@ -290,7 +290,7 @@ export default function(options) {
});
$(this).on('keydown.autocomplete', function(e) {
var c, caretPosition, i, initial, next, prev, prevIsGood, stopFound, term, total, userToComplete;
var c, caretPosition, i, initial, prev, prevIsGood, stopFound, term, total, userToComplete;
if(e.ctrlKey || e.altKey || e.metaKey){
return true;
@ -322,7 +322,6 @@ export default function(options) {
if (e.which === keys.shift) return;
if ((completeStart === null) && e.which === keys.backSpace && options.key) {
c = Discourse.Utilities.caretPosition(me[0]);
next = me[0].value[c];
c -= 1;
initial = c;
prevIsGood = true;

View file

@ -1,3 +1,4 @@
/*eslint no-bitwise:0 */
let _splitAvatars;
function defaultAvatar(username) {

View file

@ -186,8 +186,8 @@ var bindEvents = function(page,offset){
});
$('.emoji-modal .toolbar a').click(function(){
var page = parseInt($(this).data('group-id'));
render(page,0);
var p = parseInt($(this).data('group-id'));
render(p, 0);
return false;
});
};

View file

@ -234,12 +234,12 @@ const PostStream = RestModel.extend({
this.set('gaps', this.get('gaps') || {before: {}, after: {}});
const before = this.get('gaps.before');
const post = posts.find(function(post){
return post.get('post_number') > to;
const post = posts.find(function(p){
return p.get('post_number') > to;
});
before[post.get('id')] = remove.map(function(post){
return post.get('id');
before[post.get('id')] = remove.map(function(p){
return p.get('id');
});
post.set('hasGap', true);
@ -491,8 +491,8 @@ const PostStream = RestModel.extend({
// we need to zip this into the stream
let index = 0;
stream.forEach(function(postId){
if(postId < p.id){
stream.forEach(function(pid){
if (pid < p.id){
index+= 1;
}
});

View file

@ -3,6 +3,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
import ActionSummary from 'discourse/models/action-summary';
import { url, fmt, propertyEqual } from 'discourse/lib/computed';
import Quote from 'discourse/lib/quote';
import computed from 'ember-addons/ember-computed-decorators';
const Post = RestModel.extend({
@ -54,10 +55,10 @@ const Post = RestModel.extend({
}.property('post_number', 'topic_id', 'topic.slug'),
// Don't drop the /1
urlWithNumber: function() {
const url = this.get('url');
return (this.get('post_number') === 1) ? url + "/1" : url;
}.property('post_number', 'url'),
@computed('post_number', 'url')
urlWithNumber(postNumber, postUrl) {
return postNumber === 1 ? postUrl + "/1" : postUrl;
},
usernameUrl: url('username', '/users/%@'),

View file

@ -54,18 +54,18 @@ export default RestModel.extend({
findItems() {
const self = this;
let url = this.get('baseUrl');
let findUrl = this.get('baseUrl');
if (this.get('filterParam')) {
url += "&filter=" + this.get('filterParam');
findUrl += "&filter=" + this.get('filterParam');
}
// Don't load the same stream twice. We're probably at the end.
const lastLoadedUrl = this.get('lastLoadedUrl');
if (lastLoadedUrl === url) { return Ember.RSVP.resolve(); }
if (lastLoadedUrl === findUrl) { return Ember.RSVP.resolve(); }
if (this.get('loading')) { return Ember.RSVP.resolve(); }
this.set('loading', true);
return Discourse.ajax(url, {cache: 'false'}).then( function(result) {
return Discourse.ajax(findUrl, {cache: 'false'}).then( function(result) {
if (result && result.user_actions) {
const copy = Em.A();
result.user_actions.forEach(function(action) {
@ -81,7 +81,7 @@ export default RestModel.extend({
}
}).finally(function() {
self.set('loading', false);
self.set('lastLoadedUrl', url);
self.set('lastLoadedUrl', findUrl);
});
}

View file

@ -5,6 +5,7 @@ import UserStream from 'discourse/models/user-stream';
import UserPostsStream from 'discourse/models/user-posts-stream';
import Singleton from 'discourse/mixins/singleton';
import { longDate } from 'discourse/lib/formatter';
import computed from 'ember-addons/ember-computed-decorators';
const User = RestModel.extend({
@ -53,17 +54,11 @@ const User = RestModel.extend({
return this.get('username');
}.property('username', 'name'),
/**
This user's profile background(in CSS).
@property profileBackground
@type {String}
**/
profileBackground: function() {
var url = this.get('profile_background');
if (Em.isEmpty(url) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
return ('background-image: url(' + Discourse.getURLWithCDN(url) + ')').htmlSafe();
}.property('profile_background'),
@computed('profile_background')
profileBackground(bgUrl) {
if (Em.isEmpty(bgUrl) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
return ('background-image: url(' + Discourse.getURLWithCDN(bgUrl) + ')').htmlSafe();
},
/**
Path to this user.
@ -206,10 +201,10 @@ const User = RestModel.extend({
return Discourse.ajax("/users/" + this.get('username_lower'), {
data: data,
type: 'PUT'
}).then(function(data) {
self.set('bio_excerpt',data.user.bio_excerpt);
}).then(function(result) {
self.set('bio_excerpt', result.user.bio_excerpt);
var userProps = self.getProperties('enable_quoting', 'external_links_in_new_tab', 'dynamic_favicon');
const userProps = self.getProperties('enable_quoting', 'external_links_in_new_tab', 'dynamic_favicon');
Discourse.User.current().setProperties(userProps);
}).finally(() => {
this.set('isSaving', false);

View file

@ -86,9 +86,9 @@ export default function(filter, extras) {
ScreenTrack.current().stop();
const findOpts = filterQueryParams(transition.queryParams),
extras = { cached: this.isPoppedState(transition) };
findExtras = { cached: this.isPoppedState(transition) };
return findTopicList(this.store, filter, findOpts, extras);
return findTopicList(this.store, filter, findOpts, findExtras);
},
titleToken() {

View file

@ -13,7 +13,7 @@ const DiscourseRoute = Ember.Route.extend({
params = this.controller.getProperties(Object.keys(this.queryParams));
model.set('loading', true);
this.model(params).then(model => this.setupController(controller, model));
this.model(params).then(m => this.setupController(controller, m));
}
},

View file

@ -31,7 +31,7 @@ export default Discourse.Route.extend({
willTransition(transition) {
// will reset the indexStream when transitioning to routes that aren't "indexStream"
// otherwise the "header" will jump
const isIndexStream = ~INDEX_STREAM_ROUTES.indexOf(transition.targetName);
const isIndexStream = INDEX_STREAM_ROUTES.indexOf(transition.targetName) !== -1;
this.controllerFor('user').set('indexStream', isIndexStream);
return true;
}

View file

@ -1,3 +1,4 @@
/*eslint no-bitwise:0 */
import CloakedView from 'discourse/views/cloaked';
const CloakedCollectionView = Ember.CollectionView.extend({

View file

@ -217,7 +217,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
initEditor() {
// not quite right, need a callback to pass in, meaning this gets called once,
// but if you start replying to another topic it will get the avatars wrong
let $wmdInput, editor;
let $wmdInput;
const self = this;
this.wmdInput = $wmdInput = this.$('.wmd-input');
if ($wmdInput.length === 0 || $wmdInput.data('init') === true) return;
@ -243,7 +243,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
}
});
this.editor = editor = Discourse.Markdown.createEditor({
this.editor = Discourse.Markdown.createEditor({
containerElement: this.element,
lookupAvatarByPostNumber(postNumber, topicId) {
const posts = self.get('controller.controllers.topic.model.postStream.posts');

View file

@ -55,7 +55,6 @@ export default Ember.View.extend({
$li.removeClass('active');
$html.data('hide-dropdown', null);
const controller = self.get('controller');
if (controller && !controller.isDestroyed){
controller.set('visibleDropdown', null);
}

View file

@ -256,8 +256,8 @@ const PostView = Discourse.GroupedView.extend(Ember.Evented, {
// Unless it's a full quote, allow click to expand
if (!($aside.data('full') || $title.data('has-quote-controls'))) {
$title.on('click', function(e) {
if ($(e.target).is('a')) return true;
$title.on('click', function(e2) {
if ($(e2.target).is('a')) return true;
self._toggleQuote($aside);
});
$title.data('has-quote-controls', true);

View file

@ -34,8 +34,10 @@ task 'docker:test' do
@good &&= run_or_fail("bundle exec rspec")
end
unless ENV["RUBY_ONLY"]
@good &&= run_or_fail("eslint app/assets/javascripts")
@good &&= run_or_fail("eslint --ext \".es6\" app/assets/javascripts")
@good &&= run_or_fail("eslint --ext \".es6\" test/javascripts")
@good &&= run_or_fail("eslint test/javascripts")
@good &&= run_or_fail("bundle exec rake qunit:test")
end

View file

@ -93,8 +93,8 @@ _.each(clickBindings, function(selector, binding) {
ok(true, selector + " was clicked");
});
_.each(bindings, function(binding) {
testMouseTrap.trigger(binding);
_.each(bindings, function(b) {
testMouseTrap.trigger(b);
}, this);
});
});

View file

@ -37,10 +37,10 @@ test('passwordValidation', function() {
equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid');
var testInvalidPassword = function(password, expectedReason) {
var controller = subject();
controller.set('accountPassword', password);
equal(controller.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
equal(controller.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
var c = subject();
c.set('accountPassword', password);
equal(c.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
equal(c.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
};
testInvalidPassword('', undefined);