-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add "no-implicit-coercion" #15
Conversation
Fine with me. I won‘t fight over this one. :)
Kind regards,
Tim
Co-Founder Transloadit
@tim_kos
… Am 22.04.2022 um 15:02 schrieb Julian Gruber ***@***.***>:
https://eslint.org/docs/rules/no-implicit-coercion
I find this rule useful as it prevents shorthand syntax that can be either difficult to read or understand.
To me it's always better to write
new Date().getTime()
instead of
+new Date()
or
String(foo)
instead of
`${foo}`
There are more characters on screen yes, but the intend is clearer and reading the code requires less understanding of JavaScript internals.
I know that @kvz and @tim-kos like using these syntax tricks a lot, so I don't expect this to go very easy.
You can view, comment on, or merge this pull request online at:
#15
Commit Summary
51ea8c8 Enable "no-implicit-coercion"
dac55af Disallow template shorthand string conversion
4523f22 Move to its own section
File Changes (1 file)
M index.js (7)
Patch Links:
https://github.com/transloadit/eslint-config-transloadit/pull/15.patch
https://github.com/transloadit/eslint-config-transloadit/pull/15.diff
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
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 usually use !!val
, but I can live with having to write Boolean()
. I think some of these shorthands are very cryptic so it makes sense to not allow 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.
Probably not one I would have proposed myself no, but also not one I am religious about to keep out of our standard, so I am fine personally with merging this.
I do think the Uppy team should weigh in first tho. And also I think this will add yet another thousand warnings to our big repos. At one point we should make a push to also fix a few of those. Maybe a few heavy hitters can be addressed with jscodemods?
I'm assuming we can take care of 99% of cases using string search/replace, or even |
FWIW, it's always better (performance-wise, and imho in general) to write |
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.
Same as Kev. More consistency in the code we write and review is ultimately a good thing imo
I agree about performance, but not maintainability. When you're not in a hot code path then a |
Don't have a strong opinion on this. But we already have 2000+ warnings in the Uppy repo and ideally we get it down rather than up, because we are just getting too used to seeing warnings. |
FWIW the goal is to get as close as 0 warnings when doing the ESM transition, and then change ESLint settings from warning to error on all rules. |
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.
@kvz consider my peace held 😇
@@ -135,5 +135,12 @@ module.exports = { | |||
'react/jsx-one-expression-per-line': ['off'], // <-- This one is a bit annoying | |||
'no-await-in-loop': ['off'], // <-- Let's disable it and see if it bites us | |||
'no-underscore-dangle': ['off'], // We use _ in almost all repos. See discussion here: https://github.com/transloadit/botty/pull/41#discussion_r738022104 | |||
|
|||
'no-implicit-coercion': [ | |||
'error', |
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'll need to trial this as a warning to give projects the chance to upgrade, and once there are no more warnings, then we promote to error.
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.
sgtm
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.
Counter proposal: I think we should keep it as an error, projects should override that rule to be a warning instead until they've fixed all the occurrences. (please no more warnings 🥺)
I am all for readability, |
Thank you everyone for your input! @kvz what are the next steps? |
|
To me the smaller the change the better, as it will be easier to upgrade. Upgrading dependencies sounds great 👍 |
https://eslint.org/docs/rules/no-implicit-coercion
I find this rule useful as it prevents shorthand syntax that can be either difficult to read or understand.
To me it's always better to write
instead of
or
instead of
`${foo}`
There are more characters on screen yes, but the intend is clearer and reading the code requires less understanding of JavaScript internals.
I know that @kvz and @tim-kos like using these syntax tricks a lot, so I don't expect this to go very easy.