ni / javascript-styleguide

JavaScript and TypeScript Style Guide
MIT License
9 stars 9 forks source link

Configure no-unused-vars to catch more unused function arguments #35

Closed jattasNI closed 3 years ago

jattasNI commented 3 years ago

Justification

Closes #32. We want to catch unused vars even when they are function arguments.

Implementation

In both the JS and TS config change no-unused-vars config to:

I investigated providing a custom error but this rule doesn't support that. The default error is fairly informative: "'bar' is defined but never used. Allowed unused args must match /^_/u no-unused-vars". Furthermore the VSCode autofixer suggestion list includes "Prefix with underscore" so I think the workaround is plenty discoverable.

I also made the comment style more consistent by removing a few **s.

Testing

Locally added unused parameters to both JS and TS test files and verified that they were flagged by the linter unless prefixed with an underscore.