mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 07:01:13 +08:00
Merge pull request #2092 from nschonni/jshinting
Jshinting during CI build
This commit is contained in:
15
.jshintignore
Normal file
15
.jshintignore
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
app/assets/javascripts/defer/html-sanitizer-bundle.js
|
||||||
|
app/assets/javascripts/locales/
|
||||||
|
lib/autospec/run-qunit.js
|
||||||
|
lib/headless-ember.js
|
||||||
|
lib/javascripts/locale/
|
||||||
|
lib/javascripts/messageformat.js
|
||||||
|
lib/javascripts/moment.js
|
||||||
|
lib/javascripts/moment_locale/
|
||||||
|
public/javascripts/
|
||||||
|
spec/phantom_js/smoke_test.js
|
||||||
|
test/javascripts/helpers/assertions.js
|
||||||
|
test/javascripts/helpers/parse_html.js
|
||||||
|
test/javascripts/helpers/qunit_helpers.js
|
||||||
|
test/javascripts/test_helper.js
|
||||||
|
vendor/
|
@ -2,6 +2,9 @@ language: ruby
|
|||||||
rvm:
|
rvm:
|
||||||
- 2.0.0
|
- 2.0.0
|
||||||
- 2.1.1
|
- 2.1.1
|
||||||
|
before_install:
|
||||||
|
- npm i -g jshint
|
||||||
|
- jshint .
|
||||||
before_script:
|
before_script:
|
||||||
- psql -c 'create database discourse_test;' -U postgres
|
- psql -c 'create database discourse_test;' -U postgres
|
||||||
- export DISCOURSE_HOSTNAME=www.example.com
|
- export DISCOURSE_HOSTNAME=www.example.com
|
||||||
|
@ -1,40 +1,28 @@
|
|||||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
||||||
if (!Array.prototype.indexOf) {
|
if (!Array.prototype.indexOf) {
|
||||||
Array.prototype.indexOf = function(searchElement /*, fromIndex */) {
|
Array.prototype.indexOf = function (searchElement, fromIndex) {
|
||||||
"use strict";
|
if ( this === undefined || this === null ) {
|
||||||
|
throw new TypeError( '"this" is null or not defined' );
|
||||||
if (this === void 0 || this === null) {
|
|
||||||
throw new TypeError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var t = Object(this);
|
var length = this.length >>> 0; // Hack to convert object.length to a UInt32
|
||||||
var len = t.length >>> 0;
|
|
||||||
|
|
||||||
if (len === 0) {
|
fromIndex = +fromIndex || 0;
|
||||||
return -1;
|
|
||||||
|
if (Math.abs(fromIndex) === Infinity) {
|
||||||
|
fromIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var n = 0;
|
if (fromIndex < 0) {
|
||||||
if (arguments.length > 0) {
|
fromIndex += length;
|
||||||
n = Number(arguments[1]);
|
if (fromIndex < 0) {
|
||||||
if (n !== n) { // shortcut for verifying if it's NaN
|
fromIndex = 0;
|
||||||
n = 0;
|
|
||||||
} else if (n !== 0 && n !== (Infinity) && n !== -(Infinity)) {
|
|
||||||
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n >= len) {
|
for (;fromIndex < length; fromIndex++) {
|
||||||
return -1;
|
if (this[fromIndex] === searchElement) {
|
||||||
}
|
return fromIndex;
|
||||||
|
|
||||||
var k = n >= 0
|
|
||||||
? n
|
|
||||||
: Math.max(len - Math.abs(n), 0);
|
|
||||||
|
|
||||||
for (; k < len; k++) {
|
|
||||||
if (k in t && t[k] === searchElement) {
|
|
||||||
return k;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ var Poll = Discourse.Model.extend({
|
|||||||
options.push(Ember.Object.create({
|
options.push(Ember.Object.create({
|
||||||
option: option,
|
option: option,
|
||||||
votes: json["options"][option],
|
votes: json["options"][option],
|
||||||
checked: (option == selectedOption)
|
checked: (option === selectedOption)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
this.set('options', options);
|
this.set('options', options);
|
||||||
@ -22,7 +22,7 @@ var Poll = Discourse.Model.extend({
|
|||||||
|
|
||||||
saveVote: function(option) {
|
saveVote: function(option) {
|
||||||
this.get('options').forEach(function(opt) {
|
this.get('options').forEach(function(opt) {
|
||||||
opt.set('checked', opt.get('option') == option);
|
opt.set('checked', opt.get('option') === option);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Discourse.ajax("/poll", {
|
return Discourse.ajax("/poll", {
|
||||||
@ -99,7 +99,7 @@ Discourse.PostView.reopen({
|
|||||||
var view = initializePollView(this);
|
var view = initializePollView(this);
|
||||||
|
|
||||||
var pollContainer = $post.find(".poll-ui:first");
|
var pollContainer = $post.find(".poll-ui:first");
|
||||||
if (pollContainer.length == 0) {
|
if (pollContainer.length === 0) {
|
||||||
pollContainer = $post.find("ul:first");
|
pollContainer = $post.find("ul:first");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user