Skip to content

chore(cactus-plugin-satp-hermes): add dead code detection rules to eslint config#4382

Open
bhavyamsharmaa wants to merge 1 commit into
hyperledger-cacti:mainfrom
bhavyamsharmaa:chore/satp-eslint-dead-code-detection
Open

chore(cactus-plugin-satp-hermes): add dead code detection rules to eslint config#4382
bhavyamsharmaa wants to merge 1 commit into
hyperledger-cacti:mainfrom
bhavyamsharmaa:chore/satp-eslint-dead-code-detection

Conversation

@bhavyamsharmaa

Copy link
Copy Markdown

Closes #4374

What changed

Added three rules to packages/cactus-plugin-satp-hermes/eslint.config.mjs:

  • no-unreachable (error) — flags code after return/throw/break that can never run
  • no-unused-private-class-members (warn) — flags private class fields that are never read
  • @typescript-eslint/no-unused-expressions (warn) — flags expressions with no side effects

Why this approach

The issue mentions two paths: migrate to Biome, or improve ESLint. Biome migration was noted to risk linting inconsistency across the 90+ packages in the monorepo. This PR takes the incremental path — adds dead code detection to the existing config without touching any other package or adding new dependencies.

Testing

Config change only. Existing format:eslint script picks up the new rules automatically.

Assisted-by: anthropic:claude-sonnet-4-6

@RafaelAPB

Copy link
Copy Markdown
Contributor

@bhavyamsharmaa thank you for your contribution. Could you indicate what is the output of the linter given the changes? Based on that, what would be the approach to apply changes to the codebase cautiously?

@bhavyamsharmaa

Copy link
Copy Markdown
Author

Hi @RafaelAPB — here's the linter output after the new rules + follow-up fixes:

Before this update: 170 problems (32 errors, 138 warnings)
After this update: 0 errors, 137 warnings

@bhavyamsharmaa bhavyamsharmaa force-pushed the chore/satp-eslint-dead-code-detection branch 2 times, most recently from 60aa1a6 to 9114c68 Compare June 16, 2026 14:54

@RafaelAPB RafaelAPB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bhavyamsharmaa thank you for your contribution. This is very useful and needed.

The new config seems good. Could you please also 1) add a SATP lint stage to the CI that enforces that codebase passes linter , 2) add the linter to the commit hooks (pre push), and 3) resolve warnings?

try {
//todo
return true;
} catch (err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please comment instead of deleting; we will need this code

- Add no-unreachable (error), no-unused-private-class-members (warn),
  and @typescript-eslint/no-unused-expressions (warn) rules to
  eslint.config.mjs for dead code detection
- Add Node.js globals override for *.mjs files
- Add lint:ci npm script for CI linting without auto-fix
- Add SATP lint stage to satp-hermes-build.yaml CI workflow
- Add pre-push git hook that runs the SATP linter
- Restore deleted catch block as commented-out code in
  stage1-client-service.ts (will be uncommented when logic is added)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bhavyamsharmaa bhavyamsharmaa force-pushed the chore/satp-eslint-dead-code-detection branch from 9114c68 to e6b2c4d Compare July 1, 2026 18:52
@bhavyamsharmaa

Copy link
Copy Markdown
Author

Hi @RafaelAPB, addressed all your comments:

Restored the catch block as a comment in stage1-client-service.ts (not deleted) so it's easy to uncomment once the //todo logic is done.
Added SATP lint stage to satp-hermes-build.yaml, runs after build. New lint:ci script — no --fix, --quiet, so it only fails on errors (covers the new no-unreachable: "error" rule).
Added .husky/pre-push hook, runs the SATP linter via lerna before push.
On warnings: the one actual error (no-unreachable) is fixed by the commented catch block. Remaining warnings are pre-existing @typescript-eslint/no-explicit-any from the existing config, not introduced by this PR. 49 occurrences total — can open a follow-up issue to clean those up if you want.

Squashed everything into one commit.

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.

chore: consider biome linter (vs eslint)

2 participants