Eslint-plugin-import: import/named doesn't detect Flow Opaque types in flow comments

Created on 24 Aug 2017  路  5Comments  路  Source: benmosher/eslint-plugin-import

Hi all!

When using flow opaque types (new in https://github.com/facebook/flow/releases/tag/v0.51.0) via flow comments The import/named rule doesn't detect the exported types.

Ex:

Foo.js

// @flow

/*::
export opaque type Foo = string;
*/

export const makeFoo = (): Foo => 'new foo';

UseFoo.js

// @flow

import { type Foo } from './Foo'; // Foo not found in './Foo' (import/named)

A weird workaround is to remove makeFoo from Foo.js and that will fix the linter rule. Don't know why that is. It's also not a good workaround since that makes the opaque type useless.

flow help wanted

Most helpful comment

Nope, I'm able to take off the flow comments and this error is still triggering a false-positive.

All 5 comments

Is this an issue only with flow comments?

Possibly related to https://github.com/gajus/eslint-plugin-flowtype/issues/260 ?

Nope, I'm able to take off the flow comments and this error is still triggering a false-positive.

@johnhaley81 I should notice that eslint couldn't track the flow stubs generated by flow-typed

I have run locally the following test on current master (in the valid rules):

    test({
      code: 'import type { MyOpaqueType } from "./flowtypes"',
      parser: 'babel-eslint',
    }),

It is passing. Can we have a release?

Closed by #1057, in that case.

Was this page helpful?
0 / 5 - 0 ratings