From 553548046f44149508131ba4e2a9a8f889260311 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Tue, 17 Nov 2015 23:14:49 -0600 Subject: [PATCH] Add linting for tests --- .eslintrc | 16 +++++++++++++--- package.json | 2 ++ tasks/gulp-eslint.js | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index a3bc6debda..82c291e8ce 100644 --- a/.eslintrc +++ b/.eslintrc @@ -81,6 +81,9 @@ "block-spacing": [2, "always"], "key-spacing": [2, {"beforeColon": false, "afterColon": true}], "max-nested-callbacks": [2, 3], + "mocha/no-exclusive-tests": 2, + "mocha/no-global-tests": 2, + "mocha/handle-done-callback": 2, "new-cap": 2, "new-parens": 2, "newline-after-var": 2, @@ -110,10 +113,17 @@ }, "env": { "es6": true, + "mocha": true, "node": true }, - ecmaFeatures : { - modules: true + ecmaFeatures : { + modules: true }, - "extends": "eslint:recommended" + "extends": "eslint:recommended", + "globals": { + "expect": true + }, + "plugins": [ + "mocha" + ] } diff --git a/package.json b/package.json index dc78f2970c..5c0048a131 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,8 @@ "coveralls": "^2.11.2", "csv": "~0.3.6", "deep-diff": "~0.1.4", + "eslint": "^1.9.0", + "eslint-plugin-mocha": "^1.1.0", "event-stream": "^3.2.2", "expect.js": "~0.2.0", "istanbul": "^0.3.14", diff --git a/tasks/gulp-eslint.js b/tasks/gulp-eslint.js index 42462ce75d..f67e0a47c1 100644 --- a/tasks/gulp-eslint.js +++ b/tasks/gulp-eslint.js @@ -34,4 +34,21 @@ gulp.task('lint:common', () => { .pipe(eslint.failAfterError()); }); +gulp.task('lint:tests', () => { + return gulp + .src([ + './test/**/*.js', + // @TODO remove these negations as the test files are cleaned up. + '!./test/api-legacy/**/*', + '!./test/common/**/*', + '!./test/content/**/*', + '!./test/e2e/**/*', + '!./test/server_side/**/*', + '!./test/spec/**/*', + ]) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + gulp.task('lint', ['lint:server', 'lint:common']);