Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended configuration not working with enums #26

Closed
maxcnunes opened this issue Jan 6, 2022 · 7 comments · Fixed by #27
Closed

Recommended configuration not working with enums #26

maxcnunes opened this issue Jan 6, 2022 · 7 comments · Fixed by #27

Comments

@maxcnunes
Copy link

I couldn't figure it out yet, but once I add extends: ['plugin:ft-flow/recommended'] the linter crashes for enum types:

yarn run v1.22.17
$ ./node_modules/.bin/eslint ./app.js

app.js
  22:7  error  Parsing error: Unexpected token, expected "{" (22:7)

✖ 1 problem (1 error, 0 warnings)

Without ft-flow/recommended it works though.

@maxcnunes maxcnunes changed the title Recommended not working with enums Recommended configuration not working with enums Jan 6, 2022
@maxcnunes
Copy link
Author

maxcnunes commented Jan 6, 2022

This setting from the recommended configuration that was causing the issue for me:

"babelOptions": {
      "parserOpts": {
        "plugins": [
          "flow",
          "jsx"
        ]
      }
    }

Actually, it is only the "flow" plugin that causes the problem.

I got it solved by setting an empty babelOptions:{} on my eslint configuration while I don't figure out why that setting isn't working for me.

Thanks for the plugin btw 🙇

@Brianzchen
Copy link
Member

I'll be honest I've never used flow enums yet, I'll give it a go today and see what could fix it

@maxcnunes
Copy link
Author

@Brianzchen It seems this should be configuration instead, I couldn't find a flow plugin for babel at least:

  "parserOptions": {
    "babelOptions": {
      "parserOpts": {
        "presets": ["@babel/preset-flow"],
        "plugins": ["jsx", "babel-plugin-transform-flow-enums"]
      }
    }
  }

@Brianzchen
Copy link
Member

Ok I just tested this and this is what I've realised, babelOptions is basically an overwrite to babel.config.js or .babelrc.js specified in your root project, when you don't have parserOptions defined it will just read your babel config instead which should always work, you basically NEED to have that configured otherwise your code doesn't actually run so we're just doubling up code to match eslint with any other babel parsing.

My suggestion here is that we just remove this property completely from the recommended setting, whatever you have defined in your babel config to traverse your code for runtime, testing and now eslint will all be the same. This project won't need to maintain all sorts of settings for different use cases.

Also note that this property was originally added before @babel/eslint-parser was a thing but now pulling from babel configs is the standard.

Is that ok with you @maxcnunes? I can make this change quickly and then ship a patch immediately after

@Brianzchen Brianzchen reopened this Jan 6, 2022
@maxcnunes
Copy link
Author

Yeah, makes sense to me, thanks.

@Brianzchen
Copy link
Member

Give v2.0.1 a go

@maxcnunes
Copy link
Author

That worked, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants