Skip to content

Commit d2fba9d

Browse files
authored
chore: Updated eslint configuration (#2851)
1 parent 59f2bd9 commit d2fba9d

File tree

387 files changed

+2028
-1886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+2028
-1886
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc.js

-67
This file was deleted.

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ In general, we try to limit adding third-party production dependencies. If one i
5353

5454
### Coding Style Guidelines/Conventions
5555

56-
We use eslint to enforce certain coding standards. Please see our [.eslintrc](./.eslintrc.js) file for specific rule configuration.
56+
We use eslint to enforce certain coding standards. Please see our [eslint.config.js](./eslint.config.js) file for specific rule configuration.
5757

5858
### Commit Guidelines
5959

THIRD_PARTY_NOTICES.md

+226-415
Large diffs are not rendered by default.

api.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ API.prototype.startSegment = function startSegment(name, record, handler, callba
905905
// Create the segment and call the handler.
906906
const wrappedHandler = this.shim.record(handler, function handlerNamer(shim) {
907907
return {
908-
name: name,
908+
name,
909909
recorder: record ? customRecorder : null,
910910
callback: callback ? shim.FIRST : null,
911911
promise: !callback
@@ -1301,6 +1301,7 @@ API.prototype.recordCustomEvent = function recordCustomEvent(eventType, attribut
13011301
}
13021302

13031303
const tx = this.agent.getTransaction()
1304+
// eslint-disable-next-line sonarjs/pseudo-random
13041305
const priority = (tx && tx.priority) || Math.random()
13051306
this.agent.customEventAggregator.add([intrinsics, filteredAttributes], priority)
13061307
}
@@ -1326,9 +1327,9 @@ API.prototype.instrument = function instrument(moduleName, onRequire, onError) {
13261327
let opts = moduleName
13271328
if (typeof opts === 'string') {
13281329
opts = {
1329-
moduleName: moduleName,
1330-
onRequire: onRequire,
1331-
onError: onError
1330+
moduleName,
1331+
onRequire,
1332+
onError
13321333
}
13331334
}
13341335

@@ -1391,9 +1392,9 @@ API.prototype.instrumentDatastore = function instrumentDatastore(moduleName, onR
13911392
let opts = moduleName
13921393
if (typeof opts === 'string') {
13931394
opts = {
1394-
moduleName: moduleName,
1395-
onRequire: onRequire,
1396-
onError: onError
1395+
moduleName,
1396+
onRequire,
1397+
onError
13971398
}
13981399
}
13991400

@@ -1428,9 +1429,9 @@ API.prototype.instrumentWebframework = function instrumentWebframework(
14281429
let opts = moduleName
14291430
if (typeof opts === 'string') {
14301431
opts = {
1431-
moduleName: moduleName,
1432-
onRequire: onRequire,
1433-
onError: onError
1432+
moduleName,
1433+
onRequire,
1434+
onError
14341435
}
14351436
}
14361437

@@ -1461,9 +1462,9 @@ API.prototype.instrumentMessages = function instrumentMessages(moduleName, onReq
14611462
let opts = moduleName
14621463
if (typeof opts === 'string') {
14631464
opts = {
1464-
moduleName: moduleName,
1465-
onRequire: onRequire,
1466-
onError: onError
1465+
moduleName,
1466+
onRequire,
1467+
onError
14671468
}
14681469
}
14691470

bin/compare-bench-results.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
'use strict'
7-
/* eslint-disable sonarjs/no-duplicate-string, no-console */
87

98
const fs = require('fs/promises')
109
const { errorAndExit } = require('./utils')
@@ -114,7 +113,7 @@ const reportResults = async (resultFiles) => {
114113
const resultPath = 'benchmark_results'
115114
try {
116115
await fs.stat(resultPath)
117-
} catch (e) {
116+
} catch {
118117
await fs.mkdir(resultPath)
119118
}
120119
const fileName = `${resultPath}/comparison_${date.getTime()}.md`

bin/conventional-changelog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ConventionalChangelog {
137137
* @returns {string} the commit message header with any PR links removed and whitespace trimmed
138138
*/
139139
removePrLinks(subject) {
140-
return subject.replace(/\(\#\d+\)$/, '').trim()
140+
return subject.replace(/\(#\d+\)$/, '').trim()
141141
}
142142

143143
/**
@@ -211,7 +211,7 @@ class ConventionalChangelog {
211211

212212
const markdownFormatter = conventionalChangelogWriter(context, {
213213
...config.writerOpts,
214-
mainTemplate: mainTemplate,
214+
mainTemplate,
215215
headerPartial: headerTemplate,
216216
commitPartial: commitTemplate,
217217
commitGroupsSort: self.rankedGroupSort

bin/create-docs-pr.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ program.option('--dry-run', 'executes script but does not commit nor create PR')
3333
program.option(
3434
'--repo-path <path',
3535
'Path to the docs-website fork on local machine',
36+
// eslint-disable-next-line sonarjs/publicly-writable-directories
3637
'/tmp/docs-website'
3738
)
3839
program.option(
@@ -242,7 +243,7 @@ function formatReleaseNotes(releaseDate, version, body, frontmatter) {
242243
'subject: Node.js agent',
243244
`releaseDate: '${releaseDate}'`,
244245
`version: ${version.substring(1)}`, // remove the `v` from start of version
245-
`downloadLink: 'https://www.npmjs.com/package/newrelic'`,
246+
"downloadLink: 'https://www.npmjs.com/package/newrelic'",
246247
`security: ${frontmatter.security}`,
247248
`bugs: ${frontmatter.bugfixes}`,
248249
`features: ${frontmatter.features}`,
@@ -324,7 +325,7 @@ async function createPR(version, branch, dryRun, repoOwner) {
324325

325326
const github = new Github(repoOwner, 'docs-website')
326327
const title = `chore: add Node.js Agent ${version} Release Notes`
327-
const head = repoOwner === `newrelic` ? branch : `${repoOwner}:${branch}`
328+
const head = repoOwner === 'newrelic' ? branch : `${repoOwner}:${branch}`
328329
const body =
329330
'This is an automated PR generated when the Node.js agent is released. Please merge as soon as possible.'
330331

bin/git-commands.js

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ function execAsPromise(command) {
126126
return new Promise((resolve, reject) => {
127127
console.log(`Executing: '${command}'`)
128128

129+
// eslint-disable-next-line sonarjs/os-command
129130
exec(command, (err, stdout) => {
130131
if (err) {
131132
reject(err)

bin/github.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class Github {
4545
owner: this.repoOwner,
4646
repo: this.repository,
4747
tag_name: tag,
48-
name: name,
49-
body: body
48+
name,
49+
body
5050
})
5151

5252
return result.data
@@ -146,7 +146,7 @@ class Github {
146146
owner: this.repoOwner,
147147
repo: this.repository,
148148
workflow_id: nameOrId,
149-
branch: branch,
149+
branch,
150150
per_page: 5
151151
})
152152

@@ -159,11 +159,11 @@ class Github {
159159
await octokit.pulls.create({
160160
owner: this.repoOwner,
161161
repo: this.repository,
162-
head: head,
163-
base: base,
164-
title: title,
165-
body: body,
166-
draft: draft
162+
head,
163+
base,
164+
title,
165+
body,
166+
draft
167167
})
168168
}
169169

@@ -181,7 +181,7 @@ class Github {
181181
release_id: id,
182182
body
183183
})
184-
} catch (err) {
184+
} catch {
185185
await new Promise((resolve) => {
186186
const retryWait = 2 ** retryCount * 1000
187187
console.log(

bin/npm-commands.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function execAsPromise(command) {
1919
return new Promise((resolve, reject) => {
2020
console.log(`Executing: '${command}'`)
2121

22+
// eslint-disable-next-line sonarjs/os-command
2223
exec(command, (err, stdout) => {
2324
if (err) {
2425
return reject(err)

bin/pending-prs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ function stopOnError(err) {
9191

9292
function areEnvVarsSet(dryRun) {
9393
if (dryRun) {
94-
return process.env.hasOwnProperty('GITHUB_TOKEN')
94+
return Object.prototype.hasOwnProperty.call(process.env, 'GITHUB_TOKEN')
9595
}
96-
missingEnvVars = requiredEnvVars.filter((envVar) => !process.env.hasOwnProperty(envVar))
96+
missingEnvVars = requiredEnvVars.filter((envVar) => !Object.prototype.hasOwnProperty.call(process.env, envVar))
9797
return missingEnvVars.length === 0
9898
}
9999

bin/run-bench.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ class Printer {
6969

7070
async finish() {
7171
if (opts.console) {
72-
/* eslint-disable no-console */
7372
console.log(JSON.stringify(this._tests, null, 2))
74-
/* eslint-enable no-console */
7573
}
7674
const resultPath = 'benchmark_results'
7775
const filePrefix = opts.filename ? `${opts.filename}` : 'benchmark'
7876
try {
7977
await fs.stat(resultPath)
80-
} catch (e) {
78+
} catch {
8179
await fs.mkdir(resultPath)
8280
}
8381
const content = JSON.stringify(this._tests, null, 2)
@@ -95,7 +93,7 @@ async function run() {
9593

9694
const resolveGlobs = () => {
9795
if (!globs.length) {
98-
console.error(`There aren't any globs to resolve.`)
96+
console.error("There aren't any globs to resolve.")
9997
return
10098
}
10199
const afterGlobbing = (resolved) => {
@@ -127,7 +125,8 @@ async function run() {
127125
args.unshift('--inspect-brk')
128126
}
129127

130-
const child = cp.spawn('node', args, { cwd: cwd, stdio: 'pipe', silent: true })
128+
// eslint-disable-next-line sonarjs/no-os-command-from-path
129+
const child = cp.spawn('node', args, { cwd, stdio: 'pipe', silent: true })
131130

132131
child.on('error', (err) => {
133132
console.error(`Error in child test ${test}`, err)

bin/test-naming-rules.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#! /usr/bin/env node
1+
#!/usr/bin/env node
22
/*
33
* Copyright 2020 New Relic Corporation. All rights reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
'use strict'
8-
/* eslint-disable no-console */
98

109
const fs = require('fs')
1110
const path = require('path')
@@ -110,7 +109,7 @@ function run(opts) {
110109

111110
function onAppliedRule(rule, newValue, oldValue) {
112111
appliedRules.push({
113-
rule: rule,
112+
rule,
114113
original: oldValue,
115114
normalized: newValue
116115
})

bin/test/create-docs-pr.test.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ test('Create Docs PR script', async (t) => {
7070
const { mockFs, script } = t.nr
7171
mockFs.readFile.yields(null, JSON.stringify({ entries: [{ version: '1.2.3', changes: [] }] }))
7272

73-
// eslint-disable-next-line sonarjs/no-duplicate-string
7473
const func = () => script.getFrontMatter('v2.0.0', 'changelog.json')
7574
await assert.rejects(func, { message: 'Unable to find 2.0.0 entry in changelog.json' })
7675
})
@@ -151,13 +150,13 @@ test('Create Docs PR script', async (t) => {
151150
const expected = [
152151
'---',
153152
'subject: Node.js agent',
154-
`releaseDate: '2020-04-03'`,
153+
"releaseDate: '2020-04-03'",
155154
'version: 2.0.0',
156-
`downloadLink: 'https://www.npmjs.com/package/newrelic'`,
157-
`security: ["upgraded a dep"]`,
158-
`bugs: ["fixed a bug"]`,
159-
`features: ["added new api method"]`,
160-
`---`,
155+
"downloadLink: 'https://www.npmjs.com/package/newrelic'",
156+
'security: ["upgraded a dep"]',
157+
'bugs: ["fixed a bug"]',
158+
'features: ["added new api method"]',
159+
'---',
161160
'',
162161
'## Notes',
163162
'',

bin/utils.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#! /usr/bin/env node
21
/*
32
* Copyright 2020 New Relic Corporation. All rights reserved.
43
* SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)