-
Notifications
You must be signed in to change notification settings - Fork 62
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
Cleanup: add no-unused-vars and imports eslint rules and fix the codebase #790
base: master
Are you sure you want to change the base?
Cleanup: add no-unused-vars and imports eslint rules and fix the codebase #790
Conversation
@@ -385,6 +385,8 @@ export class Stream<H extends HandlerTypes = {}> extends EventEmitter<Union<Hand | |||
return false; | |||
} | |||
|
|||
// TODO: fix inheritance - _isFirst is used in Stream implementation so can't be removed here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like its not an issue of inheritance, more like an issue of linter. Would that work if you replaced _isFirst
with _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can _
but then the next person landing on this code will ask himself why there is an unused variable, will likely remove it, and broke again the inheritance. So we should keep the comment to explain why there is an unused variable here until we fix the inheritance, a.k.a we don't add unused variable because parents might use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with most of this changes, but I don't think that function signatures should be changed. I suggest to try to find an options for linter to disable such behavior.
Its ok to strip unused variables like this:
const fn = () => {
const thisIsUnused = 'random string';
return 42;
}
but its not ok to strip function arguments because by this changes you have risks even to break an API (case of messageBuilder
args)
@@ -152,7 +151,7 @@ export class Router extends EventEmitter<Handlers> { | |||
this._transaction.push(RouteAction.dropSearchParams()); | |||
} | |||
|
|||
public commit(_commitOpts?: CommitOptions): this { | |||
public commit(): this { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much advantages on such changes. Feels like there should be a separate rule (or options for existing rules) which could change this point: its wrong to remove unused function args because obviously they can be a part of function signatures.
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 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. |
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 fixedChanges
unused-imports
which is better than the default rules.eslintrc.js
with["error", { "ignoreRestSiblings": true }]
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.