feat(eslint): add no-does-not-throw rule with auto-fix#7692
Conversation
Add an ESLint rule that bans `assert.doesNotThrow()` in test files and
auto-fixes violations by extracting the callback body directly.
Per CLAUDE.md: "Never use the doesNotThrow() assertion. Instead,
execute the method directly — if it throws, the test will fail."
Auto-fix handles:
- Arrow with expression body: assert.doesNotThrow(() => expr) → expr
- Arrow/function with block body: extracts statements
- Function reference: assert.doesNotThrow(fn) → fn()
- Destructured doesNotThrow from require('assert')
Fixes all ~50 existing violations across 25 test files, including
cascading cleanups (unused assert imports, let→const).
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Overall package sizeSelf size: 4.93 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Add ESLint rules and a CI check based on recurring PR review themes: 1. eslint-no-structured-clone: bans structuredClone() in production code (not available in all supported Node.js versions) 2. eslint-prefer-assert-object-contains: detects 3+ consecutive assert.strictEqual calls on the same object and suggests using assertObjectContains instead (currently off, 143 violations) 3. check-config-completeness: validates that all DD_/OTEL_ env vars in config/index.js are registered in supported-configurations.json Note: eslint-no-object-keys-length and eslint-no-does-not-throw have been split into separate PRs (#7691 and #7692) with auto-fix support. Co-Authored-By: Claude Opus 4.6 <[email protected]>
BenchmarksBenchmark execution time: 2026-03-06 17:39:09 Comparing candidate commit 530fc69 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7692 +/- ##
=======================================
Coverage 80.31% 80.32%
=======================================
Files 739 739
Lines 31946 31960 +14
=======================================
+ Hits 25657 25671 +14
Misses 6289 6289 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
BridgeAR
left a comment
There was a problem hiding this comment.
I like this, while we can replace the custom rule with no-restricted-syntax:
{
selector: "CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])",
message: 'Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead.',
}
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM, just left a independent of the change suggestion
packages/dd-trace/test/appsec/iast/taint-tracking/rewriter.spec.js
Outdated
Show resolved
Hide resolved
…icted-syntax Simplifies the implementation by using the built-in ESLint no-restricted-syntax rule with an AST selector, per BridgeAR's review suggestion. The ~50 existing violations were already fixed in the previous commits, so the custom auto-fix machinery is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…c.js Co-authored-by: Ruben Bridgewater <[email protected]>
The no-restricted-syntax ESLint rule now statically enforces this convention, making the manual instruction in AGENTS.md redundant. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
85bbc95 to
530fc69
Compare
|
✨ Fix all issues with BitsAI or with Cursor
|
Add an ESLint rule that bans `assert.doesNotThrow()` in test files. All entries where it was used are fixed and CLAUDE.md is adjusted, since the comment is not needed anymore. --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Ruben Bridgewater <[email protected]>
Add an ESLint rule that bans `assert.doesNotThrow()` in test files. All entries where it was used are fixed and CLAUDE.md is adjusted, since the comment is not needed anymore. --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Ruben Bridgewater <[email protected]>
Summary
assert.doesNotThrow()in test files (per CLAUDE.md)no-restricted-syntaxrule with an AST selector — no custom rule neededassertimports, converted 2let→constFix patterns applied
assert.doesNotThrow(() => expr)exprassert.doesNotThrow(() => { stmt1; stmt2 })stmt1stmt2assert.doesNotThrow(fn)fn()assert.doesNotThrow(obj.method)obj.method()Test plan
npm run lintpasses clean🤖 Generated with Claude Code