Skip to content

Conversation

@dynst
Copy link
Contributor

@dynst dynst commented Jul 24, 2025

As highlighted in the version 6 announcement, there's always been a separate config with more powerful type-aware lints like no-floating-promises.

https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/

Also enable import/recommended since apparently import/typescript isn't a superset of it.

@dynst dynst force-pushed the eslint-recommended branch 3 times, most recently from 803a1a0 to 69a6d69 Compare July 24, 2025 17:16
dynst added 5 commits July 24, 2025 18:02
from the 'import/recommended' configuration. not included
in the 'import/typescript' config.
not everything is in import/typescript.
it's very difficult to disable TS plugins in the overrides, so
omit them from the root and enable them in overrides instead.
As highlighted in the v6 release notes.
these can be re enabled one at a time later.
@dynst dynst force-pushed the eslint-recommended branch from 5230978 to eaa43ef Compare July 24, 2025 18:03
@dynst
Copy link
Contributor Author

dynst commented Jul 24, 2025

There are a bunch of places where there's code like this

setInterval(async () => {
availableTokens = await faucet.availableTokens();
console.info("Available tokens:", availableTokens);
}, 60_000);

Which violates https://typescript-eslint.io/rules/no-misused-promises#checksvoidreturn since the async function returns a Promise that a function like setInterval or setTimeout is never going to await on or handle in any way. But I disabled the lint for now.

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

.eslintrc.js Outdated
"@typescript-eslint/prefer-readonly": "off",
"import/no-unresolved": "off",
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }],
"@typescript-eslint/consistent-type-exports": "error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made them all "warn" for better IDE highlighting (which stoped working at some point). The lint CI then rejects all warnings anyways.

Suggested change
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-exports": "warn",

files: "**/*.spec.ts",
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/require-await": "off",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about ignoring them in-place? How many of those do we have?

Copy link
Contributor Author

@dynst dynst Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For unit tests, there's a lot of boilerplate, and part of the boilerplate is passing async () => ... to the test framework, and it honestly seems very harmless to keep all that boilerplate the same even for tests that don't have an await call in them?

Outside of unit tests... yeah, there's a lot there too. A lot of asynchronous APIs. 15 warnings, but there will be more if you merge #1722

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sounds good. Yeah no problem having a relaxed linter for test code.

The CI script runs with --max-warnings 0 regardless.
@dynst dynst force-pushed the eslint-recommended branch from 831ba54 to fcd6c2c Compare July 29, 2025 17:30
@dynst
Copy link
Contributor Author

dynst commented Jul 29, 2025

It looks like there's another base-to-string here:

: component.toString();

But I can't figure out why CI is passing but eslint finds this locally.

 226:9  error  'component' will use Object's default stringification format ('[object Object]') when stringified  @typescript-eslint/no-base-to-string

@dynst
Copy link
Contributor Author

dynst commented Jul 29, 2025

https://typescript-eslint.io/rules/no-unnecessary-type-assertion/

packages/amino/src/secp256k1hdwallet.ts
   98:12  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
  178:14  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
  237:55  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts
  63:32  error  This assertion is unnecessary since the receiver accepts the original type of the expression  @typescript-eslint/no-unnecessary-type-assertion
packages/proto-signing/src/directsecp256k1hdwallet.ts
  105:12  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
  177:14  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
  235:55  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
packages/stargate/src/modules/gov/aminomessages.ts
  208:44  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
packages/stargate/src/stargateclient.spec.ts
  102:32  error  This assertion is unnecessary since the receiver accepts the original type of the expression  @typescript-eslint/no-unnecessary-type-assertion

But if you actually run eslint --fix for this lint, it breaks the build:

[@cosmjs/amino]: src/secp256k1hdwallet.ts:98:16 - error TS2339: Property 'type' does not exist on type 'object'.
[@cosmjs/amino]: 
[@cosmjs/amino]: 98   switch (root.type) {
[@cosmjs/amino]:                   ~~~~
[@cosmjs/amino]: 
[@cosmjs/amino]: src/secp256k1hdwallet.ts:178:18 - error TS2339: Property 'type' does not exist on type 'object'.
[@cosmjs/amino]: 
[@cosmjs/amino]: 178     switch (root.type) {
[@cosmjs/amino]:                      ~~~~
[@cosmjs/amino]: 
[@cosmjs/amino]: src/secp256k1hdwallet.ts:237:59 - error TS2339: Property 'kdf' does not exist on type 'object'.
[@cosmjs/amino]: 
[@cosmjs/amino]: 237     const encryptionKey = await executeKdf(password, root.kdf);
[@cosmjs/amino]:                                                               ~~~

Maybe this will be fixed when updating to version 8.0 of the plugin (which supports TypeScript 5.8.3).

=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.8.3

Please only submit bug reports when using the officially supported version.

=============

@dynst dynst force-pushed the eslint-recommended branch from 8a4dbee to b46fd0a Compare July 29, 2025 18:24
@webmaster128
Copy link
Member

: component.toString();

Here component is of type Slip10RawIndex which extends Uint32. So Uint32.toString is used at runtime. Maybe tooling does not get that?

@dynst
Copy link
Contributor Author

dynst commented Jul 29, 2025

Probably a local problem I have and that's why it passes on CI!

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay nice. Is this ready to merge?

@dynst
Copy link
Contributor Author

dynst commented Jul 29, 2025

Yep!

@webmaster128 webmaster128 merged commit 59e70f6 into cosmos:main Jul 29, 2025
13 checks passed
This was referenced Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants