Skip to content

Commit 451520a

Browse files
committed
Enable recommended rules for eslint-plugin-n
1 parent dc57b5a commit 451520a

File tree

30 files changed

+59
-9
lines changed

30 files changed

+59
-9
lines changed

benchmark/sirun/appsec-iast/insecure-bank.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const http = require('http')
2-
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path
2+
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path, n/no-missing-require
33

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

benchmark/sirun/appsec/insecure-bank.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const http = require('http')
2-
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path
2+
const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path, n/no-missing-require
33

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

benchmark/sirun/plugin-bluebird/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if (Number(process.env.USE_TRACER)) {
44
require('../../..').init()
55
}
66

7+
// eslint-disable-next-line n/no-missing-require
78
const Promise = require('../../../versions/bluebird/node_modules/bluebird/js/release/bluebird')
89

910
const count = process.env.COUNT ? Number(process.env.COUNT) : 50000

esbuild.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
'use strict'
22

3+
// TODO: It shouldn't be necessary to disable n/no-unpublished-require - Research
4+
// eslint-disable-next-line n/no-unpublished-require
35
module.exports = require('./packages/datadog-esbuild/index.js')

eslint.config.mjs

+22-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ export default [
4040
},
4141
{ name: '@eslint/js/recommnded', ...js.configs.recommended },
4242
...compat.extends('standard').map((config, i) => ({ name: config.name || `standard/${i + 1}`, ...config })),
43+
{
44+
...n.configs['flat/recommended'],
45+
ignores: [
46+
'packages/dd-trace/test/appsec/next/app-dir/**/*.js',
47+
'packages/dd-trace/test/appsec/next/pages-dir/**/*.js',
48+
'packages/datadog-plugin-next/test/app/**/*.js',
49+
'packages/datadog-plugin-next/test/**/pages/**/*.js',
50+
'packages/datadog-plugin-next/test/middleware.js',
51+
'**/*.mjs' // TODO: This shoudln't be required, research why it is
52+
]
53+
},
4354
{
4455
name: 'dd-trace/defaults',
4556

4657
plugins: {
47-
n,
4858
'@stylistic/js': stylistic
4959
},
5060

@@ -72,6 +82,15 @@ export default [
7282
'@stylistic/js/object-curly-spacing': ['error', 'always'],
7383
'import/no-extraneous-dependencies': 'error',
7484
'n/no-restricted-require': ['error', ['diagnostics_channel']],
85+
'n/hashbang': 'off', // TODO: Enable this rule once we have a plan to address it
86+
'n/no-process-exit': 'off', // TODO: Enable this rule once we have a plan to address it
87+
'n/no-unsupported-features/node-builtins': ['error', {
88+
ignores: [
89+
'async_hooks.createHook',
90+
'async_hooks.executionAsyncId',
91+
'async_hooks.executionAsyncResource'
92+
]
93+
}],
7594
'no-console': 'error',
7695
'no-prototype-builtins': 'off', // Override (turned on by @eslint/js/recommnded)
7796
'no-unused-expressions': 'off', // Override (turned on by standard)
@@ -107,7 +126,8 @@ export default [
107126
'mocha/no-sibling-hooks': 'off',
108127
'mocha/no-skipped-tests': 'off',
109128
'mocha/no-top-level-hooks': 'off',
110-
'n/handle-callback-err': 'off'
129+
'n/handle-callback-err': 'off',
130+
'n/no-missing-require': 'off'
111131
}
112132
},
113133
{

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
'use strict'
22

3+
// TODO: It shouldn't be necessary to disable n/no-unpublished-require - Research
4+
// eslint-disable-next-line n/no-unpublished-require
35
module.exports = require('./packages/dd-trace')

init.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/* eslint-disable no-var */
44

5+
// TODO: It shouldn't be necessary to disable n/no-unpublished-require - Research
6+
// eslint-disable-next-line n/no-unpublished-require
57
var guard = require('./packages/dd-trace/src/guardrails')
68

79
module.exports = guard(function () {

initialize.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* hook will always be active for ESM support.
1111
*/
1212

13+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
14+
1315
import { isMainThread } from 'worker_threads'
1416

1517
import * as Module from 'node:module'

integration-tests/appsec/esm-app/index.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
23

34
import childProcess from 'node:child_process'
45
import express from 'express'

integration-tests/appsec/multer.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { allowExperimental: true }] */
23

34
const { assert } = require('chai')
45
const path = require('path')

integration-tests/ci-visibility/run-workerpool.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const workerpool = require('workerpool')
1+
const workerpool = require('workerpool') // eslint-disable-line n/no-extraneous-require
22
const pool = workerpool.pool({ workerType: 'process' })
33

44
function add (a, b) {

integration-tests/ci-visibility/subproject/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
defaultCommandTimeout: 100,
33
e2e: {
44
setupNodeEvents (on, config) {
5-
return require('dd-trace/ci/cypress/plugin')(on, config)
5+
return require('dd-trace/ci/cypress/plugin')(on, config) // eslint-disable-line n/no-extraneous-require
66
},
77
specPattern: process.env.SPEC_PATTERN || 'cypress/e2e/**/*.cy.js'
88
},
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('dd-trace/ci/cypress/plugin')
1+
module.exports = require('dd-trace/ci/cypress/plugin') // eslint-disable-line n/no-extraneous-require
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require('dd-trace/ci/cypress/support')
1+
require('dd-trace/ci/cypress/support') // eslint-disable-line n/no-extraneous-require

integration-tests/ci-visibility/subproject/subproject-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { expect } = require('chai')
21
const dependency = require('./dependency')
32

43
describe('subproject-test', () => {

packages/datadog-instrumentations/src/fetch.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['fetch', 'Request'] }] */
23

34
const shimmer = require('../../datadog-shimmer')
45
const { tracingChannel } = require('dc-polyfill')

packages/datadog-instrumentations/test/multer.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['FormData'] }] */
23

34
const dc = require('dc-polyfill')
45
const axios = require('axios')

packages/datadog-plugin-fetch/test/index.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['fetch', 'Request'] }] */
23

