import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

Typings in new index.d.ts incompatible with ESLint types #3080

Closed danielrentz closed 1 month ago

danielrentz commented 1 month ago
src/eslint/env/react.ts:63:13 - error TS2322: Type '{ "react/hook-use-state": "error"; "react/iframe-missing-sandbox": "error"; "react/jsx-boolean-value": "error"; "react/jsx-no-script-url": "error"; "react/jsx-no-useless-fragment": "error"; ... 27 more ...; 'react/require-render-return': number; }' is not assignable to type 'Partial<RulesRecord>'.
  Property ''react/react-in-jsx-scope'' is incompatible with index signature.
    Type 'number' is not assignable to type 'RuleEntry<any[]> | undefined'.

63             rules: {
               ~~~~~

  ../../node_modules/eslint/lib/types/index.d.ts:1304:9
    1304         rules?: Partial<Rules>;
                 ~~~~~
    The expected type comes from property 'rules' which is declared here on type 'Config<RulesRecord>'

Root cause: All rules (e.g. line 221 and following in index.d.ts) are declared to have number value type which is incompatible to ESLint's expected RuleEntry type which resolves as

   RuleEntry
=> RuleSeverity | RuleSeverityAndOptions<any[]>
=> Severity | StringSeverity | [RuleSeverity, ...Partial<any[]>]
=> 0 | 1 | 2 | "off" | "warn" | "error" | [RuleSeverity, ...Partial<any[]>]

I think best would be to use RuleSeverity there. Or the actual values used in the preset configuration. (?)

michaelfaith commented 1 month ago

According to your error message, that's not even this plugin. Looks like eslint-plugin-react not eslint-plugin-import.

danielrentz commented 1 month ago

@michaelfaith Right, I was in the wrong browser tab :D