Added linting for JavaScript tests.

This commit is contained in:
Nik Nyby 2015-08-26 00:24:55 -04:00 committed by Tim Graham
parent 0e925de245
commit 722bf23518
10 changed files with 58 additions and 15 deletions

View File

@ -1,3 +1,7 @@
/* global module, test, DateTimeShortcuts */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.DateTimeShortcuts'); module('admin.DateTimeShortcuts');
test('init', function(assert) { test('init', function(assert) {

View File

@ -1,3 +1,8 @@
/* global module, test, html_unescape, id_to_windowname,
windowname_to_id */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.RelatedObjectLookups'); module('admin.RelatedObjectLookups');
test('html_unescape', function(assert) { test('html_unescape', function(assert) {

View File

@ -1,10 +1,14 @@
/* global module, test, SelectBox */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.SelectBox'); module('admin.SelectBox');
test('init: no options', function(assert) { test('init: no options', function(assert) {
var $ = django.jQuery; var $ = django.jQuery;
$('<select id="id"></select>').appendTo('#qunit-fixture'); $('<select id="id"></select>').appendTo('#qunit-fixture');
SelectBox.init('id'); SelectBox.init('id');
assert.equal(SelectBox.cache['id'].length, 0); assert.equal(SelectBox.cache.id.length, 0);
}); });
test('filter', function(assert) { test('filter', function(assert) {

View File

@ -1,3 +1,7 @@
/* global module, test, SelectFilter */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.SelectFilter2'); module('admin.SelectFilter2');
test('init', function(assert) { test('init', function(assert) {

View File

@ -1,7 +1,13 @@
/* global module, test */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.actions', { module('admin.actions', {
beforeEach: function() { beforeEach: function() {
// Number of results shown on page // Number of results shown on page
/* eslint-disable */
window._actions_icnt = '100'; window._actions_icnt = '100';
/* eslint-enable */
var $ = django.jQuery; var $ = django.jQuery;
$('#qunit-fixture').append($('#result-table').text()); $('#qunit-fixture').append($('#result-table').text());

View File

@ -1,3 +1,7 @@
/* global module, test */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.core'); module('admin.core');
test('Date.getTwelveHours', function(assert) { test('Date.getTwelveHours', function(assert) {

View File

@ -1,3 +1,7 @@
/* global module, test */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.inlines: tabular formsets', { module('admin.inlines: tabular formsets', {
beforeEach: function() { beforeEach: function() {
var $ = django.jQuery; var $ = django.jQuery;

View File

@ -1,22 +1,30 @@
(function (globals) { (function(globals) {
'use strict';
var django = globals.django || (globals.django = {}); var django = globals.django || (globals.django = {});
django.pluralidx = function (count) { return (count == 1) ? 0 : 1; }; django.pluralidx = function(count) { return (count === 1) ? 0 : 1; };
/* gettext identity library */ /* gettext identity library */
django.gettext = function (msgid) { return msgid; }; django.gettext = function(msgid) { return msgid; };
django.ngettext = function (singular, plural, count) { return (count == 1) ? singular : plural; }; django.ngettext = function(singular, plural, count) {
django.gettext_noop = function (msgid) { return msgid; }; return (count === 1) ? singular : plural;
django.pgettext = function (context, msgid) { return msgid; }; };
django.npgettext = function (context, singular, plural, count) { return (count == 1) ? singular : plural; }; django.gettext_noop = function(msgid) { return msgid; };
django.pgettext = function(context, msgid) { return msgid; };
django.npgettext = function(context, singular, plural, count) {
return (count === 1) ? singular : plural;
};
django.interpolate = function (fmt, obj, named) { django.interpolate = function(fmt, obj, named) {
if (named) { if (named) {
return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])}); return fmt.replace(/%\(\w+\)s/g, function(match) {
return String(obj[match.slice(2, -2)]);
});
} else { } else {
return fmt.replace(/%s/g, function(match){return String(obj.shift())}); return fmt.replace(/%s/g, function(match) {
return String(obj.shift());
});
} }
}; };
@ -60,9 +68,9 @@
"YEAR_MONTH_FORMAT": "F Y" "YEAR_MONTH_FORMAT": "F Y"
}; };
django.get_format = function (format_type) { django.get_format = function(format_type) {
var value = django.formats[format_type]; var value = django.formats[format_type];
if (typeof(value) == 'undefined') { if (typeof value === 'undefined') {
return format_type; return format_type;
} else { } else {
return value; return value;

View File

@ -1,3 +1,7 @@
/* global module, test, parseTimeString */
/* eslint global-strict: 0, strict: 0 */
'use strict';
module('admin.timeparse'); module('admin.timeparse');
test('parseTimeString', function(assert) { test('parseTimeString', function(assert) {

View File

@ -2,7 +2,7 @@
"name": "Django", "name": "Django",
"private": true, "private": true,
"scripts": { "scripts": {
"pretest": "eslint django/", "pretest": "eslint django/ js_tests/admin/",
"test": "grunt test --verbose" "test": "grunt test --verbose"
}, },
"devDependencies": { "devDependencies": {