저는 JSHint를 초보자로 삼아 자바 스크립트의 유효성을 검사하려고합니다. node.js가 설치되어 있고 JSHint를 실행하려고하면 아래 오류가 발생합니다. 나는 오류가 발생하는 이유HTML로 JSHint를 실행하고 오류가 발생했습니다.
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"es3": false,
"forin": true,
"freeze": true,
"immed": true,
"indent": 4,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": false,
"strict": false,
"maxparams": 10,
"maxdepth": 5,
"maxstatements": 40,
"maxcomplexity": 8,
"maxlen": 120,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": false,
"laxcomma": false,
"loopfunc": true,
"maxerr": false,
"moz": false,
"multistr": false,
"notypeof": false,
"proto": false,
"scripturl": false,
"shadow": false,
"sub": true,
"supernew": false,
"validthis": false,
"noyield": false,
"browser": true,
"node": true,
"globals": {
"angular": false,
"$": false
}
}
누군가가 알려 주시기 바랍니다 수 :
C:\Users\574839\Desktop\testscr.js:1
(function (exports, require, module, __filename, __dirname) { <!DOCTYPE html>
^
SyntaxError: Unexpected token <
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:456:3
나는 다음과 같은 옵션이있는 .jshintrc 파일이?
내 JS 코드는 다음과 같습니다.
<!DOCTYPE html>
<html>
<body>
<h1>What Can JavaScript Do?</h1>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick="document.getElementById('demo').innerHTML='Hello JavaScript!'">Click Me!</button>
</body>
</html>
JSHint에 JS에서 HTML을 추출하고 JS 만 테스트 할 수있는 방법이 있습니까? – InfiniteLoop
감사합니다. 마지막 질문 하나. 콘솔에 오류/경고를 표시하는 것 외에 로그 파일처럼 생성됩니까? 테스트 결과를 어디서 찾을 지 모르겠습니다. – InfiniteLoop
내가 말한 것을 긁어 내고 대답을 다시 보아라. 나는 그것을 새롭게했다. 출력을 파일에 넣고 싶다면'jshint --extract = always testscr.js> output.txt' –