Browse Source

Added linting for JavaScript tests.

Nik Nyby 9 years ago
parent
commit
722bf23518

+ 4 - 0
js_tests/admin/DateTimeShortcuts.test.js

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

+ 5 - 0
js_tests/admin/RelatedObjectLookups.test.js

@@ -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');
 
 test('html_unescape', function(assert) {

+ 5 - 1
js_tests/admin/SelectBox.test.js

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

+ 4 - 0
js_tests/admin/SelectFilter2.test.js

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

+ 6 - 0
js_tests/admin/actions.test.js

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

+ 4 - 0
js_tests/admin/core.test.js

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

+ 4 - 0
js_tests/admin/inlines.test.js

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

+ 21 - 13
js_tests/admin/jsi18n-mocks.test.js

@@ -1,22 +1,30 @@
-(function (globals) {
-
+(function(globals) {
+    'use strict';
     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 */
 
-    django.gettext = function (msgid) { return msgid; };
-    django.ngettext = function (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.gettext = function(msgid) { return msgid; };
+    django.ngettext = function(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) {
-            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 {
-            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"
     };
 
-    django.get_format = function (format_type) {
+    django.get_format = function(format_type) {
         var value = django.formats[format_type];
-        if (typeof(value) == 'undefined') {
+        if (typeof value === 'undefined') {
             return format_type;
         } else {
             return value;

+ 4 - 0
js_tests/admin/timeparse.test.js

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

+ 1 - 1
package.json

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