import-js/eslint-plugin-import

Bad automated fix for `no-duplicates` when using Flow.

Open

#2691 aperta il 23 gen 2023

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)JavaScript (1540 fork)batch import
bugflowhelp wanted

Metriche repository

Star
 (4946 star)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

This could be related to #2475, but I'm not sure. I got this error after upgrading, but not exactly the same one. I'm using Flow too.

I had some code like this:

import {
  withChartViewport,
  type WithChartViewport,
} from 'firefox-profiler/components/shared/chart/Viewport';
...
import type { Viewport } from 'firefox-profiler/components/shared/chart/Viewport';

After the change, the last import type was reported as an error and merged into the first one. This makes some sense, but this was merged incorrectly:

import {
  withChartViewport,
  type WithChartViewport,
  Viewport,
} from 'firefox-profiler/components/shared/chart/Viewport';

Notice that the word type is missing. Without it, Flow is erroring. I could add it manually, the eslint wouldn't error then.

I simply have the rule configured like this:

    'import/no-duplicates': 'error',

So in short, in this case I think the error was right but the autofix wasn't.

Could be related to #2686 but I'm not sure because the error seems different.

Guida contributor