hubble-ui
hubble-ui copied to clipboard
Cleanup: add no-unused-vars and imports eslint rules and fix the codebase
No issue.
Description
This PR adds the no-unused-vars and imports eslint rules. Then, I ran eslint --fix
and finally fixed the remaining issue that couldn't be automatically fixed
Changes
- Added a new npm package
unused-imports
which is better than the default rules - Enabled the rules in
.eslintrc.js
with["error", { "ignoreRestSiblings": true }]
- Ran eslint --fix
- Fixed the remaining issues
Screenshots
n/a
Unit tests
They should still all pass
Functional tests
It's probably worth testing quickly the entire app, to see that nothing have been broken.
but I don't think that function signatures should be changed.
Why not? I really don't see a case where an unused parameter of function could be useful. Maybe you can provide an example?
The problem with removing this lint rule is that it's really common for developers to add parameters when they start a new function and not using some of them at the end, after a few massage, while not noticing they're left unused. Think of, for example, a forEach
loop: you would think first you'll need the index and ends up without using it. As the code base grows, this will clutter the code, making harder to read it, and therefore, harder to spot bugs.
I suggest that if we find a clear case of a needed unused parameter, we then add a lint exception comment WITH a clear comment to explain why this parameter is absolutely needed, so that no other developer will remove in the future after you.