Issue
Below is my code:
interface DeleteRecipeFunctionContext {
handleRecipeDelete: (id: string | number) => void;
}
const RecipeContext = createContext<DeleteRecipeFunctionContext>({
handleRecipeDelete: (id) => null, // eslint-disable-line no-unused-vars
});
createContext requires me to pass in a default function, so I am passing in a (id)=>null as a dummy placeholder before I pass in the actual function. I receive the warning from @typescript-eslint stating:
'id' is defined but never used @typescript-eslint/no-unused-vars
Writing // eslint-disable-warning/no-unused-vars does not disable the warning, but eslint-disable-warning does. How should I turn off this warning without turning off all warnings? On the other hand, is my approach of using createContext correct (to enter a dummy function)?
Solution
To selectively disable a warning generated by a plugin rule, use the syntax
// eslint-disable-line <plugin>/<rule>
in your case:
handleRecipeDelete: (id) => null, // eslint-disable-line @typescript-eslint/no-unused-vars
I do not know if your approach to creating a context is correct, that is something that you will need to test in your application.
Answered By - GOTO 0
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.