2016-03-28 3 views
11

Ich benutze ESLint in einem Projekt und möchte auch Facebook-Flow verwenden, aber ich bekomme Warnungen von ESLint auf Flow-Typ-Annotationen.ESLint mit Arbnb config und Facebook zusammen fließen

Ich habe .flowconfig und .eslintrc im Projektstamm.

.eslintrc:

// When you write javascript you should follow these soft rules and best practices 
// https://github.com/airbnb/javascript 

// This is a link to best practices and enforcer settings for eslint 
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb 

// Use this file as a starting point for your project's .eslintrc. 
{ 
    "extends": "airbnb", 

    "plugins": [ 
    "flow-vars" 
    ], 
    "rules": { 
    "flow-vars/define-flow-type": 1, 
    "flow-vars/use-flow-type": 1 
    } 
} 

Was soll ich tun, es funktioniert? Gibt es eine Möglichkeit, den Watch-Task zusammen mit dem Webpack auszuführen?

Antwort

11

flow-vars ist veraltet!

Dies ist der aktuelle richtige Weg, um Fluss mit Airbnb läuft (mit eslint-plugin-flowtype):

Dies vorausgesetzt, dass Sie bereits flow installiert haben.

npm install --save-dev eslint babel-eslint eslint-plugin-flowtype 

.eslintrc

{ 
    "extends": [ 
    "airbnb", 
    "plugin:flowtype/recommended" 
    ], 
    "parser": "babel-eslint", 
    "plugins": [ 
    "flowtype" 
    ] 
} 

Wollen custom configuration statt?

7

Für mich wurde das Problem gelöst, indem "parser": "babel-eslint" zu meinem .eslintrc hinzugefügt wurde.

(Ich musste zuerst npm install babel-eslint --save-dev ausführen).

{ 
    "extends": "airbnb", 
    "parser": "babel-eslint", // <-- 
    "plugins": [ 
    "flow-vars" 
    ], 
    "rules": { 
    "flow-vars/define-flow-type": 1, 
    "flow-vars/use-flow-type": 1 
    } 
}