@newrelic/eslint-config 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/CONTRIBUTING.md +24 -0
- package/README.md +44 -14
- package/eslint-plugin-newrelic-header.js +71 -0
- package/index.js +170 -121
- package/package.json +11 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
### v0.6.0 (2025-08-12)
|
|
2
|
+
|
|
3
|
+
#### Miscellaneous chores
|
|
4
|
+
|
|
5
|
+
* Updated config ([#40](https://github.com/newrelic/eslint-config-newrelic/pull/40)) ([6e31965](https://github.com/newrelic/eslint-config-newrelic/commit/6e319656c6818461ca24ad57a3b564fcdbb1e28f))
|
|
6
|
+
|
|
7
|
+
### v0.5.0 (2025-01-08)
|
|
8
|
+
|
|
9
|
+
#### Features
|
|
10
|
+
|
|
11
|
+
* Migrated to eslint@9 ([#37](https://github.com/newrelic/eslint-config-newrelic/pull/37)) ([f40248f](https://github.com/newrelic/eslint-config-newrelic/commit/f40248f8101db759449c1f137b56a02870f30012))
|
|
12
|
+
|
|
13
|
+
#### Miscellaneous chores
|
|
14
|
+
|
|
15
|
+
* Removed lockfile and added .npmrc ([#34](https://github.com/newrelic/eslint-config-newrelic/pull/34)) ([c578002](https://github.com/newrelic/eslint-config-newrelic/commit/c5780025fff0c92d6d9012e6132e84fb42ad2459))
|
|
16
|
+
|
|
17
|
+
#### Continuous integration
|
|
18
|
+
|
|
19
|
+
* Removed `use_new_release` input from prepare release workflow ([#27](https://github.com/newrelic/eslint-config-newrelic/pull/27)) ([115ac47](https://github.com/newrelic/eslint-config-newrelic/commit/115ac47ec5cd69655c9a7b3dcf63f91f79952ba4))
|
|
20
|
+
* Updated CI process for releases ([#26](https://github.com/newrelic/eslint-config-newrelic/pull/26)) ([861d983](https://github.com/newrelic/eslint-config-newrelic/commit/861d983c74639af88a4f738abe24d73d959f1ca8))
|
|
21
|
+
|
|
1
22
|
### v0.4.0 (2024-01-02)
|
|
2
23
|
|
|
3
24
|
* Set new baseline ECMAScript version
|
package/CONTRIBUTING.md
CHANGED
|
@@ -18,6 +18,30 @@ Before submitting an Issue, please search for similar ones in the
|
|
|
18
18
|
2. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
|
|
19
19
|
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.
|
|
20
20
|
|
|
21
|
+
### Commit Guidelines
|
|
22
|
+
|
|
23
|
+
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) to format commit messages for this repository. Conventional Commits provide a standardized format for commit messages that allows for automatic generation of changelogs and easy tracking of changes.
|
|
24
|
+
|
|
25
|
+
When contributing to this repository, please ensure that your commit messages adhere to the Conventional Commit guidelines. Specifically, your commit messages should:
|
|
26
|
+
|
|
27
|
+
* Start with a type, indicating the kind of change being made (e.g. `feat` for a new feature, `fix` for a bugfix, etc.). The types we support are:
|
|
28
|
+
* `build`: changes that affect the build system or external dependencies
|
|
29
|
+
* `chore`: changes that do not modify source or test files
|
|
30
|
+
* `ci`: changes to our CI configuration files and scripts
|
|
31
|
+
* `docs`: documentation additions or updates
|
|
32
|
+
* `feat`: new features or capabilities added to the agent
|
|
33
|
+
* `fix`: bugfixes or corrections to existing functionality
|
|
34
|
+
* `perf`: performance improvements
|
|
35
|
+
* `refactor`: changes that do not add new feature or fix bugs, but improve code structure or readability
|
|
36
|
+
* `revert`: revert a previous commit
|
|
37
|
+
* `security`: changes related to the security of the agent, including the updating of dependencies due to CVE
|
|
38
|
+
* `style` - changes that do not affect the meaning of the code (e.g. formatting, white-space, etc.)
|
|
39
|
+
* `test` - adding new tests or modifying existing tests
|
|
40
|
+
* Use the imperative, present tense (e.g. "add feature" instead of "added feature")
|
|
41
|
+
* Optionally, include a scope in parantheses after the type to indicate which part of the repository is affected (e.g. `feat(instrumentation): add support for Prisma Client`)
|
|
42
|
+
|
|
43
|
+
Please note that we use the [Squash and Merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits) method when merging Pull Requests into the main branch. We do not use the original commit messages from each individual commit. Instead, we use the Pull Request title as the commit message for the squashed commit, and as such, require that the Pull Request title adheres to our Conventional Commit standards. Any additional documentation or information relevant to the release notes should be added to the "optional extended description" section of the squash commit on merge.
|
|
44
|
+
|
|
21
45
|
## Contributor License Agreement
|
|
22
46
|
|
|
23
47
|
Keep in mind that when you submit your Pull Request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at opensource@newrelic.com.
|
package/README.md
CHANGED
|
@@ -2,43 +2,73 @@
|
|
|
2
2
|
|
|
3
3
|
# New Relic Eslint Config
|
|
4
4
|
|
|
5
|
-
Base eslint configuration for New Relic Node.js agent team
|
|
5
|
+
Base eslint configuration for New Relic Node.js agent team.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
npm install --save-dev @newrelic/eslint-config
|
|
10
|
+
npm install --save-dev @newrelic/eslint-config eslint
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Getting Started
|
|
14
14
|
|
|
15
|
-
Add the following to your
|
|
15
|
+
Add the following to your `eslint.config.js`:
|
|
16
16
|
|
|
17
|
+
```js
|
|
18
|
+
'use strict'
|
|
19
|
+
|
|
20
|
+
const sharedConfig = require('@newrelic/eslint-config')
|
|
21
|
+
|
|
22
|
+
module.exports = [
|
|
23
|
+
...sharedConfig.recommended
|
|
24
|
+
]
|
|
17
25
|
```
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
|
|
27
|
+
That should be all you need to do for a simple project. However, some projects
|
|
28
|
+
have requirements that go beyond the baseline. In order to support such
|
|
29
|
+
projects, all of the internal configuration and plugins are exported:
|
|
30
|
+
|
|
31
|
+
+ `configs`: An object where the keys are descriptive names of eslint
|
|
32
|
+
configuration objects, and the values are those configuration objects.
|
|
33
|
+
+ `plugins`: An object where the keys are plugin names, and the values are
|
|
34
|
+
those plugins.
|
|
35
|
+
+ `recommended`: An array of the baseline configurations.
|
|
22
36
|
|
|
23
37
|
## Support
|
|
24
38
|
|
|
25
|
-
New Relic hosts and moderates an online forum where customers can interact with
|
|
39
|
+
New Relic hosts and moderates an online forum where customers can interact with
|
|
40
|
+
New Relic employees as well as other customers to get help and share best
|
|
41
|
+
practices. Like all official New Relic open source projects, there's a related
|
|
42
|
+
Community topic in the New Relic Explorers Hub. You can find this project's
|
|
43
|
+
topic/threads [here](https://forum.newrelic.com).
|
|
26
44
|
|
|
27
45
|
## Contribute
|
|
28
46
|
|
|
29
|
-
We encourage your contributions to improve [project name]! Keep in mind that
|
|
47
|
+
We encourage your contributions to improve [project name]! Keep in mind that
|
|
48
|
+
when you submit your pull request, you'll need to sign the CLA via the
|
|
49
|
+
click-through using CLA-Assistant. You only have to sign the CLA one time
|
|
50
|
+
per project.
|
|
30
51
|
|
|
31
|
-
If you have any questions, or to execute our corporate CLA (which is required if
|
|
52
|
+
If you have any questions, or to execute our corporate CLA (which is required if
|
|
53
|
+
your contribution is on behalf of a company), drop us an email at
|
|
54
|
+
opensource@newrelic.com.
|
|
32
55
|
|
|
33
56
|
**A note about vulnerabilities**
|
|
34
57
|
|
|
35
|
-
As noted in our [security policy](../../security/policy), New Relic is committed
|
|
58
|
+
As noted in our [security policy](../../security/policy), New Relic is committed
|
|
59
|
+
to the privacy and security of our customers and their data. We believe that
|
|
60
|
+
providing coordinated disclosure by security researchers and engaging with the
|
|
61
|
+
security community are important means to achieve our security goals.
|
|
36
62
|
|
|
37
|
-
If you believe you have found a security vulnerability in this project or any of
|
|
63
|
+
If you believe you have found a security vulnerability in this project or any of
|
|
64
|
+
New Relic's products or websites, we welcome and greatly appreciate you
|
|
65
|
+
reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
|
|
38
66
|
|
|
39
|
-
If you would like to contribute to this project, review
|
|
67
|
+
If you would like to contribute to this project, review
|
|
68
|
+
[these guidelines](./CONTRIBUTING.md).
|
|
40
69
|
|
|
41
70
|
|
|
42
71
|
## License
|
|
43
|
-
New Relic Eslint Config is licensed under the
|
|
72
|
+
New Relic Eslint Config is licensed under the
|
|
73
|
+
[Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
|
|
44
74
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
|
|
8
|
+
const headerTmpl = `
|
|
9
|
+
/*
|
|
10
|
+
* Copyright {{year}} New Relic Corporation. All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
`.trim()
|
|
14
|
+
|
|
15
|
+
const rule = {
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'layout',
|
|
18
|
+
fixable: 'whitespace',
|
|
19
|
+
schema: false
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
create (context) {
|
|
23
|
+
return {
|
|
24
|
+
Program (node) {
|
|
25
|
+
const src = context.sourceCode.getText()
|
|
26
|
+
if (hasHeader(src) === true) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
context.report({
|
|
30
|
+
loc: node.loc,
|
|
31
|
+
message: 'missing or invalid header',
|
|
32
|
+
fix (fixer) {
|
|
33
|
+
const rendered = headerTmpl.replace('{{year}}', new Date().getFullYear() + '') + '\n\n'
|
|
34
|
+
if (hasShebang(src) === true) {
|
|
35
|
+
return fixer.insertTextAfterRange([0, src.indexOf('\n')], '\n' + rendered)
|
|
36
|
+
}
|
|
37
|
+
return fixer.insertTextBefore(
|
|
38
|
+
node,
|
|
39
|
+
rendered
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
meta: {
|
|
50
|
+
name: 'eslint-plugin-newrelic-header',
|
|
51
|
+
version: '1.0.0'
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
header: rule
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function hasShebang (src) {
|
|
59
|
+
return /^#!\s?\//.test(src)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function hasHeader (src) {
|
|
63
|
+
const headerLines = src.split('\n').slice(0, 5)
|
|
64
|
+
if (hasShebang(src) === true) {
|
|
65
|
+
headerLines.shift()
|
|
66
|
+
}
|
|
67
|
+
return headerLines[0] === '/*' &&
|
|
68
|
+
/ \* Copyright \d{4} New Relic Corporation\. All rights reserved\./.test(headerLines[1]) === true &&
|
|
69
|
+
/ \* SPDX-License-Identifier: Apache-2\.0/.test(headerLines[2]) === true &&
|
|
70
|
+
headerLines[3] === ' */'
|
|
71
|
+
}
|
package/index.js
CHANGED
|
@@ -1,133 +1,182 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
'use strict'
|
|
7
|
-
const currentYear = new Date().getFullYear()
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
const neostandard = require('neostandard')
|
|
4
|
+
const json = require('@eslint/json').default
|
|
5
|
+
const sonarjs = require('eslint-plugin-sonarjs')
|
|
6
|
+
const header = require('./eslint-plugin-newrelic-header.js')
|
|
7
|
+
|
|
8
|
+
// The new eslint configuration format is a simple array of configuration
|
|
9
|
+
// objects. See https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects.
|
|
10
|
+
//
|
|
11
|
+
// While working on the config, it can be helpful to run:
|
|
12
|
+
// npx @eslint/config-inspector
|
|
13
|
+
|
|
14
|
+
const plugins = {
|
|
15
|
+
...neostandard.plugins,
|
|
16
|
+
json,
|
|
17
|
+
sonarjs,
|
|
18
|
+
header
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const nodeRecommended = neostandard.plugins.n.configs['flat/recommended']
|
|
22
|
+
delete nodeRecommended.languageOptions.sourceType
|
|
23
|
+
nodeRecommended.rules['n/no-unsupported-features/node-builtins'] = ['error', { version: '>=18.8.0' }]
|
|
24
|
+
nodeRecommended.rules['n/no-process-exit'] = 'off'
|
|
25
|
+
nodeRecommended.rules['n/no-deprecated-api'] = [
|
|
26
|
+
'error',
|
|
27
|
+
{
|
|
28
|
+
ignoreModuleItems: [
|
|
29
|
+
'url.parse'
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const baselineNewRelicConfig = {
|
|
35
|
+
plugins: {
|
|
36
|
+
header,
|
|
22
37
|
},
|
|
23
|
-
|
|
24
|
-
'header',
|
|
25
|
-
'prettier',
|
|
26
|
-
'sonarjs'
|
|
27
|
-
],
|
|
28
|
-
ignorePatterns: ['invalid-json/'],
|
|
38
|
+
|
|
29
39
|
rules: {
|
|
30
|
-
'
|
|
31
|
-
'comma-style': ['error', 'last'],
|
|
32
|
-
'consistent-return': 'error',
|
|
33
|
-
curly: 'error',
|
|
34
|
-
'eol-last': 'error',
|
|
35
|
-
eqeqeq: ['error', 'smart'],
|
|
36
|
-
camelcase: ['error', {properties: 'never'}],
|
|
37
|
-
'dot-notation': 'error',
|
|
38
|
-
'func-names': 'error',
|
|
39
|
-
'guard-for-in': 'error',
|
|
40
|
-
'header/header': ['error', 'block', [
|
|
41
|
-
'',
|
|
42
|
-
{
|
|
43
|
-
pattern: ' * Copyright \\d{4} New Relic Corporation. All rights reserved.',
|
|
44
|
-
template: ` * Copyright ${currentYear} New Relic Corporation. All rights reserved.`
|
|
45
|
-
},
|
|
46
|
-
' * SPDX-License-Identifier: Apache-2.0',
|
|
47
|
-
' '
|
|
48
|
-
], 2],
|
|
49
|
-
'keyword-spacing': 'error',
|
|
50
|
-
'max-nested-callbacks': ['error', 3],
|
|
51
|
-
'max-params': ['error', 5],
|
|
52
|
-
'new-cap': 'error',
|
|
53
|
-
'no-const-assign': 'error',
|
|
40
|
+
'consistent-return': 'off',
|
|
54
41
|
'no-console': 'warn',
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
'
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'no-
|
|
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
|
-
|
|
42
|
+
|
|
43
|
+
// Enable file header checking and autocorrection.
|
|
44
|
+
'header/header': 'error',
|
|
45
|
+
|
|
46
|
+
// This one enforces `!!thing` syntax, which some folks find difficult
|
|
47
|
+
// to read:
|
|
48
|
+
'no-unneeded-ternary': 'off',
|
|
49
|
+
|
|
50
|
+
// There are times we'd rather have import statements close to the
|
|
51
|
+
// thing that needed them:
|
|
52
|
+
'import-x/first': 'off',
|
|
53
|
+
|
|
54
|
+
// Prefer single quotes, but utilize others to avoid escaping:
|
|
55
|
+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
|
|
56
|
+
|
|
57
|
+
// Neostandard sets this to "warn", but we'd like "error":
|
|
58
|
+
'object-shorthand': 'error',
|
|
59
|
+
|
|
60
|
+
// @eslint/config-inspector has highlighted this rule as being deprecated.
|
|
61
|
+
// We don't JSX anyway, so goodbye:
|
|
62
|
+
'@stylistic/jsx-indent': 'off',
|
|
63
|
+
|
|
64
|
+
// These neostandard would generate unnecessary noise:
|
|
65
|
+
'@stylistic/space-before-function-paren': 'off',
|
|
66
|
+
|
|
67
|
+
// Enforce consistency for arrow functions:
|
|
68
|
+
'arrow-body-style': ['error', 'as-needed', { requireReturnForObjectLiteral: true }],
|
|
69
|
+
'@stylistic/arrow-parens': ['error', 'always'],
|
|
70
|
+
'@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
|
|
71
|
+
'@stylistic/no-confusing-arrow': 'error',
|
|
72
|
+
|
|
73
|
+
// Enforce consistency for ternary statements:
|
|
74
|
+
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
|
|
75
|
+
'no-nested-ternary': 'error',
|
|
76
|
+
|
|
77
|
+
// Function styling:
|
|
78
|
+
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
|
|
79
|
+
'@stylistic/function-paren-newline': ['error', 'consistent'],
|
|
80
|
+
|
|
81
|
+
// Object declaration styling:
|
|
82
|
+
// TODO: add destructuring when the rule is available https://github.com/eslint-stylistic/eslint-stylistic/pull/840
|
|
83
|
+
'@stylistic/object-curly-newline': ['error', {
|
|
84
|
+
// e.g. const foo = { a }
|
|
85
|
+
ObjectExpression: { consistent: true },
|
|
86
|
+
// e.g. const { a } = foo
|
|
87
|
+
ObjectPattern: { consistent: true },
|
|
88
|
+
// e.g. import { a } from foo
|
|
89
|
+
ImportDeclaration: { multiline: true },
|
|
90
|
+
// e.g. export { a }
|
|
91
|
+
ExportDeclaration: { consistent: true }
|
|
92
|
+
}]
|
|
102
93
|
},
|
|
103
|
-
|
|
94
|
+
|
|
95
|
+
linterOptions: {
|
|
96
|
+
reportUnusedDisableDirectives: 'error'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const configs = {
|
|
101
|
+
baselineNewRelicConfig,
|
|
102
|
+
nodeRecommended,
|
|
103
|
+
|
|
104
|
+
neostandard: neostandard(),
|
|
105
|
+
|
|
106
|
+
json: [
|
|
104
107
|
{
|
|
105
|
-
files: [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
109
|
-
rules:
|
|
110
|
-
'node/no-extraneous-require': 'off',
|
|
111
|
-
'node/no-missing-require': 'off',
|
|
112
|
-
'node/no-unpublished-require': 'off',
|
|
113
|
-
'node/no-unpublished-import': 'off',
|
|
114
|
-
'node/no-extraneous-import': 'off',
|
|
115
|
-
'node/no-missing-import': 'off',
|
|
116
|
-
}
|
|
108
|
+
files: ['**/*.json'],
|
|
109
|
+
plugins: { json },
|
|
110
|
+
language: 'json/json',
|
|
111
|
+
ignores: ['package-lock.json'],
|
|
112
|
+
rules: json.configs.recommended.rules
|
|
117
113
|
},
|
|
118
114
|
{
|
|
119
|
-
files: [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
files: ['**/*.jsonc'],
|
|
116
|
+
plugins: { json },
|
|
117
|
+
language: 'json/jsonc',
|
|
118
|
+
rules: json.configs.recommended.rules
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
|
|
122
|
+
sonarjsBaselineOverrides: {
|
|
123
|
+
rules: {
|
|
124
|
+
// This rule picks up inlined lambda functions as a violation:
|
|
125
|
+
'sonarjs/no-nested-functions': 'off',
|
|
126
|
+
|
|
127
|
+
// Don't bug us. We'll get to it (maybe):
|
|
128
|
+
'sonarjs/todo-tag': 'warn',
|
|
129
|
+
'sonarjs/fixme-tag': 'warn',
|
|
130
|
+
|
|
131
|
+
// Sonar be on that stuff. `static readonly FOO` is not valid JavaScript:
|
|
132
|
+
'sonarjs/public-static-readonly': 'off',
|
|
133
|
+
|
|
134
|
+
// Agree to disagree on their explanation for this one:
|
|
135
|
+
'sonarjs/no-parameter-reassignment': 'off'
|
|
131
136
|
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
sonarjsTestsOverrides: {
|
|
140
|
+
rules: {
|
|
141
|
+
// We sometimes need to shadow things like Promise for testing:
|
|
142
|
+
'sonarjs/no-globals-shadowing': 'off',
|
|
143
|
+
// Sonar doesn't like our test files that build tests:
|
|
144
|
+
'sonarjs/no-empty-test-file': 'off',
|
|
145
|
+
// Some of our tests hit local HTTP endpoints:
|
|
146
|
+
'sonarjs/no-clear-text-protocols': 'off',
|
|
147
|
+
// We don't always need secure random in tests:
|
|
148
|
+
'sonarjs/pseudo-random': 'off',
|
|
149
|
+
// We need to use `os.exec` and such at times:
|
|
150
|
+
'sonarjs/os-command': 'off',
|
|
151
|
+
'sonarjs/no-os-command-from-path': 'off',
|
|
152
|
+
// We have to use bunk passwords in tests:
|
|
153
|
+
'sonarjs/no-hardcoded-passwords': 'off',
|
|
154
|
+
// We will have slow regular expressions in tests and it is okay:
|
|
155
|
+
'sonarjs/slow-regex': 'off',
|
|
156
|
+
// The x-powered-by header has no bearing on the quality of our tests:
|
|
157
|
+
'sonarjs/x-powered-by': 'off',
|
|
158
|
+
// We sometimes need to build new functions via `new Function`:
|
|
159
|
+
'sonarjs/code-eval': 'off',
|
|
160
|
+
'no-new-func': 'off',
|
|
161
|
+
// Sometimes we add dummy values that sonar doesn't like:
|
|
162
|
+
'sonarjs/no-hardcoded-ip': 'off',
|
|
163
|
+
// We need some side effect constructors in tests:
|
|
164
|
+
'sonarjs/constructor-for-side-effects': 'off',
|
|
165
|
+
// Tests don't need "safe" permissions:
|
|
166
|
+
'sonarjs/file-permissions': 'off',
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = {
|
|
172
|
+
configs,
|
|
173
|
+
plugins,
|
|
174
|
+
recommended: [
|
|
175
|
+
...neostandard(),
|
|
176
|
+
sonarjs.configs.recommended,
|
|
177
|
+
configs.sonarjsBaselineOverrides,
|
|
178
|
+
nodeRecommended,
|
|
179
|
+
...configs.json,
|
|
180
|
+
baselineNewRelicConfig
|
|
132
181
|
]
|
|
133
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Eslint ruleset for New Relic Node.js agent",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,25 +12,21 @@
|
|
|
12
12
|
],
|
|
13
13
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"eslint": "^8.24.0",
|
|
18
|
-
"eslint-config-prettier": "^9.1.0",
|
|
19
|
-
"eslint-plugin-header": "^3.1.1",
|
|
20
|
-
"eslint-plugin-node": "^11.1.0",
|
|
21
|
-
"eslint-plugin-prettier": "^5.1.2",
|
|
22
|
-
"eslint-plugin-sonarjs": "^0.23.0",
|
|
23
|
-
"prettier": "^3.1.1"
|
|
24
|
-
},
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=12"
|
|
27
|
-
},
|
|
28
15
|
"repository": {
|
|
29
16
|
"type": "git",
|
|
30
17
|
"url": "https://github.com/newrelic/eslint-config-newrelic"
|
|
31
18
|
},
|
|
32
19
|
"files": [
|
|
33
20
|
"index.js",
|
|
21
|
+
"eslint-plugin-newrelic-header.js",
|
|
34
22
|
"*.md"
|
|
35
|
-
]
|
|
23
|
+
],
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"eslint": "^9.17.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@eslint/json": "^0.13.1",
|
|
29
|
+
"eslint-plugin-sonarjs": "^3.0.4",
|
|
30
|
+
"neostandard": "^0.12.2"
|
|
31
|
+
}
|
|
36
32
|
}
|