Skip to content

False positive with no-unused-message-ids when helper function parameter reassignment present #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bmish opened this issue Aug 10, 2022 · 0 comments · Fixed by #290
Closed
Labels

Comments

@bmish
Copy link
Member

bmish commented Aug 10, 2022

In this example, the messageId being reported can come from a function parameter or from parameter reassignment. We should ignore this scenario because we don't know all the possible values the function could be called with.

Example:

checkCall(node, node, 'unsafeCall');

function checkCall(
  reportingNode: TSESTree.Node,
  messageId: MessageIds,
): void {
  if (foo) {
    messageId = 'unsafeCallThis';
  }
  context.report({
    node: reportingNode,
    messageId: messageId,
  });
}

https://github.com/typescript-eslint/typescript-eslint/blob/b6e5413fb12c2b1943a288b514f864c339380388/packages/eslint-plugin/src/rules/no-unsafe-call.ts#L63

This is not specific to TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant