Skip to content

Commit fe46784

Browse files
authored
chore: update eslint-plugin-unicorn and fix related issues (#6836)
As drive-by fix increase the minimum dependency versions in a few cases.
1 parent 1ce3186 commit fe46784

File tree

17 files changed

+141
-158
lines changed

17 files changed

+141
-158
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@
160160
"ttl-set": "^1.0.0"
161161
},
162162
"devDependencies": {
163-
"@babel/helpers": "^7.27.6",
163+
"@babel/helpers": "^7.28.4",
164164
"@eslint/eslintrc": "^3.3.1",
165-
"@eslint/js": "^9.29.0",
165+
"@eslint/js": "^9.39.0",
166166
"@msgpack/msgpack": "^3.1.2",
167167
"@openfeature/core": "^1.9.0",
168168
"@openfeature/server-sdk": "^1.20.0",
169-
"@stylistic/eslint-plugin": "^5.0.0",
169+
"@stylistic/eslint-plugin": "^5.5.0",
170170
"@types/chai": "^4.3.16",
171171
"@types/mocha": "^10.0.10",
172172
"@types/node": "^18.19.106",
@@ -177,13 +177,13 @@
177177
"body-parser": "^2.2.0",
178178
"bun": "1.3.1",
179179
"chai": "^4.5.0",
180-
"eslint": "^9.29.0",
181-
"eslint-plugin-cypress": "^5.1.0",
180+
"eslint": "^9.39.0",
181+
"eslint-plugin-cypress": "^5.2.0",
182182
"eslint-plugin-import": "^2.32.0",
183-
"eslint-plugin-mocha": "^11.1.0",
184-
"eslint-plugin-n": "^17.20.0",
183+
"eslint-plugin-mocha": "^11.2.0",
184+
"eslint-plugin-n": "^17.23.1",
185185
"eslint-plugin-promise": "^7.2.1",
186-
"eslint-plugin-unicorn": "^61.0.2",
186+
"eslint-plugin-unicorn": "^62.0.0",
187187
"express": "^5.1.0",
188188
"glob": "^10.4.5",
189189
"globals": "^16.3.0",

packages/datadog-plugin-grpc/src/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
const pick = require('../../datadog-core/src/utils/src/pick')
44
const log = require('../../dd-trace/src/log')
55

6+
function getEmptyObject () {
7+
return {}
8+
}
9+
610
module.exports = {
711
getMethodMetadata (path, kind) {
812
const tags = {
@@ -57,6 +61,6 @@ module.exports = {
5761
log.error('Expected \'%s\' to be an array or function.', filter)
5862
}
5963

60-
return () => ({})
64+
return getEmptyObject
6165
}
6266
}

packages/datadog-plugin-http/src/client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,17 @@ function normalizeClientConfig (config) {
183183
}
184184
}
185185

186+
function is400ErrorCode (code) {
187+
return code < 400 || code >= 500
188+
}
189+
186190
function getStatusValidator (config) {
187191
if (typeof config.validateStatus === 'function') {
188192
return config.validateStatus
189193
} else if (config.hasOwnProperty('validateStatus')) {
190194
log.error('Expected `validateStatus` to be a function.')
191195
}
192-
return code => code < 400 || code >= 500
196+
return is400ErrorCode
193197
}
194198

195199
function getFilter (config) {

packages/datadog-plugin-http2/src/client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,17 @@ function hasAmazonSignature (headers, path) {
162162
return false
163163
}
164164

165+
function is400ErrorCode (code) {
166+
return code < 400 || code >= 500
167+
}
168+
165169
function getStatusValidator (config) {
166170
if (typeof config.validateStatus === 'function') {
167171
return config.validateStatus
168172
} else if (config.hasOwnProperty('validateStatus')) {
169173
log.error('Expected `validateStatus` to be a function.')
170174
}
171-
return code => code < 400 || code >= 500
175+
return is400ErrorCode
172176
}
173177

174178
function normalizeConfig (config) {

packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const STRINGIFY_SENSITIVE_KEY = STRINGIFY_RANGE_KEY + 'SENSITIVE'
88
const STRINGIFY_SENSITIVE_NOT_STRING_KEY = STRINGIFY_SENSITIVE_KEY + 'NOTSTRING'
99

1010
// eslint-disable-next-line @stylistic/max-len
11-
const KEYS_REGEX_WITH_SENSITIVE_RANGES = new RegExp(`(?:"(${STRINGIFY_RANGE_KEY}_\\d+_))|(?:"(${STRINGIFY_SENSITIVE_KEY}_\\d+_(\\d+)_))|("${STRINGIFY_SENSITIVE_NOT_STRING_KEY}_\\d+_([\\s0-9.a-zA-Z]*)")`, 'gm')
12-
const KEYS_REGEX_WITHOUT_SENSITIVE_RANGES = new RegExp(`"(${STRINGIFY_RANGE_KEY}_\\d+_)`, 'gm')
11+
const KEYS_REGEX_WITH_SENSITIVE_RANGES = new RegExp(String.raw`(?:"(${STRINGIFY_RANGE_KEY}_\d+_))|(?:"(${STRINGIFY_SENSITIVE_KEY}_\d+_(\d+)_))|("${STRINGIFY_SENSITIVE_NOT_STRING_KEY}_\d+_([\s0-9.a-zA-Z]*)")`, 'gm')
12+
const KEYS_REGEX_WITHOUT_SENSITIVE_RANGES = new RegExp(String.raw`"(${STRINGIFY_RANGE_KEY}_\d+_)`, 'gm')
1313

1414
const sensitiveValueRegex = new RegExp(DEFAULT_IAST_REDACTION_VALUE_PATTERN, 'gmi')
1515

packages/dd-trace/src/appsec/iast/vulnerability-reporter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ function sendVulnerabilities (vulnerabilities, span) {
8484
const jsonToSend = vulnerabilitiesFormatter.toJson(validatedVulnerabilities)
8585

8686
if (jsonToSend.vulnerabilities.length > 0) {
87-
const tags = {}
88-
// TODO: Store this outside of the span and set the tag in the exporter.
89-
tags[IAST_JSON_TAG_KEY] = JSON.stringify(jsonToSend)
87+
const tags = {
88+
// TODO: Store this outside of the span and set the tag in the exporter.
89+
[IAST_JSON_TAG_KEY]: JSON.stringify(jsonToSend)
90+
}
9091
span.addTags(tags)
9192
}
9293
}

packages/dd-trace/src/debugger/devtools_client/snapshot/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ module.exports = {
1313
getLocalStateForCallFrame
1414
}
1515

16+
function returnError () {
17+
return new Error('Error getting local state')
18+
}
19+
1620
async function getLocalStateForCallFrame (
1721
callFrame,
1822
{
@@ -37,7 +41,7 @@ async function getLocalStateForCallFrame (
3741
// TODO: We might be able to get part of the scope chain.
3842
// Consider if we could set errors just for the part of the scope chain that throws during collection.
3943
log.error('[debugger:devtools_client] Error getting local state for call frame', err)
40-
return () => new Error('Error getting local state')
44+
return returnError
4145
}
4246

4347
// Delay calling `processRawState` so the caller gets a chance to resume the main thread before processing `rawState`

packages/dd-trace/src/exporters/common/docker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const uuidSource =
1212
const containerSource = '[0-9a-f]{64}'
1313
const taskSource = String.raw`[0-9a-f]{32}-\d+`
1414
const lineReg = /^(\d+):([^:]*):(.+)$/m
15-
const entityReg = new RegExp(`.*(${uuidSource}|${containerSource}|${taskSource})(?:\\.scope)?$`, 'm')
15+
const entityReg = new RegExp(String.raw`.*(${uuidSource}|${containerSource}|${taskSource})(?:\.scope)?$`, 'm')
1616

1717
let inode = 0
1818
let cgroup = ''

packages/dd-trace/src/exporters/span-stats/writer.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ function makeRequest (data, url, cb) {
3636
'Datadog-Meta-Lang': 'javascript',
3737
'Datadog-Meta-Tracer-Version': pkg.version,
3838
'Content-Type': 'application/msgpack'
39-
}
39+
},
40+
protocol: url.protocol,
41+
hostname: url.hostname,
42+
port: url.port
4043
}
4144

42-
options.protocol = url.protocol
43-
options.hostname = url.hostname
44-
options.port = url.port
45-
4645
log.debug('Request to the intake: %j', options)
4746

4847
request(data, options, (err, res) => {

packages/dd-trace/src/llmobs/plugins/anthropic.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,9 @@ class AnthropicLLMObsPlugin extends LLMObsPlugin {
242242
const cacheWriteTokens = usage.cache_creation_input_tokens
243243
const cacheReadTokens = usage.cache_read_input_tokens
244244

245-
const metrics = {}
246-
247-
metrics.inputTokens =
248-
(inputTokens ?? 0) +
249-
(cacheWriteTokens ?? 0) +
250-
(cacheReadTokens ?? 0)
245+
const metrics = {
246+
inputTokens: (inputTokens ?? 0) + (cacheWriteTokens ?? 0) + (cacheReadTokens ?? 0)
247+
}
251248

252249
if (outputTokens) metrics.outputTokens = outputTokens
253250
const totalTokens = metrics.inputTokens + (outputTokens ?? 0)

0 commit comments

Comments
 (0)