question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected block statement surrounding arrow body arrow-body-style

See original GitHub issue

What version of ESLint are you using? 2.3.0

What configuration and parser (Espree, Babel-ESLint, etc.) are you using? Babel-Eslint version babel/babel-eslint#d2f90c7239e152b8994f250c69c83604cde93292 (from 07 march 2016, need this commit for fix ‘estraverse-fb’)

What did you do? Please include the actual source code causing the issue.

this.post('/post', () => {
        return {
            post: {
                foo: 1,
                bar: 2,
            },
        };
    });

Error: 1:28 error Unexpected block statement surrounding arrow body arrow-body-style

I cant remove the { } after removing the ‘return’ because I want to response a object: { }

What did you expect to happen?

No error message with the default setting ‘as-needed’

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

277reactions
platinumazurecommented, Mar 7, 2016

If you wrap the object in parentheses, it will parse correctly and the rule won’t error:

this.post('/post', () => ({
        post: {
            foo: 1,
            bar: 2,
        },
    });
61reactions
mysticateacommented, Jun 17, 2016
const reactComponents = this.props.articles.map((article, i) =>
    <Item
      article={article.data}
      key={i}
      onChange={this.props.onChange}
    />
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected block statement surrounding arrow body
This said, if arrow-body-style option is set to true, OP is correct. An other example would be something like this : return this.state.greetings.map( ......
Read more >
arrow-body-style - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Unexpected block statement surrounding arrow body [Solved ...
Hi,. I have a question around good syntax. I am picking up React and functional programming in general, and am pretty new to...
Read more >
React App Unexpected block statement surrounding arrow body
Coding example for the question React App Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.
Read more >
eslint/eslint - Gitter
Hey everyone, the following mocha test snippet is failing on arrow-body-style ("Unexpected block statement surrounding arrow body.") it('should do a thing', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found