forked from DataDog/dd-trace-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
151 lines (141 loc) · 4.44 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import path from 'node:path'
import { fileURLToPath } from 'node:url'
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 })
const SRC_FILES = [
'*.js',
'*.mjs',
'ext/**/*.js',
'ext/**/*.mjs',
'packages/*/src/**/*.js',
'packages/*/src/**/*.mjs'
]
const TEST_FILES = [
'packages/*/test/**/*.js',
'packages/*/test/**/*.mjs',
'integration-tests/**/*.js',
'integration-tests/**/*.mjs',
'**/*.spec.js'
]
export default [
{
name: 'dd-trace/global-ignore',
ignores: [
'**/coverage', // Just coverage reports.
'**/dist', // Generated
'**/docs', // Any JS here is for presentation only.
'**/out', // Generated
'**/node_modules', // We don't own these.
'**/versions', // This is effectively a node_modules tree.
'**/acmeair-nodejs', // We don't own this.
'**/vendor', // Generally, we didn't author this code.
'integration-tests/debugger/target-app/source-map-support/minify.min.js', // Generated
'integration-tests/debugger/target-app/source-map-support/typescript.js', // Generated
'integration-tests/esbuild/out.js', // Generated
'integration-tests/esbuild/aws-sdk-out.js', // Generated
'packages/dd-trace/src/payload-tagging/jsonpath-plus.js' // Vendored
]
},
{ 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: {
n,
'@stylistic/js': stylistic
},
languageOptions: {
globals: {
...globals.node
},
ecmaVersion: 2022
},
settings: {
node: {
// 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'
}
},
rules: {
'@stylistic/js/max-len': ['error', { code: 120, tabWidth: 2 }],
'@stylistic/js/object-curly-newline': ['error', { multiline: true, consistent: true }],
'@stylistic/js/object-curly-spacing': ['error', 'always'],
'import/no-extraneous-dependencies': 'error',
'n/no-restricted-require': ['error', ['diagnostics_channel']],
'no-console': 'error',
'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)
}
},
{
name: 'mocha/recommnded',
...mocha.configs.flat.recommended,
files: TEST_FILES
},
{
name: 'dd-trace/src/all',
files: SRC_FILES,
rules: {
'n/no-restricted-require': ['error', [
{
name: 'diagnostics_channel',
message: 'Please use dc-polyfill instead.'
},
{
name: 'semver',
message: 'Please use semifies instead.'
}
]]
}
},
{
name: 'dd-trace/tests/all',
files: TEST_FILES,
languageOptions: {
globals: {
sinon: 'readonly',
expect: 'readonly',
proxyquire: 'readonly',
withVersions: 'readonly',
withPeerService: 'readonly',
withNamingSchema: 'readonly',
withExports: 'readonly'
}
},
rules: {
'mocha/max-top-level-suites': 'off',
'mocha/no-exports': 'off',
'mocha/no-global-tests': 'off',
'mocha/no-identical-title': 'off',
'mocha/no-mocha-arrows': 'off',
'mocha/no-setup-in-describe': 'off',
'mocha/no-sibling-hooks': 'off',
'mocha/no-skipped-tests': 'off',
'mocha/no-top-level-hooks': 'off',
'n/handle-callback-err': 'off'
}
},
{
name: 'dd-trace/tests/integration',
files: [
'integration-tests/**/*.js',
'integration-tests/**/*.mjs',
'packages/*/test/integration-test/**/*.js',
'packages/*/test/integration-test/**/*.mjs'
],
rules: {
'import/no-extraneous-dependencies': 'off'
}
}
]