gulp-jshintチェックコード



Gulp Jshint Check Code



jshintとgulp-jshintをインストールします

gulp-jshintはjshintに依存することに注意してください

npm install jshint gulp-jshint -D

次に、gulpfile.jsで変更します



gulp.task('jshint', function () { gulp.src('app/src/js/*.js') .pipe(jshint()) .pipe(jshint.reporter('default')) // The output result can be used in conjunction with other plug-ins, which can display error messages more beautifully (such as color, etc.) })

次に、gulp jshintコマンドを実行します
あなたは結果を見ることができます

PS C:wamp64wwwgulpbabel> gulp jshint [11:56:42] Using gulpfile C:wamp64wwwgulpbabelgulpfile.js [11:56:42] Starting 'jshint'... [11:56:42] Finished 'jshint' after 8.86 ms appsrcjs1.js: line 1, col 1, 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). appsrcjs1.js: line 2, col 18, Missing semicolon. 2 errors appsrcjs2.js: line 1, col 18, Missing semicolon. 1 error appsrcjs3.js: line 1, col 18, Missing semicolon. 1 error appsrcjsgreet.js: line 4, col 31, Missing semicolon. appsrcjsgreet.js: line 6, col 2, Missing semicolon. 2 errors appsrcjsindex.js: line 1, col 1, 'import' is only available in ES6 (use 'esversion: 6'). appsrcjsindex.js: line 1, col 29, Missing semicolon. appsrcjsindex.js: line 2, col 1, 'import' is only available in ES6 (use 'esversion: 6'). appsrcjsindex.js: line 2, col 24, Missing semicolon. appsrcjsindex.js: line 3, col 1, 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). appsrcjsindex.js: line 3, col 28, Missing semicolon. appsrcjsindex.js: line 4, col 13, 'template literal syntax' is only available in ES6 (use 'esversion: 6'). appsrcjsindex.js: line 4, col 30, Missing semicolon. appsrcjsindex.js: line 5, col 18, Missing semicolon. appsrcjsindex.js: line 6, col 37, Missing semicolon. 10 errors PS C:wamp64wwwgulpbabel>

letがes6の構文に属し、セミコロンがないというエラーが表示されます。この問題は解決されていません。 .jshintrcファイルを構成するか、package.jsonファイルに追加して、esのバージョンが6であることを示すことができます。これにより、es6の問題を解決できます。



{ 'jshintConfig' : { 'esversion': 6 } }

またはnew.jshintrc

{ 'esversion': 6, //Can have es6 syntax 'undef': true, // Must be defined before use 'unused': true, // Defined must be used 'devel': true, // can useconsole, alert not configured astrueYesconsoleUndefined 'globals': { // Configure global variables, use directly without error 'module': true //Not configuredmodulefortrueWhen module.exports = {} TimesmoduleUndefined } }

jshintはコードのみを検出し、ロジックは検出しません
特定のパラメータリファレンス http://jshint.com/docs/options/