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.

eslint --init does not work with @flow

See original GitHub issue

Tell us about your environment macOS Sierra 10.12.1

  • ESLint Version: v3.3.1
  • Node Version: v6.9.1
  • npm Version: v3.10.8 What parser (default, Babel-ESLint, etc.) are you using? babel-eslint Please show your full configuration:
{
  "devDependencies": {
    "babel-cli": "^6.18.0",
    "babel-eslint": "^7.1.0",
    "babel-jest": "^17.0.0",
    "babel-plugin-transform-flow-strip-types": "^6.18.0",
    "babel-preset-es2015": "^6.18.0",
    "eslint": "^3.9.1",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-plugin-flowtype": "^2.25.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^3.0.1",
    "eslint-plugin-react": "^6.6.0",
    "flow-bin": "^0.34.0",
    "jest": "^17.0.0"
  }

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

./node_modules/.bin/eslint --init

What did you expect to happen? I have a project with flow annotations that I wanted to use as a source for my custom .eslintrc file and it breaks.

I guess we have two options:

  1. Either we strip the annotations when it is a flow annotated file and then run eslint --init
  2. Or we support natively from eslint itself flow annotations (maybe taking them from eslint-plugin-flowtype?)

Whatever is chosen I would be happy to help and implement the solution! 😄

What actually happened? Please include the actual, raw output from ESLint.

Determining Config: 0% [------------------------------] 0.0s elapsed, eta 0.0s 

(/Users/flaviocorpa/WebstormProjects/flow-linq/src/List.js:16:11) Parsing error: Unexpected token <
Error: (/Users/flaviocorpa/WebstormProjects/flow-linq/src/List.js:16:11) Parsing error: Unexpected token <
    at getSourceCodeOfFile (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/util/source-code-util.js:39:15)
    at /Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/util/source-code-util.js:95:28
    at Array.forEach (native)
    at getSourceCodeOfFiles (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/util/source-code-util.js:94:15)
    at configureRules (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/config/config-initializer.js:131:23)
    at processAnswers (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/config/config-initializer.js:254:18)
    at .completed (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/eslint/lib/config/config-initializer.js:414:30)
    at PromptUI.onCompletion (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/inquirer/lib/ui/prompt.js:57:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/rx-lite/rx.lite.js:1550:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/Users/flaviocorpa/WebstormProjects/flow-linq/node_modules/rx-lite/rx.lite.js:1489:14)

I had a look at the code and it breaks when reading the first generic:

class List<T> {
          ^^^

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
nzakascommented, Dec 28, 2016

I don’t think we should make a change here. There’s no guarantee that core rules work correctly with Flow, TypeScript, or any other dialect other than plain JS. I’m not sure there’s much value to most users in going through the process if we can’t know whether or not the results will be useful.

1reaction
platinumazurecommented, Nov 12, 2016

I’ve reproduced this, so I’m labeling this as a bug for now.

It might be that other parsers or experimental features are “not supported”, in which case this might turn into an enhancement request. Either way, I think we can improve the experience here.

Thanks for the report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix this error message "Initialization error (Eslint ...
@Rikard's fix works. If you need to do this inside WebStorm, open Preferences, go to Language and Frameworks->Node.js and NPM->Node interpreter.
Read more >
Rules - 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 >
Setting up ESLint in React - Medium
To create one, we can run eslint --init . ... This is because ESLint doesn't know that this is a React app, and...
Read more >
ESLint | WebStorm Documentation - JetBrains
Besides JavaScript and TypeScript, ESLint can be applied to files of ... client not under the server folder, the working directory will be ......
Read more >
How to add a custom ESLint configuration to a Create React ...
The following command will run the linter for the project and report if there are any issues. npm run lint. ESLint erros on...
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