This eslint plugin detects properties that are not used in destructuring assignments even though they are defined as types.
When using typescript, it is often the case that there are properties that are no longer used even though they were defined with a type.
For example, when defining types for React Props.
type Props = { name: string;
age: number;
}
export const Component: React.FC<Props> = (
{
name
}
) => {
return (<>{name}</>)
}
npm i -D eslint-plugin-must-use-all-properties
In .eslintrc.js:
"plugins": [
"must-use-all-properties",
],
rules: {"must-use-all-properties/must-use-all-properties": ["error"]}
Put the comment out //must-use-all-properties
before the destructuring assignment where you want to show the error
type Props = { name: string;
age: number;
}
export const Component: React.FC<Props> = (
// must-use-all-properties
{
name
}
) => {
return (<>{name}</>)
}
Welcome
MIT