Skip to content

Commit

Permalink
modernize eslint config
Browse files Browse the repository at this point in the history
* Switch from the old eslintrc format to the newer format via:
  `npx @eslint/migrate-config .eslintrc.json`
* ECMAScript version is now set at 2022, in line with code supported in
  Node.js 16. This is needed for a bunch of ESM syntax like top-level
  await.
* Fixes:
    * ESM files are now covered.
    * Test globals and other test-specific config are now isolated to
      tests.
    * text_map.js has an invalid switch case. Fixed that in what I
      thought was the most reasonable way.
  • Loading branch information
bengl committed Oct 3, 2024
1 parent c700341 commit 00c602e
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 83 deletions.
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ require,rfdc,MIT,Copyright 2019 David Mark Clements
require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
require,shell-quote,mit,Copyright (c) 2013 James Halliday
dev,@types/node,MIT,Copyright Authors
dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
dev,autocannon,MIT,Copyright 2016 Matteo Collina
dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
dev,axios,MIT,Copyright 2014-present Matt Zabriskie
Expand All @@ -51,6 +53,7 @@ dev,eslint-plugin-promise,ISC,jden and other contributors
dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
dev,get-port,MIT,Copyright Sindre Sorhus
dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
dev,globals,MIT,Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
dev,graphql,MIT,Copyright 2015 Facebook Inc.
dev,jszip,MIT,Copyright 2015-2016 Stuart Knightley and contributors
dev,knex,MIT,Copyright (c) 2013-present Tim Griesser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ class Greeter {
sayFarewell () {
return 'farewell'
}

sayGreetings () {
return 'greetings'
}

sayYo () {
return 'yo'
}

sayYeah () {
return 'yeah whatever'
}
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/esbuild/build-and-test-typescript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ await esbuild.build({
external: [
'graphql/language/visitor',
'graphql/language/printer',
'graphql/utilities',
],
'graphql/utilities'
]
})

console.log('ok') // eslint-disable-line no-console
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/esbuild/complex-app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import 'dd-trace/init.js'
import assert from 'assert'
import express from 'express'
import redis from 'redis'
const app = express()
const PORT = 3000
import pg from 'pg'
import PGP from 'pg-promise' // transient dep of 'pg'

const app = express()
const PORT = 3000
const pgp = PGP()

assert.equal(redis.Graph.name, 'Graph')
Expand Down
4 changes: 4 additions & 0 deletions loader-hook.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// TODO(bengl): Not sure why `import/export` fails on this line, but it's just
// a passthrough to another module so it should be fine. Disabling for now.

// eslint-disable-next-line import/export
export * from 'import-in-the-middle/hook.mjs'
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
"tlhunter-sorted-set": "^0.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@types/node": "^16.18.103",
"autocannon": "^4.5.2",
"aws-sdk": "^2.1446.0",
Expand All @@ -130,6 +132,7 @@
"express": "^4.18.2",
"get-port": "^3.2.0",
"glob": "^7.1.6",
"globals": "^15.10.0",
"graphql": "0.13.2",
"jszip": "^3.5.0",
"knex": "^2.4.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ const client = new Client({

await client.connect()
await client.execute('SELECT now() FROM local;')
await client.shutdown()
await client.shutdown()
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { Client } from '@elastic/elasticsearch'

const client = new Client({ node: 'http://localhost:9200' })

await client.ping()
await client.ping()
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const [subscription] = await topic.createSubscription('foo')

await topic.publishMessage({ data: Buffer.from('Test message!') })
await subscription.close()
await pubsub.close()
await pubsub.close()
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const schema = new graphql.GraphQLSchema({
})
})