34
const agent = require('../../dd-trace/test/plugins/agent')
45
const tags = require('../../../ext/tags')

packages/datadog-plugin-fetch/test/integration-test/client.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
} = require('../../../../integration-tests/helpers')
88
const { assert } = require('chai')
99

10+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
1011
const describe = globalThis.fetch ? globalThis.describe : globalThis.describe.skip
1112

1213
describe('esm', () => {

packages/datadog-plugin-fetch/test/integration-test/server.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['fetch'] }] */
2+
13
import 'dd-trace/init.js'
24
import getPort from 'get-port'
35

packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
23

34
const Module = require('module')
45
const { pathToFileURL } = require('url')

packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['inspector/promises'] }] */
23

34
const { builtinModules } = require('node:module')
45

packages/dd-trace/src/profiling/exporters/event_serializer.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['os.availableParallelism'] }] */
3+
14
const os = require('os')
25
const perf = require('perf_hooks').performance
36
const version = require('../../../../../package.json').version

packages/dd-trace/src/runtime_metrics.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['v8.GCProfiler'] }] */
23

34
// TODO: capture every second and flush every 10 seconds
45

packages/dd-trace/test/appsec/iast/analyzers/path-traversal-analyzer.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['fs.cp'] }] */
23

34
const os = require('os')
45
const path = require('path')

packages/dd-trace/test/appsec/iast/resources/vm.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['vm.SourceTextModule'] }] */
23

34
const tracer = require('dd-trace')
45
tracer.init({

packages/dd-trace/test/appsec/index.next.plugin.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['fs.cpSync'] }] */
23

34
const { spawn, execSync } = require('child_process')
45
const { cpSync, mkdirSync, rmdirSync, unlinkSync } = require('fs')

register.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint n/no-unsupported-features/node-builtins: ['error', { version: '>=20.6.0', allowExperimental: true }] */
2+
13
const { register } = require('node:module')
24
const { pathToFileURL } = require('node:url')
35

scripts/get-chrome-driver-download-url.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint n/no-unsupported-features/node-builtins: ['error', { version: '>=21.0.0', allowExperimental: true }] */
2+
13
const URL = 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json'
24

35
// Get chrome driver download URL from a given chrome version, provided via CHROME_VERSION env var

scripts/verify-ci-config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22
/* eslint-disable no-console */
3+
/* eslint n/no-unsupported-features/node-builtins: ['error', { version: '>=22.0.0', allowExperimental: true }] */
34

45
const fs = require('fs')
56
const path = require('path')

0 commit comments

Comments
 (0)