I am trying to configure eslint + babel-eslint + eslint-plugin-react + eslint-plugin-flowtype
I have the following devDependencies
in package.json
:
"babel-eslint": "^7.1.1",
"eslint": "^3.10.2",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-flowtype": "^2.25.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.7.1"
And the following .eslinrc
:
{
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"extends": [
"airbnb",
"plugin:flowtype/recommended"
],
"rules": {
"max-len": [1, 80, 2, {"ignoreComments": true}],
"prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/prefer-stateless-function": [
0,
{
"ignorePureComponents": true
}
],
"no-console": 0
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
}
}
I wrote simple code example in App.js
:
function foo() {
const a: string = 1;
return a;
}
async function bar() {
const b = await foo();
return b;
}
If I launch eslint src/App.js
then eslint
does not show any messages.
If I add "flowtype/require-return-type": 2
into .eslintrc
then eslint
shows:
error Missing return type annotation flowtype/require-return-type
error Missing return type annotation flowtype/require-return-type
✖ 2 problems (2 errors, 0 warnings)
But I don't understand why const a: string = 1;
is valid.
How to enable checking type of const a: string = 1;
?
flowtype + eslint
? I mean is it possible toeslint
will show errors offlowtype
when I runeslint App.js
? – Reticule