Skip to content

Commit 9b43ccb

Browse files
authored
chore: add 'lint:deps' script to check for unused and unlisted deps (#2477)
This uses knip (https://knip.dev) to check dependencies, in hopes of avoiding issues like #2473. This adds 'npm run lint:deps' and adds that to the existing 'npm run lint'. This change includes fixes for a handful of unused and unlisted deps. For now knip is configured to only check 'production' deps. Checking non-prod deps results in way too many false positives. Note that knip is being run via `npx` rather than installing as a devDep because there is a conflict: knip deps on typescript@5 and all packaegs in this repo currently use [email protected]. Installing knip at the top-level results in a ballooning of the node_modules install size as [email protected] is installed 40+ types in all separate workspaces.
1 parent 2822511 commit 9b43ccb

File tree

58 files changed

+86
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+86
-47
lines changed

knip.jsonc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://knip.dev/reference/configuration
2+
{
3+
"$schema": "https://unpkg.com/knip@5/schema-jsonc.json",
4+
"workspaces": {
5+
"metapackages/auto-instrumentations-node": {
6+
// Ensure register.ts is considered an entry-point (the `!` is to be
7+
// included with the `--production` flag).
8+
"entry": "src/register.ts!"
9+
}
10+
}
11+
}

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
"test-all-versions": "npm run --if-present --workspaces test-all-versions",
2424
"bump": "lerna publish",
2525
"changelog": "lerna-changelog",
26-
"lint": "lerna run lint && npm run lint:readme && npm run lint:markdown",
26+
"lint": "lerna run lint && npm run lint:deps && npm run lint:readme && npm run lint:markdown",
2727
"lint:fix": "lerna run lint:fix && npm run lint:markdown:fix",
28+
"lint:deps": "npx --yes [email protected] --dependencies --production --tags=-knipignore",
2829
"lint:examples": "eslint ./examples/**/*.js",
2930
"lint:examples:fix": "eslint ./examples/**/*.js --fix",
3031
"lint:markdown": "markdownlint-cli2 $(git ls-files '*.md')",

packages/opentelemetry-host-metrics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"@opentelemetry/api": "^1.3.0",
47+
"@opentelemetry/sdk-metrics": "^1.8.0",
4748
"@types/mocha": "8.2.3",
4849
"@types/node": "18.18.14",
4950
"@types/sinon": "10.0.20",
@@ -53,7 +54,6 @@
5354
"typescript": "4.4.4"
5455
},
5556
"dependencies": {
56-
"@opentelemetry/sdk-metrics": "^1.8.0",
5757
"systeminformation": "5.22.9"
5858
},
5959
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-host-metrics#readme"

packages/opentelemetry-host-metrics/src/BaseMetrics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Meter, MeterProvider, diag, metrics } from '@opentelemetry/api';
1818

19+
/** @knipignore */
1920
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2021

2122
/**

packages/opentelemetry-test-utils/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
"@opentelemetry/core": "^1.0.0",
4848
"@opentelemetry/exporter-jaeger": "^1.3.1",
4949
"@opentelemetry/instrumentation": "^0.54.0",
50+
"@opentelemetry/otlp-transformer": "^0.54.0",
5051
"@opentelemetry/resources": "^1.8.0",
52+
"@opentelemetry/sdk-metrics": "^1.27.0",
5153
"@opentelemetry/sdk-node": "^0.54.0",
5254
"@opentelemetry/sdk-trace-base": "^1.8.0",
5355
"@opentelemetry/sdk-trace-node": "^1.8.0",

packages/winston-transport/src/OpenTelemetryTransportV3.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Logger, logs } from '@opentelemetry/api-logs';
1818
import TransportStream = require('winston-transport');
19+
/** @knipignore */
1920
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
2021
import { emitLogRecord } from './utils';
2122

plugins/node/instrumentation-amqplib/src/amqplib.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
normalizeExchange,
7575
unmarkConfirmChannelTracing,
7676
} from './utils';
77+
/** @knipignore */
7778
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
7879

7980
const supportedVersions = ['>=0.5.5 <1'];

plugins/node/instrumentation-cucumber/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
},
4646
"devDependencies": {
4747
"@cucumber/cucumber": "^9.0.0",
48+
"@cucumber/messages": "^22.0.0",
4849
"@opentelemetry/api": "^1.0.0",
4950
"@opentelemetry/core": "^1.3.1",
5051
"@opentelemetry/sdk-trace-base": "^1.3.1",

plugins/node/instrumentation-cucumber/src/instrumentation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {
3838
} from '@cucumber/cucumber/lib/support_code_library_builder/types';
3939

4040
import { AttributeNames, CucumberInstrumentationConfig } from './types';
41+
/** @knipignore */
4142
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
4243

4344
const hooks = ['Before', 'BeforeStep', 'AfterStep', 'After'] as const;

0 commit comments

Comments
 (0)