From fd3ed7a0ac66e52c91a6aadfc287a311a4ed3552 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 6 Jun 2016 09:25:10 +0300 Subject: [PATCH] Lint tweaks. --- Gruntfile.js | 14 +++++++------- test/tasks/events_test.js | 2 +- test/tasks/fail_test.js | 2 +- test/tasks/helper.js | 12 +++++++++--- test/tasks/livereload_test.js | 6 +++--- test/tasks/nospawn_test.js | 6 +++--- test/tasks/patterns_test.js | 2 +- test/tasks/reloadgruntfile_test.js | 6 +++--- test/tasks/watch_test.js | 2 +- 9 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 56523e8..4e7a15f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,11 +14,11 @@ module.exports = function(grunt) { all: [ 'Gruntfile.js', 'tasks/**/*.js', - '<%= nodeunit.tests %>', + '<%= nodeunit.tests %>' ], options: { - jshintrc: '.jshintrc', - }, + jshintrc: '.jshintrc' + } }, jscs: { src: ['tasks/**/*.js', 'test/tasks/**/*.js'], @@ -29,12 +29,12 @@ module.exports = function(grunt) { watch: { all: { files: ['<%= jshint.all %>'], - tasks: ['jshint', 'nodeunit'], - }, + tasks: ['jshint', 'nodeunit'] + } }, nodeunit: { - tests: ['test/tasks/*_test.js'], - }, + tests: ['test/tasks/*_test.js'] + } }); // Dynamic alias task to nodeunit. Run individual tests with: grunt test:events diff --git a/test/tasks/events_test.js b/test/tasks/events_test.js index 1040710..7304262 100644 --- a/test/tasks/events_test.js +++ b/test/tasks/events_test.js @@ -161,5 +161,5 @@ exports.events = { test.ok(result.indexOf('Ive changed') !== -1, 'should run task set in event listener'); test.done(); }); - }, + } }; diff --git a/test/tasks/fail_test.js b/test/tasks/fail_test.js index ec8473a..ba9bec9 100644 --- a/test/tasks/fail_test.js +++ b/test/tasks/fail_test.js @@ -51,5 +51,5 @@ exports.fail = { test.ok(result.match(/This task should be fatal/g).length === 2, 'grunt.fatal should not stop the watch task.'); test.done(); }); - }, + } }; diff --git a/test/tasks/helper.js b/test/tasks/helper.js index 6bdc634..7ee9a23 100644 --- a/test/tasks/helper.js +++ b/test/tasks/helper.js @@ -10,7 +10,9 @@ helper.fixtures = path.join(__dirname, '..', 'fixtures'); // If verbose flag set, display output helper.verboseLog = function() {}; if (_.indexOf(process.argv, '-v') !== -1) { - helper.verboseLog = function() { console.log.apply(null, arguments); }; + helper.verboseLog = function() { + console.log.apply(null, arguments); + }; } // helper for creating assertTasks for testing tasks in child processes @@ -73,7 +75,9 @@ helper.assertTask = function assertTask(task, options) { if (shouldRun) { setTimeout(function() { var run = runs.shift(); - if (typeof run === 'function') { run(); } + if (typeof run === 'function') { + run(); + } }, 500); } }); @@ -94,7 +98,9 @@ helper.assertTask = function assertTask(task, options) { // clean up files within fixtures helper.cleanUp = function cleanUp(files) { - if (typeof files === 'string') { files = [files]; } + if (typeof files === 'string') { + files = [files]; + } files.forEach(function(filepath) { filepath = path.join(helper.fixtures, filepath); if (grunt.file.exists(filepath)) { diff --git a/test/tasks/livereload_test.js b/test/tasks/livereload_test.js index 5ab7523..b065456 100644 --- a/test/tasks/livereload_test.js +++ b/test/tasks/livereload_test.js @@ -10,7 +10,7 @@ var fixtures = helper.fixtures; function cleanUp() { helper.cleanUp([ - 'livereload/node_modules', + 'livereload/node_modules' ]); } @@ -19,7 +19,7 @@ function request(port, done) { var data = ''; var req = http.request({ hostname: 'localhost', - port: port, + port: port }, function(res) { res.setEncoding('utf8'); res.on('data', function(chunk) { @@ -235,5 +235,5 @@ exports.livereload = { 'Should not livereload when a task errors with flag and spawn=false'); test.done(); }); - }, + } }; diff --git a/test/tasks/nospawn_test.js b/test/tasks/nospawn_test.js index c76324d..12c7deb 100644 --- a/test/tasks/nospawn_test.js +++ b/test/tasks/nospawn_test.js @@ -35,7 +35,7 @@ exports.nospawn = { grunt.file.write(path.join(cwd, 'lib', 'nospawn.js'), write); }, function(result) { helper.verboseLog(result); - var count = result.match((new RegExp('Running "watch" task', 'g'))).length; + var count = result.match(new RegExp('Running "watch" task', 'g')).length; test.equal(count, 2, 'Watch should have fired twice.'); test.ok(result.indexOf('Server is listening...') !== -1, 'server should have been started.'); test.ok(result.indexOf('Server is talking!') !== -1, 'server should have responded.'); @@ -56,10 +56,10 @@ exports.nospawn = { // Two functions needed to run two rounds of watching }], function(result) { helper.verboseLog(result); - var count = result.match((new RegExp('Running "long" task', 'g'))).length; + var count = result.match(new RegExp('Running "long" task', 'g')).length; test.equal(count, 4, 'long task should have been ran only 4 times.'); test.ok(result.indexOf('have been interrupted') !== -1, 'tasks should have been interrupted.'); test.done(); }); - }, + } }; diff --git a/test/tasks/patterns_test.js b/test/tasks/patterns_test.js index df12884..38bd445 100644 --- a/test/tasks/patterns_test.js +++ b/test/tasks/patterns_test.js @@ -40,5 +40,5 @@ exports.patterns = { 'Watch should NOT have been triggered when dontedit.js was edited.'); test.done(); }); - }, + } }; diff --git a/test/tasks/reloadgruntfile_test.js b/test/tasks/reloadgruntfile_test.js index 1d0c00c..6b207eb 100644 --- a/test/tasks/reloadgruntfile_test.js +++ b/test/tasks/reloadgruntfile_test.js @@ -10,7 +10,7 @@ var fixtures = helper.fixtures; function cleanUp() { helper.cleanUp([ 'multiTargets/node_modules', - 'multiTargets/Gruntfile.js.bak', + 'multiTargets/Gruntfile.js.bak' ]); } @@ -45,11 +45,11 @@ exports.reloadgruntfile = { grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var one = true;'); }], function(result) { helper.verboseLog(result); - var count = result.match((new RegExp('Running "watch" task', 'g'))).length; + var count = result.match(new RegExp('Running "watch" task', 'g')).length; test.equal(count, 2, 'Watch should have fired twice.'); test.ok(result.indexOf('one has changed') !== -1, 'task one should have been triggered.'); test.ok(result.indexOf('two has changed') !== -1, 'task two should have been triggered.'); test.done(); }); - }, + } }; diff --git a/test/tasks/watch_test.js b/test/tasks/watch_test.js index 1371911..6e608f1 100644 --- a/test/tasks/watch_test.js +++ b/test/tasks/watch_test.js @@ -33,7 +33,7 @@ exports.watch = { var cwd = path.resolve(fixtures, 'atBegin'); var assertWatch = helper.assertTask(['watch', '--debug'], {cwd: cwd}); assertWatch(function() { - // noop. Does not modify any watched files. + // noop. Does not modify any watched files. }, function(result) { helper.verboseLog(result); var firstIndex = result.indexOf('one has changed');