await graphql.graphql({
schema,
source: `query MyQuery { hello(name: "world") }`,
await graphql.graphql({
schema,
source: 'query MyQuery { hello(name: "world") }',
variableValues: { who: 'world' }
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import getPort from 'get-port'
const port = await getPort()
const gateway = Gateway({
edgemicro: {
port: port,
port,
logging: { level: 'info', dir: os.tmpdir() }
},
proxies: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ const db = client.db('test_db')
const collection = db.collection('test_collection')
collection.insertOne({ a: 1 }, {}, () => {})
setTimeout(() => { client.close() }, 1500)

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const connectPromise = new Promise((resolve, reject) => {
await server.connect()
await connectPromise

server.insert(`test.your_collection_name`, [{ a: 1 }], {}, (err) => {
server.insert('test.your_collection_name', [{ a: 1 }], {}, (err) => {
if (err) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ client.on('end', () => {

client.on('error', (err) => {
client.end()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nock('https://api.openai.com:443')
])

const openaiApp = new openai.OpenAIApi(new openai.Configuration({
apiKey: 'sk-DATADOG-ACCEPTANCE-TESTS',
apiKey: 'sk-DATADOG-ACCEPTANCE-TESTS'
}))

await openaiApp.createCompletion({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dd-trace/init.js'
import opensearch from '@opensearch-project/opensearch'

const client = new opensearch.Client({ node: `http://localhost:9201` })
const client = new opensearch.Client({ node: 'http://localhost:9201' })
await client.ping()
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ const config = {
user: 'test',
password: 'Oracle18',
connectString: `${hostname}:1521/xepdb1`
};
}

const dbQuery = 'select current_timestamp from dual'

let connection;

connection = await oracledb.getConnection(config)
const connection = await oracledb.getConnection(config)
await connection.execute(dbQuery)

if (connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import ShareDB from 'sharedb'
const backend = new ShareDB({ presence: true })
const connection = backend.connect()
await connection.get('some-collection', 'some-id').fetch()
connection.close()
connection.close()
11 changes: 7 additions & 4 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,17 @@ class TextMapPropagator {
case 'tracecontext':
spanContext = this._extractTraceparentContext(carrier)
break
case 'b3' && this
._config
.tracePropagationStyle
.otelPropagators: // TODO: should match "b3 single header" in next major
case 'b3 single header': // TODO: delete in major after singular "b3"
spanContext = this._extractB3SingleContext(carrier)
break
case 'b3':
if (this._config.tracePropagationStyle.otelPropagators) {
// TODO: should match "b3 single header" in next major
spanContext = this._extractB3SingleContext(carrier)
} else {
spanContext = this._extractB3MultiContext(carrier)
}
break
case 'b3multi':
spanContext = this._extractB3MultiContext(carrier)
break
Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/test/fixtures/esm/esm-hook-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ esmHook(['express', 'os'], (exports, name, baseDir) => {
const { freemem } = await import('os')
const expressResult = expressDefault()
const express = typeof expressResult === 'function' ? 'express()' : expressResult
// eslint-disable-next-line no-console
console.log(JSON.stringify({
express,
freemem: freemem()
Expand Down
46 changes: 45 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,31 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@eslint/eslintrc@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.1.0.tgz#dbd3482bfd91efa663cbe7aa1f506839868207b6"
integrity sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==
dependencies:
ajv "^6.12.4"
debug "^4.3.2"
espree "^10.0.1"
globals "^14.0.0"
ignore "^5.2.0"
import-fresh "^3.2.1"
js-yaml "^4.1.0"
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@eslint/[email protected]":
version "8.57.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==

"@eslint/js@^9.11.1":
version "9.11.1"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.11.1.tgz#8bcb37436f9854b3d9a561440daf916acd940986"
integrity sha512-/qu+TWz8WwPWc7/HcIJKi+c+MOm46GdVaSlTTQcaqaL53+GsoA6MxWp5PtTx48qbSP7ylM1Kn7nhvkugfJvRSA==

"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
Expand Down Expand Up @@ -739,7 +759,7 @@ acorn-jsx@^5.3.2:
resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz"
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==

acorn@^8.8.2, acorn@^8.9.0:
acorn@^8.12.0, acorn@^8.8.2, acorn@^8.9.0:
version "8.12.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248"
integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==
Expand Down Expand Up @@ -1926,6 +1946,11 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

eslint-visitor-keys@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz#1f785cc5e81eb7534523d85922248232077d2f8c"
integrity sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==

eslint@^8.57.0:
version "8.57.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668"
Expand Down Expand Up @@ -1975,6 +2000,15 @@ esm@^3.2.25:
resolved "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz"
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==

espree@^10.0.1:
version "10.2.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-10.2.0.tgz#f4bcead9e05b0615c968e85f83816bc386a45df6"
integrity sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==
dependencies:
acorn "^8.12.0"
acorn-jsx "^5.3.2"
eslint-visitor-keys "^4.1.0"

espree@^9.6.0, espree@^9.6.1:
version "9.6.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f"
Expand Down Expand Up @@ -2375,6 +2409,16 @@ globals@^13.19.0, globals@^13.24.0:
dependencies:
type-fest "^0.20.2"

globals@^14.0.0:
version "14.0.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e"
integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==

globals@^15.10.0:
version "15.10.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.10.0.tgz#a7eab3886802da248ad8b6a9ccca6573ff899c9b"
integrity sha512-tqFIbz83w4Y5TCbtgjZjApohbuh7K9BxGYFm7ifwDR240tvdb7P9x+/9VvUKlmkPoiknoJtanI8UOrqxS3a7lQ==

globalthis@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236"
Expand Down

0 comments on commit 00c602e

Please sign in to comment.