-
Notifications
You must be signed in to change notification settings - Fork 404
/
Copy patheslint.config.js
115 lines (103 loc) · 2.73 KB
/
eslint.config.js
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
/*
* Copyright 2025 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
const jsdoc = require('eslint-plugin-jsdoc')
const sharedConfig = require('@newrelic/eslint-config')
// The new eslint configuration format is a simple array of configuration
// objects. See https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects.
//
// While working on the config, it can be helpful to run:
// npx @eslint/config-inspector
// This should be used to override rules we don't need applied to our
// test suites.
const testFiles = [
'test/benchmark/**',
'test/integration/**',
'test/unit/**',
'test/smoke/**',
'test/versioned/**',
'bin/test/**'
]
// See https://eslint.org/docs/latest/use/configure/ignore#ignoring-files
const globalIgnores = {
ignores: [
'**/node_modules/**',
'docs/',
'out/', // Compiled jsdocs directory.
'test/versioned-external',
'test/versioned/nextjs/app',
'test/versioned/nextjs/app-dir'
]
}
const newrelicConfigOverrides = {
files: ['**/newrelic.js', '**/newrelic.mjs'],
rules: {
'header/header': 'off'
}
}
const jsdocConfig = {
plugins: { jsdoc },
rules: {
'jsdoc/require-jsdoc': 'off',
'jsdoc/tag-lines': 'off',
'jsdoc/check-types': 'off',
'jsdoc/no-undefined-types': [
'warn',
{
definedTypes: [
'Logger',
'Agent',
'Shim',
'MessageShim',
'TraceSegment',
'Transaction',
'Tracer',
'Exception',
'MetricAggregator',
'EventEmitter'
]
}
]
}
}
const jsdocOverrides = {
files: [
'./lib/shim/*.js',
'lib/transaction/handle.js',
'api.js'
],
rules: {
'jsdoc/require-jsdoc': 'warn'
}
}
// Configuration objects are merged in order. That is, the last object in the
// list will merge with objects earlier in the list. This allows for overriding
// any settings by adding objects to the end of the list.
// See:
// + https://eslint.org/docs/latest/use/configure/configuration-files#cascading-configuration-objectsar
// + https://eslint.org/blog/2022/08/new-config-system-part-2/#goodbye-extends%2C-hello-flat-cascade
module.exports = [
...sharedConfig.configs.neostandard,
sharedConfig.plugins.sonarjs.configs.recommended,
{
...sharedConfig.configs.sonarjsTestsOverrides,
files: testFiles
},
sharedConfig.configs.sonarjsBaselineOverrides,
jsdoc.configs['flat/recommended'],
jsdocConfig,
jsdocOverrides,
{
...sharedConfig.configs.nodeRecommended,
ignores: testFiles
},
{
files: ['bin/*.js'],
rules: { 'n/hashbang': 'off' }
},
sharedConfig.configs.baselineNewRelicConfig,
newrelicConfigOverrides,
globalIgnores
]