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

Clean up ESLint config #5214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/insecure-bank.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const http = require('http')
IlyasShabi marked this conversation as resolved.
Show resolved Hide resolved
const app = require('/opt/insecure-bank-js/app')
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path

const { port } = require('./common')

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec/insecure-bank.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const http = require('http')
const app = require('/opt/insecure-bank-js/app')
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path

const { port } = require('./common')

Expand Down
87 changes: 46 additions & 41 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import mocha from 'eslint-plugin-mocha'
import n from 'eslint-plugin-n'
import stylistic from '@stylistic/eslint-plugin-js'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'

import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin-js'
import mocha from 'eslint-plugin-mocha'
import n from 'eslint-plugin-n'
import globals from 'globals'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
})
const compat = new FlatCompat({ baseDirectory: __dirname })

const TEST_FILES = [
'packages/*/test/**/*.js',
'packages/*/test/**/*.mjs',
'integration-tests/**/*.js',
'integration-tests/**/*.mjs',
'**/*.spec.js'
]

export default [
{
Expand All @@ -31,9 +36,13 @@ export default [
'packages/dd-trace/src/appsec/blocked_templates.js', // TODO Why is this ignored?
'packages/dd-trace/src/payload-tagging/jsonpath-plus.js' // Vendored
]
}, ...compat.extends('eslint:recommended', 'standard', 'plugin:mocha/recommended'), {
},
{ name: '@eslint/js/recommnded', ...js.configs.recommended },
...compat.extends('standard').map((config, i) => ({ name: config.name || `standard/${i + 1}`, ...config })),
{
name: 'dd-trace/defaults',

plugins: {
mocha,
n,
'@stylistic/js': stylistic
},
Expand All @@ -48,47 +57,43 @@ export default [

settings: {
node: {
version: '>=16.0.0'
// Used by `eslint-plugin-n` to determine the minimum version of Node.js to support.
// Normally setting this in the `package.json` engines field is enough, but when we have more than one active
// major release line at the same time, we need to specify the lowest version here to ensure backporting will
// not fail.
version: '>=18.0.0'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we agree we'd keep v4 "backportable" in case we need to, and thus keep v16.0.0 for now ?

},

rules: {
'@stylistic/js/max-len': ['error', { code: 120, tabWidth: 2 }],
'@stylistic/js/object-curly-newline': ['error', {
multiline: true,
consistent: true
}],
'@stylistic/js/object-curly-newline': ['error', { multiline: true, consistent: true }],
'@stylistic/js/object-curly-spacing': ['error', 'always'],
'import/no-absolute-path': 'off',
'import/no-extraneous-dependencies': 'error',
'n/no-callback-literal': 'off',
'n/no-restricted-require': ['error', ['diagnostics_channel']],
'no-console': 'error',
'no-prototype-builtins': 'off',
'no-unused-expressions': 'off',
'no-var': 'error',
'prefer-const': 'error',
'standard/no-callback-literal': 'off'
'no-prototype-builtins': 'off', // Override (turned on by @eslint/js/recommnded)
'no-unused-expressions': 'off', // Override (turned on by standard)
'no-var': 'error' // Override (set to warn in standard)
}
},
{
files: [
'packages/*/test/**/*.js',
'packages/*/test/**/*.mjs',
'integration-tests/**/*.js',
'integration-tests/**/*.mjs',
'**/*.spec.js'
],
name: 'mocha/recommnded',
...mocha.configs.flat.recommended,
files: TEST_FILES
},
{
name: 'dd-trace/tests/all',
files: TEST_FILES,
languageOptions: {
globals: {
...globals.mocha,
sinon: false,
expect: false,
proxyquire: false,
withVersions: false,
withPeerService: false,
withNamingSchema: false,
withExports: false
sinon: 'readonly',
expect: 'readonly',
proxyquire: 'readonly',
withVersions: 'readonly',
withPeerService: 'readonly',
withNamingSchema: 'readonly',
withExports: 'readonly'
}
},
rules: {
Expand All @@ -101,11 +106,11 @@ export default [
'mocha/no-sibling-hooks': 'off',
'mocha/no-skipped-tests': 'off',
'mocha/no-top-level-hooks': 'off',
'n/handle-callback-err': 'off',
'no-loss-of-precision': 'off'
'n/handle-callback-err': 'off'
}
},
{
name: 'dd-trace/tests/integration',
files: [
'integration-tests/**/*.js',
'integration-tests/**/*.mjs',
Expand Down
12 changes: 0 additions & 12 deletions integration-tests/.eslintrc.json

This file was deleted.

8 changes: 4 additions & 4 deletions integration-tests/appsec/esm-app/worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ if (isMainThread) {
throw e
})
} else {
function dummyOperation (a) {
return a + 'dummy operation with concat'
}

dummyOperation('should not crash')
}

function dummyOperation (a) {
return a + 'dummy operation with concat'
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type:doc": "cd docs && yarn && yarn build",
"type:test": "cd docs && yarn && yarn test",
"lint": "node scripts/check_licenses.js && eslint . && yarn audit",
"lint-fix": "node scripts/check_licenses.js && eslint . --fix && yarn audit",
"lint:fix": "node scripts/check_licenses.js && eslint . --fix && yarn audit",
"release:proposal": "node scripts/release/proposal",
"services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
"test": "SERVICES=* yarn services && mocha --expose-gc 'packages/dd-trace/test/setup/node.js' 'packages/*/test/**/*.spec.js'",
Expand Down Expand Up @@ -117,7 +117,7 @@
"devDependencies": {
"@apollo/server": "^4.11.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@eslint/js": "^8.57.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version of is actually not compatible with the major version of ESLint we use (v8). Once we upgrade to v9, we can upgrade this as well

"@msgpack/msgpack": "^3.0.0-beta3",
"@stylistic/eslint-plugin-js": "^2.8.0",
"@types/node": "^16.0.0",
Expand Down
21 changes: 0 additions & 21 deletions packages/.eslintrc.json

This file was deleted.

23 changes: 0 additions & 23 deletions packages/dd-trace/test/.eslintrc.json

This file was deleted.

12 changes: 6 additions & 6 deletions packages/dd-trace/test/debugger/devtools_client/state.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ describe('findScriptFromPartialPath', function () {
})
})
})
})

