Skip to content

Commit

Permalink
Clean up jscs and jshint errors in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
timrwood authored and ichernev committed Mar 25, 2015
1 parent d5262a0 commit 9494aaf
Show file tree
Hide file tree
Showing 41 changed files with 183 additions and 177 deletions.
3 changes: 2 additions & 1 deletion .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"validateQuoteMarks": {
"mark": "'",
"escape": true
}
},
"esnext": true
}
31 changes: 31 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"node" : true,
"browser" : true,
"boss" : false,
"curly" : true,
"debug" : false,
"devel" : false,
"eqeqeq" : true,
"eqnull" : true,
"esnext" : true,
"evil" : false,
"forin" : false,
"immed" : false,
"laxbreak" : false,
"newcap" : true,
"noarg" : true,
"noempty" : false,
"nonew" : false,
"onevar" : true,
"plusplus" : false,
"regexp" : false,
"undef" : true,
"sub" : true,
"strict" : false,
"white" : true,
"es3" : false,
"camelcase" : true,
"globals": {
"define": false
}
}
29 changes: 1 addition & 28 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,34 +133,7 @@ module.exports = function (grunt) {
'!test/browser*.js'
],
options: {
'node' : true,
'browser' : true,
'boss' : false,
'curly' : true,
'debug' : false,
'devel' : false,
'eqeqeq' : true,
'eqnull' : true,
'evil' : false,
'forin' : false,
'immed' : false,
'laxbreak' : false,
'newcap' : true,
'noarg' : true,
'noempty' : false,
'nonew' : false,
'onevar' : true,
'plusplus' : false,
'regexp' : false,
'undef' : true,
'sub' : true,
'strict' : false,
'white' : true,
'es3' : true,
'camelcase' : true,
'globals': {
'define': false
}
jshintrc: true
}
},
jscs: {
Expand Down
4 changes: 3 additions & 1 deletion test/helpers/each.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function (array, callback) {
function each(array, callback) {
var i;
for (i = 0; i < array.length; i++) {
callback(array[i], i, array);
}
}

export default each;
6 changes: 3 additions & 3 deletions test/moment/add_subtract.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("add and subtract");
module('add and subtract');

test('add short reverse args', function (assert) {
var a = moment(), b, c, d;
Expand Down
14 changes: 7 additions & 7 deletions test/moment/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("create");
module('create');

test('array', function (assert) {
assert.ok(moment([2010]).toDate() instanceof Date, '[2010]');
Expand Down Expand Up @@ -344,12 +344,12 @@ test('string with array of formats', function (assert) {
['MM/DD/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', 'YYYY-MM-DDTHH:mm:ssZ'])
.format('YYYY-MM-DD'), '2011-07-01', 'Works for long strings');

assert.equal(moment('11-02-10', ['MM.DD.YY', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'escape RegExp special characters on comparing');
assert.equal(moment('11-02-10', ['MM.DD.YY', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'escape RegExp special characters on comparing');

assert.equal(moment('13-10-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year');
assert.equal(moment('13-10-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year');
assert.equal(moment('13-10-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year');
assert.equal(moment('13-10-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year');

assert.equal(moment('01', ['MM', 'DD'])._f, 'MM', 'Should use first valid format');
assert.equal(moment('01', ['MM', 'DD'])._f, 'MM', 'Should use first valid format');
});

test('string with array of formats + ISO', function (assert) {
Expand Down
12 changes: 6 additions & 6 deletions test/moment/days_in_month.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import each from "../helpers/each";
import { module, test } from '../qunit';
import moment from '../../moment';
import each from '../helpers/each';

module('days in month');

test('days in month', function (assert) {
each([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], function (days, i) {
var firstDay = moment([2012, i]);
var lastDay = moment([2012, i, days]);
var firstDay = moment([2012, i]),
lastDay = moment([2012, i, days]);
assert.equal(firstDay.daysInMonth(), days, firstDay.format('L') + ' should have ' + days + ' days.');
assert.equal( lastDay.daysInMonth(), days, lastDay.format('L') + ' should have ' + days + ' days.');
assert.equal(lastDay.daysInMonth(), days, lastDay.format('L') + ' should have ' + days + ' days.');
});
});

Expand Down
6 changes: 3 additions & 3 deletions test/moment/diff.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

function equal(assert, a, b, message) {
assert.ok(Math.abs(a - b) < 0.00000001, '(' + a + ' === ' + b + ') ' + message);
Expand Down Expand Up @@ -103,7 +103,7 @@ test('diff month', function (assert) {
});

test('diff across DST', function (assert) {
var dst = dstForYear(2012), a, b, daysInMonth;
var dst = dstForYear(2012), a, b, daysInMonth;
if (!dst) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/moment/duration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('duration');

Expand Down
4 changes: 2 additions & 2 deletions test/moment/duration_from_moments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('duration from moments');

Expand Down
8 changes: 4 additions & 4 deletions test/moment/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('format');

Expand Down Expand Up @@ -119,9 +119,9 @@ test('escaping quotes', function (assert) {
moment.locale('en');
var date = moment([2012, 0]);
assert.equal(date.format('MMM \'YY'), 'Jan \'12', 'Should be able to format with single parenthesis');
assert.equal(date.format("MMM 'YY"), 'Jan \'12', 'Should be able to format with double parenthesis');
assert.equal(date.format('MMM "YY'), 'Jan "12', 'Should be able to format with double parenthesis');
assert.equal(date.format('MMM \'YY'), 'Jan \'12', 'Should be able to format with single parenthesis');
assert.equal(date.format("MMM 'YY"), 'Jan \'12', 'Should be able to format with double parenthesis');
assert.equal(date.format('MMM "YY'), 'Jan "12', 'Should be able to format with double parenthesis');
});

test('toJSON', function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions test/moment/getters_setters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('getters and setters');

Expand Down
4 changes: 2 additions & 2 deletions test/moment/invalid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('invalid');

Expand Down
4 changes: 2 additions & 2 deletions test/moment/is_after.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module('is after');

Expand Down
6 changes: 3 additions & 3 deletions test/moment/is_before.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is before");
module('is before');

test('is after without units', function (assert) {
var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
Expand Down
6 changes: 3 additions & 3 deletions test/moment/is_between.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is between");
module('is between');

test('is between without units', function (assert) {
var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
Expand Down
8 changes: 4 additions & 4 deletions test/moment/is_date.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is date");
module('is date');

test('isDate recognizes Date objects', function (assert) {
assert.ok(moment.isDate(new Date()), 'no args (now)');
assert.ok(moment.isDate(new Date([2014, 02, 15])), 'array args');
assert.ok(moment.isDate(new Date([2014, 2, 15])), 'array args');
assert.ok(moment.isDate(new Date('2014-03-15')), 'string args');
assert.ok(moment.isDate(new Date('does NOT look like a date')), 'invalid date');
});
Expand Down
6 changes: 3 additions & 3 deletions test/moment/is_moment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is moment");
module('is moment');

test('is moment object', function (assert) {
var MyObj = function () {},
Expand Down
6 changes: 3 additions & 3 deletions test/moment/is_same.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is same");
module('is same');

test('is same without units', function (assert) {
var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
Expand Down
8 changes: 4 additions & 4 deletions test/moment/is_valid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("is valid");
module('is valid');

test('array bad month', function (assert) {
assert.equal(moment([2010, -1]).isValid(), false, 'month -1 invalid');
Expand Down Expand Up @@ -135,7 +135,7 @@ test('invalidAt', function (assert) {
assert.equal(moment([2000, 12]).invalidAt(), 1, 'month 12 is invalid: 0-11');
assert.equal(moment([2000, 1, 30]).invalidAt(), 2, '30 is not a valid february day');
assert.equal(moment([2000, 1, 29, 25]).invalidAt(), 3, '25 is invalid hour');
assert.equal(moment([2000, 1, 29, 24, 01]).invalidAt(), 3, '24:01 is invalid hour');
assert.equal(moment([2000, 1, 29, 24, 1]).invalidAt(), 3, '24:01 is invalid hour');
assert.equal(moment([2000, 1, 29, 23, 60]).invalidAt(), 4, '60 is invalid minute');
assert.equal(moment([2000, 1, 29, 23, 59, 60]).invalidAt(), 5, '60 is invalid second');
assert.equal(moment([2000, 1, 29, 23, 59, 59, 1000]).invalidAt(), 6, '1000 is invalid millisecond');
Expand Down
6 changes: 3 additions & 3 deletions test/moment/leapyear.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("leap year");
module('leap year');

test('leap year', function (assert) {
assert.equal(moment([2010, 0, 1]).isLeapYear(), false, '2010');
Expand Down
6 changes: 3 additions & 3 deletions test/moment/listers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("listers");
module('listers');

test('default', function (assert) {
assert.deepEqual(moment.months(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
Expand Down
24 changes: 12 additions & 12 deletions test/moment/locale.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import each from "../helpers/each";
import { module, test } from '../qunit';
import moment from '../../moment';
import each from '../helpers/each';

module("locale", {
module('locale', {
setup : function () {
// TODO: Remove once locales are switched to ES6
each([{
name: "en-gb",
name: 'en-gb',
data: {}
}, {
name: "en-ca",
name: 'en-ca',
data: {}
}, {
name: "es",
name: 'es',
data: {
relativeTime: { past: 'hace %s', s: 'unos segundos', d: 'un día' },
relativeTime: {past: 'hace %s', s: 'unos segundos', d: 'un día'},
months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_')
}
}, {
name: "fr",
name: 'fr',
data: {}
}, {
name: "fr-ca",
name: 'fr-ca',
data: {}
}, {
name: "it",
name: 'it',
data: {}
}, {
name: "zh-cn",
name: 'zh-cn',
data: {
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_')
}
Expand Down
6 changes: 3 additions & 3 deletions test/moment/min_max.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("min max");
module('min max');

test('min', function (assert) {
var now = moment(),
Expand Down
6 changes: 3 additions & 3 deletions test/moment/mutable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from "../qunit";
import moment from "../../moment";
import { module, test } from '../qunit';
import moment from '../../moment';

module("mutable");
module('mutable');

test('manipulation methods', function (assert) {
var m = moment();
Expand Down
Loading

0 comments on commit 9494aaf

Please sign in to comment.