2014-12-09 6 views
0

난 그냥 내가 만드는거야 자바 스크립트 코드는 적어도 몇 가지 기준을 충족하는지 확인하기 위해 JSLint를 사용하기 시작했는데 나는 혼란스러운 메시지를 가지고 :JSLint 예상치 못한 '그'메시지

JSLint: Unexpected 'that'. 

코드를 진행 막대를 구현하는 솔루션의 일부입니다.이 중 일부는 타이머 및 콜백을 처리하는이 객체이며 다음과 같습니다 (이것은 대용량 파일의 시작 부분에서 추출한 것이므로 필요에 따라 전체 파일을 추가 할 수 있음).

var ProgressHandler = function() { 
    "use strict"; 

    // Build a new object 
    var that = {}; 

    // Add basic properties 
    that.taskid = 0; 
    that.timerid = 0; // Timer ID used to push refreshes 
    that.progressUrl = ""; // URL to invoke to read progress 
    that.interval = 500; // The interval for progress refresh 
    that.taskProgressCallback = null; // The user-defined callback that refreshes the UI 
    that.taskCompletedCallback = null; // The user-defined callback that finalizes the call 

    // Set progress url 
    that.setProgressUrl = function (url) { 
     that.progressUrl = url; 
     return this; 
    } 

    // Set frequency of refresh 
    that.setInterval = function (interval) { 
     that.interval = interval; 
     return this; 
    }; 

that.setInterval으로 시작하는 줄에 메시지가 나타납니다. 그 I의 추가 사용이 있지만 JSLint는 또한이 시점에서 처리가 중지된다고 말합니다. 이 메시지를 검색하려고 시도했지만 여기 또는 jslinterrors.com에 특별히 나와 있지 않습니다.

왜 이런 현상이 나타나고이를 해결하려면 어떻게해야합니까? 아니면 그냥 무시해야합니까?

+0

이 스크립트를 JSLint를 통해 실행하면 'that.setInterval'에 오류가 발생합니다. –

+0

죄송 합니다만, 그 말을해야만합니다. 그것은 that.setInterval 라인입니다. –

답변

3

that.setProgressUrl의 정의 이후에 ;이없는 것으로 보입니다. 변경 대상 :

// Set progress url 
    that.setProgressUrl = function (url) { 
     that.progressUrl = url; 
     return this; 
    }; 

보고 된 문제를 해결합니다. 그런 다음 파일 끝 부분에 닫기 중괄호와 세미 콜론이 누락되어 있다는 점에 문제가 있습니다. 복사 및 붙여 넣기 문제인지는 확실하지 않습니다. 전체 스크립트는 다음과 같습니다 :

var ProgressHandler = function() { 
    "use strict"; 

    // Build a new object 
    var that = {}; 

    // Add basic properties 
    that.taskid = 0; 
    that.timerid = 0; // Timer ID used to push refreshes 
    that.progressUrl = ""; // URL to invoke to read progress 
    that.interval = 500; // The interval for progress refresh 
    that.taskProgressCallback = null; // The user-defined callback that refreshes the UI 
    that.taskCompletedCallback = null; // The user-defined callback that finalizes the call 

    // Set progress url 
    that.setProgressUrl = function (url) { 
     that.progressUrl = url; 
     return this; 
    }; 

    // Set frequency of refresh 
    that.setInterval = function (interval) { 
     that.interval = interval; 
     return this; 
    }; 
}; 
+0

누락 된 항목이있는 이유 중 하나 인 완전한 파일이 아닙니다. –

+1

@ClaraOnager, 의미가 있습니다. 그 대답의 나머지 부분이 당신의 이슈를 해결하길 바랍니다. – detaylor

+0

JSLint 메시지를 해독하는 일반적인 원칙으로, 예기치 않은 '무언가'메시지가 나오면 그 문제로부터 잠재적 인 문제를 찾아보아야합니다. –