Skip to content

feat(eslint): integrate eslint-plugin-sonarjs (closes #207)#211

Merged
JoshuaVSherman merged 1 commit into
devfrom
feat-issue-207-sonarjs
May 18, 2026
Merged

feat(eslint): integrate eslint-plugin-sonarjs (closes #207)#211
JoshuaVSherman merged 1 commit into
devfrom
feat-issue-207-sonarjs

Conversation

@JoshuaVSherman
Copy link
Copy Markdown
Contributor

Summary

  • Adds eslint-plugin-sonarjs@^4 to the flat config (sonarjs.configs.recommended).
  • Fixes the 6 sonarjs errors surfaced on dev: 1 readability bug fix (no-unenclosed-multiline-block in src/AgController/index.ts:99), 1 inline disable with justification (pseudo-random for the pulse heartbeat), and 1 test-files-only override block disabling no-nested-functions for mock factories.
  • eslint --fix cleaned up ~35 stale // eslint-disable-line comments for rules that aren't active anymore.

Not addressed (out of scope)

86 pre-existing @typescript-eslint/no-explicit-any warnings remain. They predate this PR and the rule is already configured as warn, not error, so they don't fail the build. Separate cleanup if desired.

Test plan

  • npx eslint . → 0 errors (86 pre-existing no-explicit-any warnings remain)
  • npm test → 66/66 tests pass
  • Spot-check the readability fix in src/AgController/index.ts:99-104 — braces around else { break; } and the istanbul-ignore comment moved to its own line.
  • Confirm the test-files override block is appropriately scoped.

Closes #207.

🤖 Generated with Claude Code

Adds eslint-plugin-sonarjs@^4 to the flat config and fixes/scopes all
findings reported on the dev branch.

## Sonarjs findings addressed (6 errors → 0)

- sonarjs/no-unenclosed-multiline-block (1, src/AgController/index.ts:99):
  Real readability bug — `} else break;` followed by an `if` on the next
  line looked ambiguous. Added braces around `else { break; }` and moved
  the istanbul-ignore comment to its own line.

- sonarjs/pseudo-random (1, src/AgController/index.ts:58): disabled with
  inline justification — this is a non-security pulse heartbeat (an
  arbitrary 0-4 number transmitted to clients every second), Math.random
  is fine here.

- sonarjs/no-nested-functions (4, test/**): disabled for test files via a
  files: ['test/**/*.ts'] override block. The findings are all in mock
  factories with deeply-nested arrow chains (e.g. socketcluster's
  receiver→createConsumer→next→Promise.resolve pattern); refactoring
  these into named helpers hurts readability instead of improving it.
  Rule stays active for src/.

## Stale eslint-disable comments cleaned (eslint --fix)

The sonarjs recommended config surfaced ~35 pre-existing
`// eslint-disable-line` comments for rules that aren't active anymore
(no-await-in-loop, no-constant-condition, no-console, etc.). `eslint --fix`
removed them automatically across src/AgController/, src/app/, and
src/model/.

## What's NOT addressed

86 pre-existing `@typescript-eslint/no-explicit-any` warnings remain.
These predate this PR and are out of scope; the `no-explicit-any` rule
is already set to `warn` in the config (not `error`), so they don't fail
the build. Tackle separately if desired.

Verified: 66/66 tests pass; 0 ESLint errors.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JoshuaVSherman JoshuaVSherman merged commit ebd082a into dev May 18, 2026
2 checks passed
@JoshuaVSherman JoshuaVSherman deleted the feat-issue-207-sonarjs branch May 18, 2026 23:10
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.

Integrate eslint-plugin-sonarjs and fix linting findings

1 participant