-
Notifications
You must be signed in to change notification settings - Fork 226
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
eslint warn floating promises #5495
Conversation
a9d195a
to
05c1089
Compare
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.
Great stuff! Thanks for shepherding this through.
Sorry I haven't had time to look at this yet. I'd like to review before this lands. |
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.
Running yarn lint
locally took 33 minutes and failed with an OOM in the solo
package.
Let's find a way to reduce the impact of this change.
Recording numbers from out chat: (in packages/zoe)
👍 e1625fe makes it opt in with an |
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.
Thanks for making this optional. One change request for the env check.
Should we also add a new script to the root package.json
that runs lint:packages
with the AGORICSDK_ESLINT_ENABLE_TYPE_RULES="true"
and NODE_OPTIONS="--max-old-space-size=8192"
set (which apparently is needed on my machine, not just in CI). We can bike-shed the name, something like lint:with-types
?
.eslintrc.cjs
Outdated
@@ -1,18 +1,23 @@ | |||
/* eslint-env node */ | |||
const process = require('process'); | |||
const lintTypes = !!process.env.AGORICSDK_ESLINT_ENABLE_TYPE_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.
I'd prefer an explicit test for === '1' || === 'true'
as the above would be truthy with AGORICSDK_ESLINT_ENABLE_TYPE_RULES = '0'
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 hear you would prefer that and you put a block on merge because of it. Imo "I'd prefer" is not a reason to block a change.
I could add an explicit test but I don't think it's worth it given how this will be used. It's reasonable for an env flag to be based on presence. Knowing the people who are going to use this flag, I don't expect anyone will try AGORICSDK_ESLINT_ENABLE_TYPE_RULES=0
.
I'm not claiming it won't be better if it did handle that, just that it's not worth the added code or time to write it or blocking a PR.
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 would prefer to use the presence of $CI
to determine the linting mode. Totally easy to set: CI=t yarn lint
.
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.
wfm. I considered CI but felt aversion because I wanted people to run it locally too, but pros:
- it is a much more conventional flag
- it often means "do more, slower stuff"
- makes obvious when using it that it's the same settings as run in CI
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.
CI
is really a conflation. I'm not really a fan of implicit behavior changes based on environment sniffing. As @turadg mentions, there is value in being able to explicitly run this test locally.
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 think this, combined with your other comment, is the best argument for a long-named environment variable (but please, AGORIC_
prefix rather than SMASHINGTHE_FIRST_TWO_WORDS_TOGETHER
), plus a script that runs with the appropriate NODE_OPTIONS and enabling environment variable.
Then CI can use that script directly as well. No need to put it in package.json
, I think, unless it's something like lint-slowly
:)
All the If this were production code the standards would be higher but it's just a little option for stronger linting. I expect our linting to get refactored more soon so don't want to create more commands that have to keep working as expected. This env var has the air of something that could go away. |
e1625fe
to
5b21587
Compare
Right, I forgot about that.
No I don't. Me 3 days ago learned that I also need to set I suppose I would have less qualms if somehow the |
5b21587
to
20b8839
Compare
20b8839
to
5b847c5
Compare
closes: #5407
Description
Enable no-floating-promises. This defers solving all the floating promises by using
warn
level instead oferror
. Eventually we'll want toerror
but I propose we get there incrementally, distributed among teams.This rule from @typescript-eslint is the first we've enabled to require type information (by setting
parserOptions.project
) . That increases the time cost of linting. Measured withtime yarn lerna run --no-bail lint:eslint
on my machine:In CI the lint job went from 5 min before to 21 min after. To prevent developers having to wait longer for PRs to complete, this splits the lint job into two
lint-primary
andlint-rest
.The comments in that job config note that performance could be greatly improved if the linter were able to reuse type information across projects. Alternately we could unify the packages into one TypeScript project.
I also tried cutting the lint job time by shortening the setup step, replacing
restore-node
withsetup-node
and yarn install from cache. This cut 5min setup time down to 2min. (Saving 6min compute over the two jobs.) But it failed because there are build artifacts the linting depends on, such as:import/no-unresolved
fails when@agoric/ui-components
isn't builtSecurity Considerations
--
Documentation Considerations
Notify developers that they'll begin seeing new warnings and that the Github PR annotations may show many more in the code review web UI.
Testing Considerations
Verified that lint jobs are not the slowest zebra: iIn last run lint-primary (10m) and lint-rest (12m) were both less than test-cosmic-swingset (13m) and test-swingset3 (13min).