style(v2): reduce number of ESLint warnings #4993
Conversation
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
|
|
Lighthouse ran on https://deploy-preview-4993--docusaurus-2.netlify.app/ |
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
|
thanks, not agreeing with everything but overwall happy to reduce eslint warnings I personally like TS function return type inference but it seems to be a best practice to type return types explicitly so why not |
| @@ -127,7 +127,10 @@ function assertIsCategory( | |||
| ); | |||
| } | |||
| // "collapsed" is an optional property | |||
| if (item.hasOwnProperty('collapsed') && typeof item.collapsed !== 'boolean') { | |||
| if ( | |||
| Object.prototype.hasOwnProperty.call(item, 'collapsed') && | |||
slorber
Jun 18, 2021
Collaborator
too much ceremony, I'd just replace by typeof item.collapsed !== "undefined" ?
Josh-Cena
Jun 18, 2021
•
Author
Contributor
There is actually a consideration about collapsed existing on the prototype chain of item. Is it safe to assume here that typeof item.collapsed !== "undefined" works the same?
slorber
Jun 24, 2021
Collaborator
can you replace with typeof item.collapsed !== "undefined" ? it has not been done here
packages/docusaurus-theme-bootstrap/src/theme/ThemedImage/index.tsx
Outdated
Show resolved
Hide resolved
packages/docusaurus-theme-classic/src/theme/ThemedImage/index.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
…x.tsx Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
|
@slorber If I'm delving into typing (the |
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
smaller PRs are always easier to review/merge, so splitting the work is not a bad idea. |
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
|
@slorber I think I'm mostly done—reduced warning count by >50. The rest of them (33) contain:
Need some help here... Airbnb is complaining about await docs.reduce(
(p, doc) => p.then(() => handleDocItem(doc)),
Promise.resolve(),
);
I see that we are planning to add hotkey binding maps. This warning will remind us of this feature :P
|
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Honestly don't like Airbnb preset, it's way too opinionated with weird rules, but it's the current docu preset so let's just disable what is annoying. This rule can also be disabled, it's not really applicable for NodeJS code IMHO. I'll merge this PR as is, any further improvements are welcome |
|
finally, asking for a few changes |
| // eslint-disable-next-line no-await-in-loop | ||
| await handleDocItem(doc); | ||
| } | ||
| await docs.reduce( |
Josh-Cena
Jun 24, 2021
Author
Contributor
Although I reverted this, I'm pretty confident that the new code works correctly
| @@ -127,7 +127,10 @@ function assertIsCategory( | |||
| ); | |||
| } | |||
| // "collapsed" is an optional property | |||
| if (item.hasOwnProperty('collapsed') && typeof item.collapsed !== 'boolean') { | |||
| if ( | |||
| Object.prototype.hasOwnProperty.call(item, 'collapsed') && | |||
slorber
Jun 24, 2021
Collaborator
can you replace with typeof item.collapsed !== "undefined" ? it has not been done here
|
Okay cool. Lemme address those... |
This reverts commit c7525d4.
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
|
thanks |
Motivation
When I'm working on the project I was constantly overwhelmed (exaggeration here; there aren't so many) by ESLint warnings. Although they aren't serious issues, I decide it's better that we address these issues, since this is what we have the linter for.
There are some warnings that I probably need help with, especially regarding
anytypes. (I realize how intractable typing objects can become.) I don't want to easily resort toeslint-disablecomments.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
These are mostly style changes that don't really impact functionality to any degree.