jsx-eslint/eslint-plugin-react

no-unused-prop-types does not work if TypeScript interface is defined in another file

Aperta

#3209 aperta il 17 feb 2022

 (5 commenti) (1 reazione) (0 assegnatari)JavaScript (2731 fork)batch import
help wantedtypescript

Metriche repository

Star
 (9293 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

in types.ts:

export interface SharedProps {
    className?: string;
}

In component.tsx:

import { SharedProps } from './types';

export interface TestComponentProps extends SharedProps {
  name: string;
  count: number;
}

export function TestComponent(props: TestComponentProps) {
  return (
    <div>Hello, {props.name}! {props.count}</div>
  )
}

no-unused-prop-types doesn't catch that className is unused in TestComponent.

Tested using most recent version of everything (eslint-plugin-react, etc)

Guida contributor