Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upeslint: forbid boolean function arguments #4674
Open
Comments
|
Is Though it's still a good rule to enable nonetheless. |
|
@achrinza |
Hmm, that's a good question. Now that I am re-reading the documentation for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Function arguments of type
booleanare considered as a bad practice because they make the code difficult to read and reason about.Consider the following code:
What does the
trueflag mean? There is no way to tell when reading the code using the function, we have to look up the API definition and/or implementation to understand.Compare with the current implementation which is following the best practices:
Now it's more clear that we want to treat the binding as optional and don't trigger an error when it's not found.
Let's improve our eslint configuration to automatically detect and reject boolean arguments. Eslint rule to use: no-inferrable-types
Further reading:
Acceptance criteria
Breaking changes must be committed in such way that they don't trigger semver-major release of packages that are not affected.