From f53d4fc8d911a998759cae90a9cd0bf09ff17828 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 9 Jan 2025 11:33:43 -0500 Subject: [PATCH] chore: Utilize updated @newrelic/eslint-config (#2865) --- THIRD_PARTY_NOTICES.md | 403 ++++++++++++++++--------------- eslint-plugin-newrelic-header.js | 71 ------ eslint.config.js | 136 ++--------- package.json | 3 +- third_party_manifest.json | 27 ++- 5 files changed, 241 insertions(+), 399 deletions(-) delete mode 100644 eslint-plugin-newrelic-header.js diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index bb91eb5417..b5e048dfcd 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -35,6 +35,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic * [@aws-sdk/s3-request-presigner](#aws-sdks3-request-presigner) * [@koa/router](#koarouter) * [@matteo.collina/tspl](#matteocollinatspl) +* [@newrelic/eslint-config](#newreliceslint-config) * [@newrelic/newrelic-oss-cli](#newrelicnewrelic-oss-cli) * [@newrelic/test-utilities](#newrelictest-utilities) * [@octokit/rest](#octokitrest) @@ -52,7 +53,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic * [conventional-changelog-writer](#conventional-changelog-writer) * [conventional-commits-parser](#conventional-commits-parser) * [eslint-plugin-jsdoc](#eslint-plugin-jsdoc) -* [eslint-plugin-sonarjs](#eslint-plugin-sonarjs) * [eslint](#eslint) * [express](#express) * [git-raw-commits](#git-raw-commits) @@ -1546,6 +1546,215 @@ SOFTWARE. ``` +### @newrelic/eslint-config + +This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.5.0](https://github.com/newrelic/eslint-config-newrelic/tree/v0.5.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.5.0/LICENSE): + +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +``` + ### @newrelic/newrelic-oss-cli This product includes source derived from [@newrelic/newrelic-oss-cli](https://github.com/newrelic/newrelic-oss-cli) ([v0.1.2](https://github.com/newrelic/newrelic-oss-cli/tree/v0.1.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/newrelic-oss-cli/blob/v0.1.2/LICENSE): @@ -2930,198 +3139,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -### eslint-plugin-sonarjs - -This product includes source derived from [eslint-plugin-sonarjs](https://github.com/SonarSource/SonarJS) ([v3.0.1](https://github.com/SonarSource/SonarJS/tree/v3.0.1)), distributed under the [LGPL-3.0-only License](https://github.com/SonarSource/SonarJS/blob/v3.0.1/LICENSE): - -``` -SONAR Source-Available License v1.0 -Last Updated November 13, 2024 - -1. DEFINITIONS - -"Agreement" means this Sonar Source-Available License v1.0 - -"Competing" means marketing a product or service as a substitute for the -functionality or value of SonarQube. A product or service may compete regardless -of how it is designed or deployed. For example, a product or service may compete -even if it provides its functionality via any kind of interface (including -services, libraries, or plug-ins), even if it is ported to a different platform -or programming language, and even if it is provided free of charge. - -"Contribution" means: - - a) in the case of the initial Contributor, the initial content Distributed under -this Agreement, and - - b) in the case of each subsequent Contributor: - i) changes to the Program, and - ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are -Distributed by that particular Contributor. A Contribution "originates" from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include changes or -additions to the Program that are not Modified Works. - -"Contributor" means any person or entity that Distributes the Program. - -"Derivative Works" shall mean any work, whether in Source Code or other form, -that is based on (or derived from) the Program and for which the editorial -revisions, annotations, elaborations, or other modifications represent, as a -whole, an original work of authorship. - -"Distribute" means the acts of a) distributing or b) making available in any -manner that enables the transfer of a copy. - -"Licensed Patents" mean patent claims licensable by a Contributor that are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Modified Works" shall mean any work in Source Code or other form that results -from an addition to, deletion from, or modification of the contents of the -Program, including, for purposes of clarity, any new file in Source Code form -that contains any contents of the Program. Modified Works shall not include -works that contain only declarations, interfaces, types, classes, structures, or -files of the Program solely in each case in order to link to, bind by name, or -subclass the Program or Modified Works thereof. - -"Non-competitive Purpose" means any purpose except for (a) providing to others -any product or service that includes or offers the same or substantially similar -functionality as SonarQube, (b) Competing with SonarQube, and/or (c) employing, -using, or engaging artificial intelligence technology that is not part of the -Program to ingest, interpret, analyze, train on, or interact with the data -provided by the Program, or to engage with the Program in any manner. - -"Notices" means any legal statements or attributions included with the Program, -including, without limitation, statements concerning copyright, patent, -trademark, disclaimers of warranty, or limitations of liability - -"Program" means the Contributions Distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including Contributors. - -"SonarQube" means an open-source or commercial edition of software offered by -SonarSource that is branded "SonarQube". - -"SonarSource" means SonarSource SA, a Swiss company registered in Switzerland -under UID No. CHE-114.587.664. - -"Source Code" means the form of a Program preferred for making modifications, -including but not limited to software source code, documentation source, and -configuration files. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license, for any -Non-competitive Purpose, to reproduce, prepare Derivative Works of, publicly -display, publicly perform, Distribute and sublicense the Contribution of such -Contributor, if any, and such Derivative Works. - - b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents, for any Non-competitive Purpose, to make, use, sell, offer to sell, -import, and otherwise transfer the Contribution of such Contributor, if any, in -Source Code or other form. This patent license shall apply to the combination of -the Contribution and the Program if, at the time the Contribution is added by -the Contributor, such addition of the Contribution causes such combination to be -covered by the Licensed Patents. The patent license shall not apply to any other -combinations that include the Contribution. - - c) Recipient understands that although each Contributor grants the licenses to -its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third-party patent license is required to allow Recipient to -Distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - - d) Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. - -3. REQUIREMENTS - -3.1 If a Contributor Distributes the Program in any form, then the Program must -also be made available as Source Code, in accordance with section 3.2, and the -Contributor must accompany the Program with a statement that the Source Code for -the Program is available under this Agreement, and inform Recipients how to -obtain it in a reasonable manner on or through a medium customarily used for -software exchange; and - -3.2 When the Program is Distributed as Source Code: - - a) it must be made available under this Agreement, and - - b) a copy of this Agreement must be included with each copy of the Program. - -3.3 Contributors may not remove or alter any Notices contained within the -Program from any copy of the Program which they Distribute, provided that -Contributors may add their own appropriate Notices. - -4. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY -APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES -OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT -LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement, including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations. - -5. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY -APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES. - -6. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program itself -(excluding combinations of the Program with other software or hardware) -infringes such Recipient’s patent(s), then such Recipient’s rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient’s rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient’s rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient’s obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives -no rights or licenses to the intellectual property of any Contributor under this -Agreement, whether expressly, by implication, estoppel, or otherwise. All rights -in the Program not expressly granted under this Agreement are reserved. Nothing -in this Agreement is intended to be enforceable by any entity that is not a -Contributor or Recipient. No third-party beneficiary rights are created under -this Agreement. - -``` - ### eslint This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.17.0](https://github.com/eslint/eslint/tree/v9.17.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.17.0/LICENSE): diff --git a/eslint-plugin-newrelic-header.js b/eslint-plugin-newrelic-header.js deleted file mode 100644 index 23954eda11..0000000000 --- a/eslint-plugin-newrelic-header.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2024 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict' - -const headerTmpl = ` -/* - * Copyright {{year}} New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ -`.trim() - -const rule = { - meta: { - type: 'layout', - fixable: 'whitespace', - schema: false - }, - - create(context) { - return { - Program(node) { - const src = context.sourceCode.getText() - if (hasHeader(src) === true) { - return - } - context.report({ - loc: node.loc, - message: 'missing or invalid header', - fix(fixer) { - const rendered = headerTmpl.replace('{{year}}', new Date().getFullYear() + '') + '\n\n' - if (hasShebang(src) === true) { - return fixer.insertTextAfterRange([0, src.indexOf('\n')], '\n' + rendered) - } - return fixer.insertTextBefore( - node, - rendered - ) - } - }) - } - } - } -} - -module.exports = { - meta: { - name: 'eslint-plugin-newrelic-header', - version: '1.0.0' - }, - rules: { - header: rule - } -} - -function hasShebang(src) { - return /^#!\s?\//.test(src) -} - -function hasHeader(src) { - const headerLines = src.split('\n').slice(0, 5) - if (hasShebang(src) === true) { - headerLines.shift() - } - return headerLines[0] === '/*' && - / \* Copyright \d{4} New Relic Corporation\. All rights reserved\./.test(headerLines[1]) === true && - / \* SPDX-License-Identifier: Apache-2\.0/.test(headerLines[2]) === true && - headerLines[3] === ' */' -} diff --git a/eslint.config.js b/eslint.config.js index ce7a604e0f..6c146435ff 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,14 +1,12 @@ /* - * Copyright 2024 New Relic Corporation. All rights reserved. + * Copyright 2025 New Relic Corporation. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ 'use strict' -const neostandard = require('neostandard') const jsdoc = require('eslint-plugin-jsdoc') -const sonarjs = require('eslint-plugin-sonarjs') -const header = require('./eslint-plugin-newrelic-header.js') +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. @@ -39,41 +37,6 @@ const globalIgnores = { ] } -const localConfig = { - plugins: { - header - }, - - rules: { - 'consistent-return': 'off', - 'no-console': 'warn', - - // Enable file header checking and autocorrection. - 'header/header': 'error', - - // This one enforces `!!thing` syntax, which some folks find difficult - // to read: - 'no-unneeded-ternary': 'off', - - // There are times we'd rather have import statements close to the - // thing that needed them: - 'import-x/first': 'off', - - // Prefer single quotes, but utilize others to avoid escaping: - '@stylistic/quotes': ['error', 'single', { avoidEscape: true }], - - // Neostandard sets this to "warn", but we'd like "error": - 'object-shorthand': 'error', - - // These neostandard would generate unnecessary noise: - '@stylistic/space-before-function-paren': 'off' - }, - - linterOptions: { - reportUnusedDisableDirectives: 'error' - } -} - const newrelicConfigOverrides = { files: ['**/newrelic.js', '**/newrelic.mjs'], rules: { @@ -81,56 +44,6 @@ const newrelicConfigOverrides = { } } -const sonarjsTestsConfig = { - files: testFiles, - - rules: { - // We sometimes need to shadow things like Promise for testing: - 'sonarjs/no-globals-shadowing': 'off', - // Sonar doesn't like our test files that build tests: - 'sonarjs/no-empty-test-file': 'off', - // Some of our tests hit local HTTP endpoints: - 'sonarjs/no-clear-text-protocols': 'off', - // We don't always need secure random in tests: - 'sonarjs/pseudo-random': 'off', - // We need to use `os.exec` and such at times: - 'sonarjs/os-command': 'off', - 'sonarjs/no-os-command-from-path': 'off', - // We have to use bunk passwords in tests: - 'sonarjs/no-hardcoded-passwords': 'off', // eslint-disable-line - // We will have slow regular expressions in tests and it is okay: - 'sonarjs/slow-regex': 'off', - // The x-powered-by header has no bearing on the quality of our tests: - 'sonarjs/x-powered-by': 'off', - // We sometimes need to build new functions via `new Function`: - 'sonarjs/code-eval': 'off', - 'no-new-func': 'off', - // Sometimes we add dummy values that sonar doesn't like: - 'sonarjs/no-hardcoded-ip': 'off', - // We need some side effect constructors in tests: - 'sonarjs/constructor-for-side-effects': 'off', - // Tests don't need "safe" permissions: - 'sonarjs/file-permissions': 'off', - } -} - -const sonarjsOverrides = { - rules: { - // This rule picks up inlined lambda functions as a violation: - 'sonarjs/no-nested-functions': 'off', - - // Don't bug us. We'll get to it (maybe): - 'sonarjs/todo-tag': 'warn', - 'sonarjs/fixme-tag': 'warn', - - // Sonar be on that stuff. `static readonly FOO` is not valid JavaScript: - 'sonarjs/public-static-readonly': 'off', - - // Agree to disagree on their explanation for this one: - 'sonarjs/no-parameter-reassignment': 'off' - } -} - const jsdocConfig = { plugins: { jsdoc }, rules: { @@ -167,20 +80,6 @@ const jsdocOverrides = { } } -const nodeRecommended = neostandard.plugins.n.configs['flat/recommended'] -delete nodeRecommended.languageOptions.sourceType -nodeRecommended.rules['n/no-unsupported-features/node-builtins'] = ['error', { version: '>=18.8.0' }] -nodeRecommended.rules['n/no-process-exit'] = 'off' -nodeRecommended.rules['n/no-deprecated-api'] = [ - 'error', - { - ignoreModuleItems: [ - 'url.parse' - ] - } -] -nodeRecommended.ignores = testFiles - // 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. @@ -188,32 +87,29 @@ nodeRecommended.ignores = testFiles // + 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 = [ - // Apply baseline configuration. - ...neostandard(), + ...sharedConfig.configs.neostandard, - // Add sonarjs config: - sonarjs.configs.recommended, - sonarjsTestsConfig, - sonarjsOverrides, + sharedConfig.plugins.sonarjs.configs.recommended, + { + ...sharedConfig.configs.sonarjsTestsOverrides, + files: testFiles + }, + sharedConfig.configs.sonarjsBaselineOverrides, - // Add jsdoc config: jsdoc.configs['flat/recommended'], jsdocConfig, jsdocOverrides, - // Add customized eslint-plugin-n recommended rules: - nodeRecommended, { - files: [ - 'bin/*.js' - ], - rules: { - 'n/hashbang': 'off' - } + ...sharedConfig.configs.nodeRecommended, + ignores: testFiles + }, + { + files: ['bin/*.js'], + rules: { 'n/hashbang': 'off' } }, - // Apply local configuration and overrides: - localConfig, + sharedConfig.configs.baselineNewRelicConfig, newrelicConfigOverrides, globalIgnores ] diff --git a/package.json b/package.json index 2958f6c938..3ca9f65ce1 100644 --- a/package.json +++ b/package.json @@ -220,6 +220,7 @@ "@aws-sdk/s3-request-presigner": "^3.556.0", "@koa/router": "^12.0.1", "@matteo.collina/tspl": "^0.1.1", + "@newrelic/eslint-config": "^0.5.0", "@newrelic/newrelic-oss-cli": "^0.1.2", "@newrelic/test-utilities": "^9.1.0", "@octokit/rest": "^18.0.15", @@ -238,7 +239,6 @@ "conventional-commits-parser": "^3.2.4", "eslint": "^9.17.0", "eslint-plugin-jsdoc": "^50.6.1", - "eslint-plugin-sonarjs": "^3.0.1", "express": "*", "git-raw-commits": "^2.0.11", "glob": "^7.1.2", @@ -250,7 +250,6 @@ "koa-router": "^12.0.1", "lint-staged": "^11.0.0", "lockfile-lint": "^4.9.6", - "neostandard": "^0.12.0", "nock": "11.8.0", "proxyquire": "^1.8.0", "rimraf": "^2.6.3", diff --git a/third_party_manifest.json b/third_party_manifest.json index b7cd9a5b59..6b8df931fa 100644 --- a/third_party_manifest.json +++ b/third_party_manifest.json @@ -1,5 +1,5 @@ { - "lastUpdated": "Mon Dec 23 2024 09:14:45 GMT-0500 (Eastern Standard Time)", + "lastUpdated": "Wed Jan 08 2025 12:42:52 GMT-0500 (Eastern Standard Time)", "projectName": "New Relic Node Agent", "projectUrl": "https://github.com/newrelic/node-newrelic", "includeOptDeps": true, @@ -278,6 +278,19 @@ "publisher": "Matteo Collina", "email": "hello@matteocollina.com" }, + "@newrelic/eslint-config@0.5.0": { + "name": "@newrelic/eslint-config", + "version": "0.5.0", + "range": "^0.5.0", + "licenses": "Apache-2.0", + "repoUrl": "https://github.com/newrelic/eslint-config-newrelic", + "versionedRepoUrl": "https://github.com/newrelic/eslint-config-newrelic/tree/v0.5.0", + "licenseFile": "node_modules/@newrelic/eslint-config/LICENSE", + "licenseUrl": "https://github.com/newrelic/eslint-config-newrelic/blob/v0.5.0/LICENSE", + "licenseTextSource": "file", + "publisher": "New Relic Node.js agent team", + "email": "nodejs@newrelic.com" + }, "@newrelic/newrelic-oss-cli@0.1.2": { "name": "@newrelic/newrelic-oss-cli", "version": "0.1.2", @@ -494,18 +507,6 @@ "email": "gajus@gajus.com", "url": "http://gajus.com" }, - "eslint-plugin-sonarjs@3.0.1": { - "name": "eslint-plugin-sonarjs", - "version": "3.0.1", - "range": "^3.0.1", - "licenses": "LGPL-3.0-only", - "repoUrl": "https://github.com/SonarSource/SonarJS", - "versionedRepoUrl": "https://github.com/SonarSource/SonarJS/tree/v3.0.1", - "licenseFile": "node_modules/eslint-plugin-sonarjs/LICENSE", - "licenseUrl": "https://github.com/SonarSource/SonarJS/blob/v3.0.1/LICENSE", - "licenseTextSource": "file", - "publisher": "SonarSource" - }, "eslint@9.17.0": { "name": "eslint", "version": "9.17.0",