Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Updated eslint configuration #2851

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

67 changes: 0 additions & 67 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ In general, we try to limit adding third-party production dependencies. If one i

### Coding Style Guidelines/Conventions

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

### Commit Guidelines

Expand Down
641 changes: 226 additions & 415 deletions THIRD_PARTY_NOTICES.md

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ API.prototype.startSegment = function startSegment(name, record, handler, callba
// Create the segment and call the handler.
const wrappedHandler = this.shim.record(handler, function handlerNamer(shim) {
return {
name: name,
name,
recorder: record ? customRecorder : null,
callback: callback ? shim.FIRST : null,
promise: !callback
Expand Down Expand Up @@ -1301,6 +1301,7 @@ API.prototype.recordCustomEvent = function recordCustomEvent(eventType, attribut
}

const tx = this.agent.getTransaction()
// eslint-disable-next-line sonarjs/pseudo-random
const priority = (tx && tx.priority) || Math.random()
this.agent.customEventAggregator.add([intrinsics, filteredAttributes], priority)
}
Expand All @@ -1326,9 +1327,9 @@ API.prototype.instrument = function instrument(moduleName, onRequire, onError) {
let opts = moduleName
if (typeof opts === 'string') {
opts = {
moduleName: moduleName,
onRequire: onRequire,
onError: onError
moduleName,
onRequire,
onError
}
}

Expand Down Expand Up @@ -1391,9 +1392,9 @@ API.prototype.instrumentDatastore = function instrumentDatastore(moduleName, onR
let opts = moduleName
if (typeof opts === 'string') {
opts = {
moduleName: moduleName,
onRequire: onRequire,
onError: onError
moduleName,
onRequire,
onError
}
}

Expand Down Expand Up @@ -1428,9 +1429,9 @@ API.prototype.instrumentWebframework = function instrumentWebframework(
let opts = moduleName
if (typeof opts === 'string') {
opts = {
moduleName: moduleName,
onRequire: onRequire,
onError: onError
moduleName,
onRequire,
onError
}
}

Expand Down Expand Up @@ -1461,9 +1462,9 @@ API.prototype.instrumentMessages = function instrumentMessages(moduleName, onReq
let opts = moduleName
if (typeof opts === 'string') {
opts = {
moduleName: moduleName,
onRequire: onRequire,
onError: onError
moduleName,
onRequire,
onError
}
}

Expand Down
3 changes: 1 addition & 2 deletions bin/compare-bench-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

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

const fs = require('fs/promises')
const { errorAndExit } = require('./utils')
Expand Down Expand Up @@ -114,7 +113,7 @@ const reportResults = async (resultFiles) => {
const resultPath = 'benchmark_results'
try {
await fs.stat(resultPath)
} catch (e) {
} catch {
await fs.mkdir(resultPath)
}
const fileName = `${resultPath}/comparison_${date.getTime()}.md`
Expand Down
4 changes: 2 additions & 2 deletions bin/conventional-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ConventionalChangelog {
* @returns {string} the commit message header with any PR links removed and whitespace trimmed
*/
removePrLinks(subject) {
return subject.replace(/\(\#\d+\)$/, '').trim()
return subject.replace(/\(#\d+\)$/, '').trim()
}

/**
Expand Down Expand Up @@ -211,7 +211,7 @@ class ConventionalChangelog {

const markdownFormatter = conventionalChangelogWriter(context, {
...config.writerOpts,
mainTemplate: mainTemplate,
mainTemplate,
headerPartial: headerTemplate,
commitPartial: commitTemplate,
commitGroupsSort: self.rankedGroupSort
Expand Down
5 changes: 3 additions & 2 deletions bin/create-docs-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ program.option('--dry-run', 'executes script but does not commit nor create PR')
program.option(
'--repo-path <path',
'Path to the docs-website fork on local machine',
// eslint-disable-next-line sonarjs/publicly-writable-directories
'/tmp/docs-website'
)
program.option(
Expand Down Expand Up @@ -242,7 +243,7 @@ function formatReleaseNotes(releaseDate, version, body, frontmatter) {
'subject: Node.js agent',
`releaseDate: '${releaseDate}'`,
`version: ${version.substring(1)}`, // remove the `v` from start of version
`downloadLink: 'https://www.npmjs.com/package/newrelic'`,
"downloadLink: 'https://www.npmjs.com/package/newrelic'",
`security: ${frontmatter.security}`,
`bugs: ${frontmatter.bugfixes}`,
`features: ${frontmatter.features}`,
Expand Down Expand Up @@ -324,7 +325,7 @@ async function createPR(version, branch, dryRun, repoOwner) {

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

Expand Down
1 change: 1 addition & 0 deletions bin/git-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function execAsPromise(command) {
return new Promise((resolve, reject) => {
console.log(`Executing: '${command}'`)

// eslint-disable-next-line sonarjs/os-command
exec(command, (err, stdout) => {
if (err) {
reject(err)
Expand Down
18 changes: 9 additions & 9 deletions bin/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Github {
owner: this.repoOwner,
repo: this.repository,
tag_name: tag,
name: name,
body: body
name,
body
})

return result.data
Expand Down Expand Up @@ -146,7 +146,7 @@ class Github {
owner: this.repoOwner,
repo: this.repository,
workflow_id: nameOrId,
branch: branch,
branch,
per_page: 5
})

Expand All @@ -159,11 +159,11 @@ class Github {
await octokit.pulls.create({
owner: this.repoOwner,
repo: this.repository,
head: head,
base: base,
title: title,
body: body,
draft: draft
head,
base,
title,
body,
draft
})
}

Expand All @@ -181,7 +181,7 @@ class Github {
release_id: id,
body
})
} catch (err) {
} catch {
await new Promise((resolve) => {
const retryWait = 2 ** retryCount * 1000
console.log(
Expand Down
1 change: 1 addition & 0 deletions bin/npm-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function execAsPromise(command) {
return new Promise((resolve, reject) => {
console.log(`Executing: '${command}'`)

// eslint-disable-next-line sonarjs/os-command
exec(command, (err, stdout) => {
if (err) {
return reject(err)
Expand Down
4 changes: 2 additions & 2 deletions bin/pending-prs.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ function stopOnError(err) {

function areEnvVarsSet(dryRun) {
if (dryRun) {
return process.env.hasOwnProperty('GITHUB_TOKEN')
return Object.prototype.hasOwnProperty.call(process.env, 'GITHUB_TOKEN')
}
missingEnvVars = requiredEnvVars.filter((envVar) => !process.env.hasOwnProperty(envVar))
missingEnvVars = requiredEnvVars.filter((envVar) => !Object.prototype.hasOwnProperty.call(process.env, envVar))
return missingEnvVars.length === 0
}

Expand Down
9 changes: 4 additions & 5 deletions bin/run-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ class Printer {

async finish() {
if (opts.console) {
/* eslint-disable no-console */
console.log(JSON.stringify(this._tests, null, 2))
/* eslint-enable no-console */
}
const resultPath = 'benchmark_results'
const filePrefix = opts.filename ? `${opts.filename}` : 'benchmark'
try {
await fs.stat(resultPath)
} catch (e) {
} catch {
await fs.mkdir(resultPath)
}
const content = JSON.stringify(this._tests, null, 2)
Expand All @@ -95,7 +93,7 @@ async function run() {

const resolveGlobs = () => {
if (!globs.length) {
console.error(`There aren't any globs to resolve.`)
console.error("There aren't any globs to resolve.")
return
}
const afterGlobbing = (resolved) => {
Expand Down Expand Up @@ -127,7 +125,8 @@ async function run() {
args.unshift('--inspect-brk')
}

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

child.on('error', (err) => {
console.error(`Error in child test ${test}`, err)
Expand Down
5 changes: 2 additions & 3 deletions bin/test-naming-rules.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#! /usr/bin/env node
#!/usr/bin/env node
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

'use strict'
/* eslint-disable no-console */

const fs = require('fs')
const path = require('path')
Expand Down Expand Up @@ -110,7 +109,7 @@ function run(opts) {

function onAppliedRule(rule, newValue, oldValue) {
appliedRules.push({
rule: rule,
rule,
original: oldValue,
normalized: newValue
})
Expand Down
13 changes: 6 additions & 7 deletions bin/test/create-docs-pr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ test('Create Docs PR script', async (t) => {
const { mockFs, script } = t.nr
mockFs.readFile.yields(null, JSON.stringify({ entries: [{ version: '1.2.3', changes: [] }] }))

// eslint-disable-next-line sonarjs/no-duplicate-string
const func = () => script.getFrontMatter('v2.0.0', 'changelog.json')
await assert.rejects(func, { message: 'Unable to find 2.0.0 entry in changelog.json' })
})
Expand Down Expand Up @@ -151,13 +150,13 @@ test('Create Docs PR script', async (t) => {
const expected = [
'---',
'subject: Node.js agent',
`releaseDate: '2020-04-03'`,
"releaseDate: '2020-04-03'",
'version: 2.0.0',
`downloadLink: 'https://www.npmjs.com/package/newrelic'`,
`security: ["upgraded a dep"]`,
`bugs: ["fixed a bug"]`,
`features: ["added new api method"]`,
`---`,
"downloadLink: 'https://www.npmjs.com/package/newrelic'",
'security: ["upgraded a dep"]',
'bugs: ["fixed a bug"]',
'features: ["added new api method"]',
'---',
'',
'## Notes',
'',
Expand Down
1 change: 0 additions & 1 deletion bin/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
Expand Down
Loading
Loading