2017-03-03 3 views
4

나는 다음과 같은 eslint 오류가 발생합니다 :는 반작용 기본 앱 ES 린트에서 글로벌로 웹 소켓을 정의

42:21 error 'WebSocket' is not defined no-undef 

당신은 그것을 글로벌 때문에 react-native에서 웹 소켓을 가져올 수는 없지만 나는에 전역으로 웹 소켓을 추가 할 때 내

globals: 
    WebSocket: true 

가 어떻게이 반작용 기본 앱 ES 린트의 세계로 웹 소켓을 정의합니까 : .eslintrc.yml이 오류의 결과를 변경하지 않는 이유는 무엇입니까?

이 문제를 해결할 수 있습니까?

env: 
    browser: false 
    es6: true 
    commonjs: true 
    node: true 
extends: 'airbnb' 
parser: babel-eslint 
globals: 
    WebSocket: true 
parserOptions: 
    ecmaFeatures: 
    experimentalObjectRestSpread: true 
    jsx: true 
    sourceType: module 
plugins: 
    - react 
    - react-native 
rules: 
    indent: 
    - error 
    - tab 
    - {"SwitchCase": 1} 
    linebreak-style: 
    - error 
    - unix 
    quotes: 
    - error 
    - double 
    semi: 
    - error 
    - never 
    no-tabs: off 
    max-len: off 
    no-console: off 
    no-plusplus: off 
    global-require: off 
    import/no-unresolved: off 
    import/extensions: off 
    class-methods-use-this: off 
    react/jsx-no-bind: off 
    react/forbid-prop-types: off 
    react/prefer-stateless-function: off 
    react/jsx-indent: [2, 'tab'] 
    react/jsx-indent-props: [2, 'tab'] 
    react/jsx-filename-extension: [1, { extensions: ['.js', '.jsx'] }] 
    react/jsx-uses-react: error 
    react/jsx-uses-vars: error 
    react-native/no-unused-styles: 2 
    react-native/split-platform-components: 2 
    react-native/no-inline-styles: off 
    react-native/no-color-literals: off 

나는 내가 에어 비앤비 eslint에서 상속하지 않는 경우

/* globals WebSocket:true */ 

또한 인라인 주석을 사용하여 제거 할 수 있지만, 그럴 수 없어 그림 : 현재 내 .eslintrc은 다음과 같습니다 Airbnb에서 어떤 보푸라기 규칙이 이것을 막을 책임이 있습니다.

+0

어떻게 eslint를 실행합니까? 또한'.eslintrc.yml' 파일이 eslint를 실행할 때 사용되는지 확인 하시겠습니까? – Gyandeep

답변

1

제공된 정보에 따르면 설정 파일이 어떤 이유로 든 선택되지 않은 것 같습니다. globals의 구성이 올바르게 보이고 작동해야합니다. 무슨 일이 일어나고 있는지 알아 내기 위해서는 두 가지를해야합니다. 먼저 eslint --print-config path_to_some_js_file을 실행하여 ESLint가 모든 종속성과 계단식을 해결 한 후에 구성이 어떻게 나타나는지 확인할 수 있습니다. 대부분의 경우 config에는 globals이 선언되지 않습니다. 그런 다음 eslint --debug path_to_file을 실행하면 ESLint에서 사용중인 모든 구성 파일을 볼 수 있습니다. 파일이 포함되어 있지 않으면 다른 모든 구성 파일을 확인하고 그 파일에 root: true이 없는지 확인하십시오. 그러면 ESLint가 상위 디렉토리의 구성을 병합하지 않습니다. CLI 플래그에 대한 자세한 내용은 다음을 참조하십시오. ESLint documentation