Skip to content

Commit e8004c0

Browse files
committed
lint: Use a new yet-another-license-header eslint-plugin to handle license headers
This changes to a new eslint-plugin to handle license headers. It supports the configurability that we need to allow additional Copyright holders. I've manually adapted the Copyright positioning in instr-oracledb and resource-detector-gcp to conform with the defined license header pattern. We can adjust the regexp if we need. Refs: open-telemetry#2969
1 parent fb3ca3a commit e8004c0

26 files changed

+161
-86
lines changed

eslint.config.mjs

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
import eslint from '@eslint/js';
218
import tseslint from 'typescript-eslint';
319
import globals from 'globals';
4-
import licenseHeaderPlugin from 'eslint-plugin-license-header';
520
import nodePlugin from 'eslint-plugin-n';
21+
import yalhPlugin from 'eslint-plugin-yet-another-license-header';
22+
23+
const defaultLicense = `
24+
/*
25+
* Copyright The OpenTelemetry Authors
26+
*
27+
* Licensed under the Apache License, Version 2.0 (the "License");
28+
* you may not use this file except in compliance with the License.
29+
* You may obtain a copy of the License at
30+
*
31+
* https://www.apache.org/licenses/LICENSE-2.0
32+
*
33+
* Unless required by applicable law or agreed to in writing, software
34+
* distributed under the License is distributed on an "AS IS" BASIS,
35+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36+
* See the License for the specific language governing permissions and
37+
* limitations under the License.
38+
*/
39+
`;
640

7-
const license = [
8-
'/*',
9-
' * Copyright The OpenTelemetry Authors',
10-
' *',
11-
' * Licensed under the Apache License, Version 2.0 (the "License");',
12-
' * you may not use this file except in compliance with the License.',
13-
' * You may obtain a copy of the License at',
14-
' *',
15-
' * https://www.apache.org/licenses/LICENSE-2.0',
16-
' *',
17-
' * Unless required by applicable law or agreed to in writing, software',
18-
' * distributed under the License is distributed on an "AS IS" BASIS,',
19-
' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
20-
' * See the License for the specific language governing permissions and',
21-
' * limitations under the License.',
22-
' */',
23-
];
41+
// This matches `defaultLicense`, but allows additional Copyright holders
42+
// either on the same line:
43+
// Copyright The OpenTelemetry Authors, <someone>, <another someone>
44+
// and/or on subsequent lines:
45+
// Copyright The OpenTelemetry Authors
46+
// Copyright <someone>
47+
// Copyright <another someone>
48+
const licensePattern = /^\/\*\n \* Copyright The OpenTelemetry Authors(, .+)*\n( \* Copyright .+\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 \* {6}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 \*\/$/
2449

2550
const baseConfig = tseslint.config(
2651
{
@@ -34,8 +59,7 @@ const baseConfig = tseslint.config(
3459
{
3560
files: ['**/*.{js,ts,mjs}', '*.{js,ts,mjs}'],
3661
plugins: {
37-
// XXX
38-
// 'license-header': licenseHeaderPlugin,
62+
'yet-another-license-header': yalhPlugin,
3963
node: nodePlugin,
4064
},
4165
extends: [
@@ -58,8 +82,10 @@ const baseConfig = tseslint.config(
5882
quotes: ['error', 'single', { avoidEscape: true }],
5983
eqeqeq: ['error', 'smart'],
6084
'prefer-rest-params': 'off',
61-
// XXX
62-
// 'license-header/header': ['error', license],
85+
'yet-another-license-header/header': ['error', {
86+
header: defaultLicense,
87+
allowedHeaderPatterns: [licensePattern],
88+
}],
6389

6490
// new rules
6591
'no-unused-vars': 'warn',

package-lock.json

Lines changed: 17 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"cross-env": "^7.0.3",
5656
"eslint": "9.34.0",
5757
"eslint-config-prettier": "10.1.8",
58-
"eslint-plugin-license-header": "0.8.0",
5958
"eslint-plugin-n": "17.21.3",
59+
"eslint-plugin-yet-another-license-header": "^0.1.0",
6060
"glob": "^10.4.5",
6161
"globals": "^16.3.0",
6262
"lerna": "8.2.3",

packages/instrumentation-oracledb/src/OracleTelemetryTraceHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,8 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
17+
1818
import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
1919
import {
2020
Span,

packages/instrumentation-oracledb/src/constants.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,7 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
1817

1918
// Contains span names produced by instrumentation
2019
// It lists the RPC names (suffix with _MSG like EXECUTE_MSG) and

packages/instrumentation-oracledb/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,7 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
1817

1918
export { OracleInstrumentation } from './instrumentation';
2019
export type {

packages/instrumentation-oracledb/src/instrumentation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,8 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
17+
1818
import {
1919
InstrumentationBase,
2020
InstrumentationNodeModuleDefinition,

packages/instrumentation-oracledb/src/internal-types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,7 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
1817

1918
import type * as oracledbTypes from 'oracledb';
2019
import type * as api from '@opentelemetry/api';

packages/instrumentation-oracledb/src/semconv.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,7 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
1817

1918
/**
2019
* The database management system (DBMS) product as identified

packages/instrumentation-oracledb/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright The OpenTelemetry Authors
3+
* Copyright (c) 2025, Oracle and/or its affiliates.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -12,9 +13,8 @@
1213
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
15-
*
16-
* Copyright (c) 2025, Oracle and/or its affiliates.
17-
* */
16+
*/
17+
1818
import type * as api from '@opentelemetry/api';
1919
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
2020

0 commit comments

Comments
 (0)