function testPath (path) {
return function () {
const result = state.findScriptFromPartialPath(path)
expect(result).to.deep.equal([url, scriptId, undefined])
function testPath (path) {
return function () {
const result = state.findScriptFromPartialPath(path)
expect(result).to.deep.equal([url, scriptId, undefined])
}
}
}
})
}

describe('multiple partial matches', function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/encode/0.5.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('encode 0.5', () => {
example: 1
},
start: 123123123123123120,
duration: 456456456456456456,
duration: 4564564564564564,
Copy link
Collaborator Author

@watson watson Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because I re-enabled no-loss-of-precision rule

links: []
}]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('format', () => {
_service: 'test'
}),
setTag: sinon.stub(),
_startTime: 1500000000000.123456,
_startTime: 1500000000000.123,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because I re-enabled no-loss-of-precision rule

_duration: 100
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/lambda/fixtures/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const handler = async (_event, _context) => {
const callbackHandler = (_event, _context, callback) => {
const response = sampleResponse

callback('', response)
callback('', response) // eslint-disable-line n/no-callback-literal
}

const timeoutHandler = async (...args) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/llmobs/sdk/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ describe('sdk', () => {
function myWorkflow (input, cb) {
span = llmobs._active()
setTimeout(() => {
cb('output', 'ignore')
cb('output', 'ignore') // eslint-disable-line n/no-callback-literal
}, 1000)
}

Expand Down
11 changes: 0 additions & 11 deletions packages/dd-trace/test/profiling/.eslintrc.json

This file was deleted.

8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@
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==
"@eslint/js@^8.57.1":
version "8.57.1"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2"
integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==

"@graphql-tools/merge@^8.4.1":
version "8.4.2"
Expand Down
Loading