-
Notifications
You must be signed in to change notification settings - Fork 221
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
Upgrade to ESLint v9 #10846
Upgrade to ESLint v9 #10846
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
ac1e669
to
615e12d
Compare
7775513
to
3d589b1
Compare
eslint.config.mjs
Outdated
"packages/cosmic-proto/node_modules/", | ||
"packages/cosmic-proto/coverage/", | ||
"packages/cosmic-proto/dist/", |
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.
are these not implied by the simpler globs? we want to ignore these no matter where they are:
coverage
dist
node_modules
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.
These were migrated from all our our current eslintignore
files. I do think it makes sense to have these ignored gobally though
eslint.config.mjs
Outdated
|
||
export default [{ | ||
ignores: [ | ||
"coverage/**/*", |
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.
does .eslintignore
no longer work?
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.
Yeah it's deprecated
eslint.config.mjs
Outdated
|
||
"ava/no-skip-test": "off", | ||
"ava/use-test": "off", | ||
"@jessie.js/safe-await-separator": "off", // Temporarily disabled due to ESLint 9.x compatibility issue |
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.
can be re-enabled?
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 catching this
@@ -1,9 +1,12 @@ | |||
// This file can contain .js-specific Typescript compiler config. | |||
{ | |||
"extends": "../../tsconfig.json", | |||
"compilerOptions": {}, |
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.
what does this do?
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.
Not needed. I was testing something out and forget to remove this
packages/cosmic-swingset/types.d.ts
Outdated
import { SpawnSyncReturns as NodeSpawnSyncReturns } from 'child_process'; | ||
|
||
declare module 'child_process' { | ||
export interface SpawnSyncReturns<T> extends NodeSpawnSyncReturns<T> { |
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.
why was this necessary?
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 were previously ignoring packages/cosmic-swingset/check-validator.cjs
when using our old config. Given that it had check-jessie
, so I assume it was meant to be linted. When trying to lint, I got this error:
check-validator.cjs:25:9 - error TS2339: Property 'code' does not exist on type 'SpawnSyncReturns<Buffer<ArrayBufferLike>>'.
25 if (ret.code) {
~~~~
check-validator.cjs:26:20 - error TS2339: Property 'code' does not exist on type 'SpawnSyncReturns<Buffer<ArrayBufferLike>>'.
26 process.exit(ret.code);
I added this to get the linting working. I'm open to alternatives
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'm pretty sure it's a bug. Node docs for spawnSync and the TS defs show a status: number
property which I think is what this meant to use.
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.
Nice catch!
eslint.config.mjs
Outdated
const allDeprecated = [...deprecatedForLoanContract, ['loan', 'debt']]; | ||
|
||
const deprecatedTerminology = Object.fromEntries( | ||
Object.entries({ |
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.
This isn't formatted correctly. Please make sure this file is included in the format
and lint:format
selections
eslint.config.mjs
Outdated
|
||
"ava/no-skip-test": "off", | ||
"ava/use-test": "off", | ||
"@jessie.js/safe-await-separator": "error", // Temporarily disabled due to ESLint 9.x compatibility issue |
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.
comment no longer applicable
eslint.config.mjs
Outdated
// Include both .js and .ts files for cache package | ||
files: ["packages/cache/**/*.{js,ts,mjs,cjs}"], |
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.
shouldn't this be the glob for all packages?
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 think we were previously including *.ts
files.
casting
and cache
both explicilty ran eslint --ext .js,.ts .
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.
almost there.
before I forget to say: before merging the commits will need cleaning up. there aren't any actual fix
commits here for the changelog. Just one that updates ESlint and another that fixes the .code
bug
eslint.config.mjs
Outdated
'packages/cosmic-proto/src/codegen/', | ||
'packages/cosmic-proto/scripts/', | ||
// Cosmic-swingset specific ignores | ||
'packages/cosmic-swingset/src/bundles/**/*', |
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.
this should be a global ignore for bundles
at any path
eslint.config.mjs
Outdated
'packages/cosmic-swingset/src/bundles/**/*', | ||
'packages/cosmic-swingset/t[0-9]/**/*', | ||
'packages/cosmic-swingset/t[0-9].*/**/*', | ||
'packages/cosmic-swingset/node_modules/**/*', |
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.
ignored above
eslint.config.mjs
Outdated
'packages/cosmic-swingset/t[0-9]/**/*', | ||
'packages/cosmic-swingset/t[0-9].*/**/*', | ||
'packages/cosmic-swingset/node_modules/**/*', | ||
'packages/cosmic-swingset/build/**/*', |
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.
this should be another global ignore
eslint.config.mjs
Outdated
export default [ | ||
{ | ||
ignores: [ | ||
'**/coverage/**/*', |
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.
all these directory ignores don't need the trailing glob, right?
https://eslint.org/docs/latest/use/configure/ignore#ignoring-directories
866b354
to
8bd868d
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.
🎉
633ca30
to
8f15007
Compare
@@ -205,7 +205,6 @@ const main = async () => { | |||
instancePath: [contractName], | |||
callPipe: [['makeDepositInvitation']], | |||
}, | |||
// @ts-expect-error 'NatAmount' vs 'AnyAmount' |
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.
Why is this eslint change affecting TypeScript?
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.
It may be because of some changes to tsconfig
, but I couldn't figure out how to keep this line without this error:
scripts/fast-usdc-tool.ts:208:7 - error TS2578: Unused '@ts-expect-error' directive.
208 // @ts-expect-error 'NatAmount' vs 'AnyAmount'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3,7 +3,7 @@ | |||
|
|||
import '@endo/init'; | |||
import starshipChainInfo from '../starship-chain-info.js'; | |||
import { makeAssetInfo } from '../tools/asset-info.ts'; |
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.
This is a code change, not just lint change. I suspect it will break this test. I've added "force:integration" to check
eslint.config.mjs
Outdated
'import/no-extraneous-dependencies': 'off', | ||
}, | ||
}, | ||
// Separate config for multichain-testing that doesn't inherit root 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.
It's a separate Yarn project so I think we'd be better off giving it a desperate flag confit.
Ie leave its dependencies and source alone. If the eslint config for the root project is affecting multichain-testing, fix only that. (Eg by putting a config file in there so it will get that one instead)
Regardless we need an issue to come and make this other yarn project in the repo lint correctly. Something like #10238
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.
They don't have a supported way of doing this. I did some digging and they have an experimental approach to this. We can leverage this as long as we understand it's not a fully released feature yet
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.
That link says the default is to start search from the CWD. Why wouldn't an eslintconfig within multichain-testing
already resolve before the one in agoric-sdk
?
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.
Just tested and this does indeed work without the flag
eslint.config.mjs
Outdated
}, | ||
], | ||
// Disable all other rules | ||
'@typescript-eslint/no-floating-promises': 'off', |
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 want to see these suppressions omitted but if we do end up keeping them please use "warn" instead of disabling them completely. They should still give notice to developers even if they don't fail CI.
9b673b2
to
675172a
Compare
@@ -91,29 +91,5 @@ | |||
"@agoric/zoe": "portal:../packages/zoe", | |||
"@agoric/zone": "portal:../packages/zone" | |||
}, | |||
"eslintConfig": { |
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.
please separate multichain-testing
changes to another PR. It's complicating this migration of agoric-sdk root project. Let's get that landed.
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.
Without these changes, linting will fail for multichain-testing as it'll pick up the root config and try to use that
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.
Hmm, I just tried it and it seemed to work.
cd multichain-testing
git checkout master .
yarn install
yarn lint
Do you get a different result?
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.
btw, assuming we can punt updating multichain-testing
, this PR should no longer be marked as closing 10642
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.
This does work locally. I'll remove the changes and observe CI. It was picking up the new config in CI, but maybe I just observed the wrong thing and chased the wrong path
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.
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.
Going back to this comment, when you ran git checkout master .
, I don't think it removed the eslint.config.mjs
file that was newly added as part of this change, so when you ran yarn lint
, it was still using that file
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.
Very confusing when CI has a different result for yarn lint
than the local checkout does. I tried diagnosing why the linked job failed but I couldn't determine what state of this branch it was using and what changes it had to multichain-testing.
So I made a new branch, https://github.com/Agoric/agoric-sdk/tree/ta/eslint-v9, which has the steps I pasted above. It's passing in https://github.com/Agoric/agoric-sdk/actions/runs/12898290669/job/35965066953
Maybe the failing job did not have the master state of multichain-testing
?
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.
Even when you reverted the change in the eslint-v9
branch, the new eslint.config.mjs
file is still present in the latest version of the branch
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.
Ah. My branch doesn't actually match what I was asking for. And upon closer inspection it looks like it's green because in master the linter is broken in this dir.
So thanks for fixing it!
8d2bdd3
to
2fa6631
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.
One small change to make. Before merge please rebase locally to fix the "fixup! fixup!" which automerge won't know how to handle.
multichain-testing/package.json
Outdated
@@ -5,7 +5,7 @@ | |||
"scripts": { | |||
"build": "exit 0", | |||
"lint": "yarn tsc && yarn eslint .", | |||
"lint-fix": "yarn lint:eslint --fix", | |||
"lint-fix": "yarn lint --fix", |
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.
yarn lint
just happens to end in eslint. Since we don't have lint:
scripts in this package.json this one should call that directly.
"lint-fix": "yarn lint --fix", | |
"lint-fix": "yarn eslint . --fix", |
@@ -91,29 +91,5 @@ | |||
"@agoric/zoe": "portal:../packages/zoe", | |||
"@agoric/zone": "portal:../packages/zone" | |||
}, | |||
"eslintConfig": { |
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.
Ah. My branch doesn't actually match what I was asking for. And upon closer inspection it looks like it's green because in master the linter is broken in this dir.
So thanks for fixing it!
8d2bdd3
to
6593986
Compare
6593986
to
6bd3574
Compare
This pull request has been removed from the queue for the following reason: The merge conditions cannot be satisfied due to failing checks: You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
closes: #10642
Description
Updates ESLint to v9. Doing so deprecates the use of
.eslintrc
andeslintignore
and moves all these configuration options into a flat config file,eslint.config.mjs
. As part of this change, we also needed to update the github eslint plugin as well as thejessie.js
eslint plugin. Most of the rules were migrated successfully, but I had to modify a few rules since ESLint v9 comes with a few default behavior changes.Security Considerations
N/A
Scaling Considerations
N/A
Documentation Considerations
Here's a breakdown of the breaking changes that come with ESLint v9. https://eslint.org/docs/latest/use/migrate-to-9.0.0#-varsignorepattern-option-of-no-unused-vars-no-longer-applies-to-catch-arguments.
Testing Considerations
I modified our
yarn lint
command so I could individually run and view the error of each package. Doing so allowed me to debug every single error that occured after the ugprade and make changes to restore expected behavior.Upgrade Considerations
N/A