사전 준비
현재 puf-core 및 puf-builder에서 jsint.sh 파일로 배치파일이 작성되어 있음.
Required) Node.js가 설치되어 있어야합니다.
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs (Nodejs가 필요)
JsHint를 설치(http://jshint.com/install/)
npm install -g jshint
분석할 최상위 폴더에 아래 예제 처럼 2가지 파일을 생성합니다.
.jshintignore : 생략할 파일 및 폴더 목록
.jshintrc : 체크할 rule(http://jshint.com/docs/options/)
분석할 폴더에서 아래 명령을 실행하면 하위 폴더 포함한 모든 파일(생략할 파일제외)을 분석해줍니다.
jshint *
jshint * --checkstyle-reporter > test.xml (test 파일에 checkstyle로 저장된다)
룰 파일 추가 옵션
jshint * --config 룰 파일 경로
jshint ignore 파일 예시
.jshintignore meteor/ public/ tests/ run.sh /.txt packages/test-platform/package.js packages/test-auth/package.js .jshintignore
jshintrc 예시
.jshintrc { // JSHint Meteor Configuration File // Match the Meteor Style Guide //
// By @raix with contributions from @aldeed and @awatson1978
// Source https://github.com/raix/Meteor-jshintrc //
// See http://jshint.com/docs/ for more details
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details "maxerr" : 50, // {int} Maximum error before stopping
"-W100" : true, "-W004" : true, // jshint is already defined.
"-W009" : true, // The array literal notation [] is preferable.
"-W002" : true, // Value of 'e' may be overwritten in IE 8 and earlier.
"-W061" : true, // eval can be harmful.
"-W030" : true, // Expected an assignment or function call and instead saw an expression.
"-W041" : true, // Use '===' to compare with
"-W058" : true, // Missing '()' invoking a constructor.
"-W032" : true, // Unnecessary semicolon.
"-W018" : true, // Confusing use of '!'.
"-W084" : true, // Expected a conditional expression and instead saw an assignment.
"-W051" : true, // Variables should not be deleted. "-W025" : true, // Missing name in function declaration. // Enforcing "bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
"eqeqeq" : false, // true: Require triple equals (===) for comparison
"forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : false, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. (function () { } ());
"indent" : 4, // {int} Number of spaces to use for indentation
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. new F()
"noarg" : false, // true: Prohibit use of arguments.caller and arguments.callee
"noempty" : false, // true: Prohibit use of empty blocks
"nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of ++ & --
"quotmark" : false, // Quotation mark consistency: // false : do nothing (default) // true : ensure whatever is used is consistent //
"single" : require single quotes //
"double" : require double quotes
"undef" : false, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : false, // Unused variables: // true : all variables, last function parameter //
"vars" : all variables only // "strict" : all variables, all function parameters
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : 20, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
"varstmt" : false, // true: Disallow any var statements. Only let and const are allowed. // Relaxing "asi" : true, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of == null
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: const)
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) // (ex: for each, multiple try/catch, function expression??
"evil" : false, // true: Tolerate use of eval and new Function()
"expr" : false, // true: Tolerate ExpressionStatement as Programs
"funcscope" : true, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the __iterator__ property
"lastsemic" : true, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : true, // true: Tolerate possibly unsafe line breakings
"laxcomma" : true, // true: Tolerate comma-first style coding
"loopfunc" : true, // true: Tolerate functions being defined in loops
"multistr" : true, // true: Tolerate multi-line strings // Bad escaping of EOL. Use option multistr if needed.
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the __proto__ property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : true, // true: Allows re-define variables later in code e.g. var x=1; x=2;
"sub" : true, // true: Tolerate using [] notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate new function () { ... }; and new Object;
"validthis" : false, // true: Tolerate using this in a non-constructor function // Environments
"browser" : true, // Web Browser (window, document, etc)
"browserify" : false, // Browserify (node.js code in the browser)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : false, // jQuery "mocha" : false, // Mocha
"mootools" : false, // MooTools
"node" : false, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"phantom" : false, // PhantomJS
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : false, // Rhino
"shelljs" : false, // ShellJS
"typed" : false, // Globals for typed array constructions
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface "globals" : { } }