babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)

Home Page:https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing error when use pipeline-operator <fsharp> with none-parenthesized arrow function

gomain opened this issue · comments

The code:

// This fails to parse
const a = b |> x => x.f();

// This is ok
const a = b |> (x => x.f());

The error:

1:18  error  Parsing error: Unexpected token, expected ";"
> 1 |const a = b |> x => x.f()
    |                 ^

The config, in my package.json:

{
  "eslintConfig": {
    "root": true,
    "parser": "babel-eslint"
  },
  "babel": {
    "plugins": [
      [
        "@babel/plugin-proposal-pipeline-operator",
        {
          "proposal": "fsharp"
        }
      ]
    ]
  }
}

I could not reproduce the parsing error on repl, what's the version of @babel/core and babel-eslint?

There is nothing wrong with babel itself. The code transforms correctly with babel-cli. I suspect babel-eslint is not reading the plugin configuration correctly or maybe defaulting to minimal. Only when run eslint this error occurs.

Exact same error when using minimal: repl

Anyhow, using these versions.

├── @babel/cli@7.6.4
├── @babel/core@7.6.4
├── @babel/plugin-proposal-pipeline-operator@7.5.0
├── babel-eslint@10.0.3
├── eslint@5.16.0

babel-eslint did not take the user’s existing Babel configuration into account until v11 (which is still currently in pre-release). Does upgrading solve this issue?

Thank you @kaicataldo,

I understood this was the obvious way to configure babel-eslint. Upgrading to babel-eslint@11.0.0-beta.0 does solve the issue.

Can you please point me to the documents of how to configure babel-eslint@<11 to achieve the same results?

babel-eslint@<11 doesn’t support this kind of configuration, which is partly why the feature was added to v11.