From fd1705fdc5742fe7bdfdec86fbc898c6d71dd8b6 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 1 Aug 2025 14:37:05 -0700 Subject: [PATCH] chore(lint): switch from 'header' to 'license-header' eslint plugin Fixes: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2967 Refs: https://github.com/nikku/eslint-plugin-license-header/pull/26 --- eslint.config.js | 33 ++++++++++++++--- package-lock.json | 37 ++++++++++++++++++- package.json | 2 +- packages/host-metrics/global.d.ts | 1 + .../instrumentation-kafkajs/src/propagator.ts | 1 + packages/instrumentation-kafkajs/src/types.ts | 1 + 6 files changed, 67 insertions(+), 8 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 0cde1b40db..5ba8c18ca9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,7 @@ module.exports = { plugins: [ "@typescript-eslint", - "header", + "license-header", "node", "prettier" ], @@ -19,11 +19,32 @@ module.exports = { "prefer-rest-params": "off", "no-shadow": "off", "node/no-deprecated-api": ["warn"], - "header/header": ["error", "block", [{ - pattern: / \* Copyright The OpenTelemetry Authors(, .+)*[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm, - template: - `\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ` - }]] + "license-header/header": [ + "error", + [ + "/*", + " * Copyright The OpenTelemetry Authors", + " *", + " * 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", + " *", + " * https://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.", + " */", + ], + { + "allowedHeaderPatterns": [ + // Allow additional copyrights on the first line. + /^\/\*\r?\n \* Copyright The OpenTelemetry Authors(, .+)*\r?\n \*\r?\n \* Licensed under the Apache License, Version 2.0 \(the "License"\);\r?\n \* you may not use this file except in compliance with the License.\r?\n \* You may obtain a copy of the License at\r?\n \*\r?\n \* https:\/\/www.apache.org\/licenses\/LICENSE-2.0\r?\n \*\r?\n \* Unless required by applicable law or agreed to in writing, software\r?\n \* distributed under the License is distributed on an "AS IS" BASIS,\r?\n \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r?\n \* See the License for the specific language governing permissions and\r?\n \* limitations under the License.\r?\n \*\/$/, + ] + } + ] }, overrides: [ { diff --git a/package-lock.json b/package-lock.json index af13903f44..1f265a97f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,8 +18,8 @@ "eslint": "8.7.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.8.0", - "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.27.5", + "eslint-plugin-license-header": "^0.8.0", "eslint-plugin-node": "11.1.0", "eslint-plugin-prettier": "4.2.1", "glob": "^10.4.5", @@ -15378,6 +15378,16 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-license-header": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-license-header/-/eslint-plugin-license-header-0.8.0.tgz", + "integrity": "sha512-khTCz6G3JdoQfwrtY4XKl98KW4PpnWUKuFx8v+twIRhJADEyYglMDC0td8It75C1MZ88gcvMusWuUlJsos7gYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "requireindex": "^1.2.0" + } + }, "node_modules/eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -26472,6 +26482,16 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "node_modules/requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.5" + } + }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -51207,6 +51227,15 @@ } } }, + "eslint-plugin-license-header": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-license-header/-/eslint-plugin-license-header-0.8.0.tgz", + "integrity": "sha512-khTCz6G3JdoQfwrtY4XKl98KW4PpnWUKuFx8v+twIRhJADEyYglMDC0td8It75C1MZ88gcvMusWuUlJsos7gYg==", + "dev": true, + "requires": { + "requireindex": "^1.2.0" + } + }, "eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -59652,6 +59681,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true + }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", diff --git a/package.json b/package.json index 72f46b91f8..6dc4d5c008 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "eslint": "8.7.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.8.0", - "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.27.5", + "eslint-plugin-license-header": "^0.8.0", "eslint-plugin-node": "11.1.0", "eslint-plugin-prettier": "4.2.1", "glob": "^10.4.5", diff --git a/packages/host-metrics/global.d.ts b/packages/host-metrics/global.d.ts index 19cc54f99a..35bcee58fa 100644 --- a/packages/host-metrics/global.d.ts +++ b/packages/host-metrics/global.d.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + declare module 'systeminformation/lib/network' { export { networkStats } from 'systeminformation'; } diff --git a/packages/instrumentation-kafkajs/src/propagator.ts b/packages/instrumentation-kafkajs/src/propagator.ts index abe2b1ee8b..a9031bcea9 100644 --- a/packages/instrumentation-kafkajs/src/propagator.ts +++ b/packages/instrumentation-kafkajs/src/propagator.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { TextMapGetter } from '@opentelemetry/api'; /* diff --git a/packages/instrumentation-kafkajs/src/types.ts b/packages/instrumentation-kafkajs/src/types.ts index 3c660ffdc8..ae174ca9f0 100644 --- a/packages/instrumentation-kafkajs/src/types.ts +++ b/packages/instrumentation-kafkajs/src/types.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Span } from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation';