2014-10-11 5 views
2

I 파일에서 다음 개체를 remover.js 있습니다JSHint 불평 객체가 정의되지

'use strict'; 

(function(remover, $, undefined) { 
    // ... 
    // Object's definition 
    // ... 
}(window.remover = window.remover || {}, jQuery)); 

이 외부 파일에 사용되는 main.js :

'use strict'; 

remover.doSomething(); 

코드가 작동되지만 JSHint 다음과 같은 문제가 발생합니다 :

Running "jshint:all" (jshint) task 

app/scripts/stuff/main.js 
    line 3 col 1 'remover' is not defined. 

✖ 1 problem 

이 경고를 제거하는 방법?

답변

7

당신은 두 가지 옵션이 있습니다, 하나는 모든 디버깅 나쁜이며, 다른 하나는 특히 글로벌 기관과 문제를 해결하는 정의되지 않은 경고를 타고을 받고있다.

  1. 안 var에 정의되지 않은 경고 (나쁜!)

    그냥 파일 undef 옵션과 함께 main.js에 경고를 비활성화

    'use strict'; 
    /*jshint undef:false */ 
    
  2. JSHint에게 어느입니다 외부 라이브러리 (좋은!)

    지금 실행 글로벌

    'use strict'; 
    /*global remover */ 
    

으로 모든 변수를 언급 grunt jshint해야 출력 자세한 내용은 JSHint Documentation의 섹션 지침에 있습니다

Running "jshint:all" (jshint) task 

✔ No problems 

.

관련 문제