- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.5k
Description
Hi!
I noticed that the prefer-inline option for import/no-duplicates actively forbids using that option with Flow:
eslint-plugin-import/src/rules/no-duplicates.js
Lines 119 to 123 in 766af5f
| const preferInline = context.options[0] && context.options[0]['prefer-inline']; | |
| // a user might set prefer-inline but not have a supporting TypeScript version. Flow does not support inline types so this should fail in that case as well. | |
| if (preferInline && (!typescriptPkg || !semver.satisfies(typescriptPkg.version, '>= 4.5'))) { | |
| throw new Error('Your version of TypeScript does not support inline type imports.'); | |
| } | 
However, Flow does support inline types (See this Try flow online REPL):
import React, { type Element } from 'react';
function Example(): Element<'div'> {
  return <div>Hello</div>;
}So we don't need this:
import React from 'react';
import type { Element } from 'react';
function Example(): Element<'div'> {
  return <div>Hello</div>;
}This is even implemented as explicitly allowed in another rule, import/consinstent-type-specifier-style: https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md
I spotted this when upgrading from eslint-plugin-import v2.26.0 to v2.27.5 that this old code that works and didn't show lint errors:
import type { Localizable } from 'common/types/locale';
import { localize, localizable } from 'common/types/locale';
import type { FormattedMoney } from 'common/types/money';
import { money, formatMoney, type Money } from 'common/types/money';Now should be written like this instead:
import type { Localizable } from 'common/types/locale';
import { localize, localizable } from 'common/types/locale';
import {
  money,
  formatMoney,
  type Money,
  type FormattedMoney
} from 'common/types/money';Notice how the imports from common/types/localeremained the same while the imports from common/types/money showed errors.
5:37 warning '/path/to/common/types/money.js' imported multiple times import/no-duplicates 6:48 warning '/path/to/common/types/money.js' imported multiple times import/no-duplicates
Expected outcome
I'd expect this to work with Flow:
'import/no-duplicates': ['warn', { 'prefer-inline': true }]Actual outcome
Error:
Your version of TypeScript does not support inline type imports. Occurred while linting /path/to/inquiry/utils/priceRangeToText.js:3