Umair Umair - 3 months ago 346
Javascript Question

Unexpected block statement surrounding arrow body ESlint

Why is this piece of code giving me lint warnings? What's the workaround? Any help would be appreciated.

const configureStore = () => {
return createStore(
rootReducer,
middleware
);
};


That's my eslint configuration

{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"react"
],
"rules": {
"comma-dangle": 0,
"object-curly-spacing": 0,
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"arrow-body-style": 1,
"newline-per-chained-call": 1
},
"env": {
"browser": true,
"node": true,
"mocha": true
}
}

Answer

It's a little hard to debug not knowing your particular lint config.

My only guess is that your linter is configured in a way that complains if you use a block on an arrow body which contains only a single expression

Try

const configureStore = () =>
  createStore(rootReducer, middleware);

If that doesn't work, please provide a comment

--

ps, if you paste your exact code in repl.it, there are no lint warnings