Skip to content
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

Not using message argument from Shiny.addCustomMessageHandler #500

Open
TymekDev opened this issue Oct 9, 2023 · 0 comments
Open

Not using message argument from Shiny.addCustomMessageHandler #500

TymekDev opened this issue Oct 9, 2023 · 0 comments
Labels
status: triage Awaiting review and labeling by a core developer

Comments

@TymekDev
Copy link
Contributor

TymekDev commented Oct 9, 2023

Steps to reproduce

  1. Create custom message handler:
Shiny.addCustomMessageHandler('asdf', (message) => {
  console.log('Hello world!');
});
  1. Run rhino::lint_js()

Bug description

lint_js returns no-unused-vars lint error.

To make it go away I have to either:

  1. disable linter for the line with // eslint-disable-line no-unused-vars, or
  2. artificially use handler's argument, because Shiny.addCustomMessageHandler('asdf', () => {}) results in "handler must be a function that takes one argument."

Expected behavior

I would expect handlers without used arguments to be supported.

Rhino diagnostics

Darwin 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:52 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8103
R version 4.3.1 (2023-06-16)
rhino: 1.3.0
node: v20.6.1

Comments

A possible solution would be configuring the no-unused-vars rule in .eslintrc.json template.

   "rules": {
     "import/prefer-default-export": "off",
     "no-alert": "off",
-    "no-console": "off"
+    "no-console": "off",
+    "no-unused-vars": ["error", {"argsIgnorePattern": "^_$"}]
   },

This would make _ a special variable that can be used to denote an unused argument, like so:

Shiny.addCustomMessageHandler('asdf', (_) => {
  console.log('Hello world!');
});
@TymekDev TymekDev added the status: triage Awaiting review and labeling by a core developer label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage Awaiting review and labeling by a core developer
Projects
None yet
Development

No branches or pull requests

1 participant