Skip to content

Commit b23ecda

Browse files
committed
chore(eslint): defer negated comparison rule
The only finding is a hot ID parser guard where the opposite comparison does not preserve NaN handling.
1 parent 08afd57 commit b23ecda

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ export default [
592592
'unicorn/expiring-todo-comments': 'off',
593593
'unicorn/filename-case': ['off', { case: 'kebabCase' }], // Many errors
594594
'unicorn/name-replacements': 'off', // Many errors | naming churn (split out of prevent-abbreviations)
595-
'unicorn/no-negated-comparison': ['error', { checkLogicalExpressions: true }],
596595
'unicorn/prevent-abbreviations': 'off', // Many errors
597596

598597
// These rules require a newer Node.js version than we support
@@ -652,6 +651,7 @@ export default [
652651
'unicorn/no-break-in-nested-loop': 'off', // Conflicts with our performance-oriented loops
653652
'unicorn/no-global-object-property-assignment': 'off', // We use globalThis[Symbol.for('dd-trace')]
654653
'unicorn/no-negated-array-predicate': 'off', // Predicate inversion is harder to read and creates churn
654+
'unicorn/no-negated-comparison': 'off', // Opposite comparisons do not preserve NaN handling
655655
'unicorn/no-nested-ternary': 'off', // Not really an issue in the code and the benefit is small
656656
'unicorn/no-new-array': 'off', // new Array is often used for performance reasons
657657
'unicorn/no-null': 'off', // We do not control external APIs and it is hard to differentiate these

packages/dd-trace/src/id.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function fromString (str, raddix) {
151151
while (pos < len) {
152152
const chr = Number.parseInt(str[pos++], raddix)
153153

154-
if (Number.isNaN(chr) || chr < 0) break
154+
if (!(chr >= 0)) break // NaN
155155

156156
low = low * raddix + chr
157157
high = high * raddix + Math.floor(low / UINT_MAX)

0 commit comments

Comments
 (0)