rhino
rhino copied to clipboard
Not using message argument from Shiny.addCustomMessageHandler
Steps to reproduce
- Create custom message handler:
Shiny.addCustomMessageHandler('asdf', (message) => {
console.log('Hello world!');
});
- Run
rhino::lint_js()
Bug description
lint_js returns no-unused-vars lint error.
To make it go away I have to either:
- disable linter for the line with
// eslint-disable-line no-unused-vars, or - 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!');
});