GithubHelp home page GithubHelp logo

Comments (7)

sebmck avatar sebmck commented on August 11, 2024

There's only so much that can be done. Arrow functions that have expression bodies need to be transformed to have a body or else #20 happens.

from babel-eslint.

nzakas avatar nzakas commented on August 11, 2024

Can you try with the default ESLint parser to see if you get the same issues?

from babel-eslint.

keithamus avatar keithamus commented on August 11, 2024

ESLint parser does not have the same issue with func-names; espree parses Arrow functions as type: "ArrowFunctionExpression"[1], [2] which is ignored by the func-names rule[3]

Interestingly, the Mozilla Parser API indicates that it should be neither "FunctionExpression" nor "ArrowFunctionExpression" - but actually "ArrowExpression"[4].

Esprima also parses arrows as "ArrowFunctionExpression"[5]

from babel-eslint.

keithamus avatar keithamus commented on August 11, 2024

As for space-before-blocks. Esprima counts the inline arrow function as an expression, e.g. () => x*x; is a BinaryExpression, but does count it as a block when presented with curlies, (e.g. () => { return x*x; }).

This behaviour seems like the correct way. Espree also follows this same pattern (I cannot link as it does not have an online repl, but I did verify this).

from babel-eslint.

sebmck avatar sebmck commented on August 11, 2024

@keithamus Yes, this is because babel-eslint was designed for eslint 0.15.x before it had ES6 support so it had to convert nodes that ESLint didn't understand to ones that it did. I'm currently tied up in work on the Babel core but I'm more than welcome to a pull request to update all the nodes to 0.16.x.

from babel-eslint.

keithamus avatar keithamus commented on August 11, 2024

Totally fine 😄 I just thought I'd add my findings, I doubt I'll be able to find the time to fix this.

Right now I'm using eslint 0.16 with the ES6 features turned on, which seems to be more reliable than babel-eslint.

from babel-eslint.

sebmck avatar sebmck commented on August 11, 2024

Should be fixed if you upgrade babel-eslint to 2.0.0 and eslint to 0.16.x, thanks!

from babel-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.