amilajack / eslint-plugin-flowtype-errors

Run Flow as an ESLint plugin
MIT License
402 stars 32 forks source link

Error: Cannot resolve name `$Shape` (flowtype-errors/show-errors) #185

Closed MEGApixel23 closed 5 years ago

MEGApixel23 commented 5 years ago

I'm using flow with VueJS and eslint. Looks like the plugin doesn't recognize the built-in flow types, like $Shape.

Here is a code where it fails:

export interface PrincipalDevice extends $Shape<Navigator> {}

and here is my eslint config within package.json

{
"eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/standard"
    ],
    "rules": {
      "flowtype-errors/show-errors": 2
    },
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "globals": {
      "pdfjsLib": true,
      "$": true,
      "RecordRTC_Extension": true,
      "ZiggeoApi": true,
      "expect": true,
      "it": true,
      "describe": true
    },
    "plugins": [
      "html",
      "flowtype-errors"
    ]
  }
}
nwoltman commented 5 years ago

Could you please provide the following:

As a side note, it's not this plugin's responsibility to do things like "recognize the built-in flow types, like $Shape". This plugin just runs Flow and displays Flow errors as ESLint errors.

MEGApixel23 commented 5 years ago

Appreciate your quick response!

  1. "The output you're getting from ESLint"

    error: '$Diff' is not defined (no-undef) at src/interfaces/PrincipalDevice.js:2:42:
    1 | // @flow
    > 2 | export interface PrincipalDevice extends $Diff<Navigator> {}
    |                                          ^
    3 | 
  2. "The output that you get when running Flow directly"

    
    Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/interfaces/PrincipalDevice.js:2:42

Cannot resolve name $Shape.

 1│ // @flow
 2│ export interface PrincipalDevice extends $Shape<Navigator> {}
 3│


3. I expect no errors in the output.
nwoltman commented 5 years ago

How in the world is ESLint saying your code uses $Diff but Flow says it uses $Shape?

MEGApixel23 commented 5 years ago

How in the world is ESLint saying your code uses $Diff but Flow says it uses $Shape?

Sorry about that. I was trying different built-in types and copied the wrong error output. There should be $Shape in both cases. But the same is relevant for any built-in type.

nwoltman commented 5 years ago

In that case, this has nothing to do with this plugin. If Flow is giving you an error, this plugin is just going to output that same error.

This looks like it's a bug in Flow, so you should report it over in the flow repo. They take forever to fix bugs, so in the meantime, you could do this as a workaround:

type NavigatorShape = $Shape<Navigator>;
interface PrincipalDevice extends NavigatorShape {}