From a1ae6f7c41a2989a8c8a9d413c4b201f86758fae Mon Sep 17 00:00:00 2001 From: BitDen Date: Tue, 14 Nov 2017 08:22:46 +0800 Subject: [PATCH] Jshint for prod and dev build --- src/{.jshintrc => .jshintrc.json} | 0 webpack/config.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) rename src/{.jshintrc => .jshintrc.json} (100%) diff --git a/src/.jshintrc b/src/.jshintrc.json similarity index 100% rename from src/.jshintrc rename to src/.jshintrc.json diff --git a/webpack/config.js b/webpack/config.js index 8d5285e7..7da7aa40 100644 --- a/webpack/config.js +++ b/webpack/config.js @@ -18,6 +18,13 @@ _loaders = [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015' +}, { + // './src/*.js', './src/modules/*.js' + test: /\.\.\/src\/[a-z]*\.js/, + exclude: /node_modules/, + enforce: 'pre', + loader: 'jshint-loader', + options: Object.assign({}, require('../.jshintrc.json'), require('../src/.jshintrc.json')) }]; let configEnv = {}; @@ -32,11 +39,30 @@ if (ENV === 'development') { module: { loaders: [..._loaders, { - test: /\.js$/, + // './test/*Spec.js' + test: /\.[/]test[/][a-z*]\.js/, exclude: /node_modules/, enforce: 'pre', loader: 'jshint-loader', - options: require('../.jshintrc.json') + options: Object.assign({}, require('../.jshintrc.json'), { + node: true, + globals: { + angular: false, + inject: false, + jQuery: false, + jasmine: false, + afterEach: false, + beforeEach: false, + ddescribe: false, + describe: false, + expect: false, + iit: false, + it: false, + spyOn: false, + xdescribe: false, + xit: false + } + }) } ]},