Skip to content

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Jul 16, 2025

In #2567 support
was added to eslint.config.js for linting .js and .mjs files -- before it
only supported .ts files.
Originally this was added to support linting examples/... which includes many
.js files.

This change enables linting of .js and .mjs files in the rest of the repo.

Refs: #2891

…linting)

In open-telemetry#2567 support
was added to eslint.config.js for linting .js and .mjs files -- before it
only supported .ts files.
Originally this was added to support linting examples/... which includes many
.js files.

This change enables linting of .js and .mjs files in the rest of the repo.

Refs: open-telemetry#2891
@trentm
Copy link
Contributor Author

trentm commented Jul 16, 2025

^^ the first commit is just the package.json changes. Subsequent commits will include lint:fix changes (and if necessary manual changes to for npm run lint to pass).

@trentm trentm added the has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions label Jul 16, 2025
@trentm
Copy link
Contributor Author

trentm commented Jul 16, 2025

After running lint:fix (where 99% of changes were style-only tweaks to .eslintrc.js files), the only lint failures are in instr-aws-lambda:

      /Users/trentm/tm/opentelemetry-js-contrib2/packages/instrumentation-aws-lambda/test/lambda-test/async.js
        18:35  error  'event' is defined but never used    no-unused-vars
        18:42  error  'context' is defined but never used  no-unused-vars
        22:33  error  'event' is defined but never used    no-unused-vars
        22:40  error  'context' is defined but never used  no-unused-vars
        26:39  error  'event' is defined but never used    no-unused-vars
        26:46  error  'context' is defined but never used  no-unused-vars
        30:35  error  'event' is defined but never used    no-unused-vars
        30:42  error  'context' is defined but never used  no-unused-vars
        34:50  error  'event' is defined but never used    no-unused-vars
        34:57  error  'context' is defined but never used  no-unused-vars

      /Users/trentm/tm/opentelemetry-js-contrib2/packages/instrumentation-aws-lambda/test/lambda-test/sync.js
        22:27  error  'event' is defined but never used     no-unused-vars
        22:34  error  'context' is defined but never used   no-unused-vars
        22:43  error  'callback' is defined but never used  no-unused-vars
        30:33  error  'event' is defined but never used     no-unused-vars
        30:40  error  'context' is defined but never used   no-unused-vars
        30:49  error  'callback' is defined but never used  no-unused-vars

      ✖ 27 problems (16 errors, 11 warnings)

All are with the no-unused-vars rule.

Note that our eslint rules for TypeScript test files turn this rule off:

"@typescript-eslint/no-unused-vars": "off",

We could do the same for .js files (Option 1), or add a more nuanced config something like this, which supports adding a leading _ to a var name to have it skip the "no-unused-vars" rule (Option 2):

        "no-unused-vars": [
            "error",
            {
                "vars": "all",
                "args": "all",
                "caughtErrors": "all",
                "argsIgnorePattern": "^_",
                "caughtErrorsIgnorePattern": "^_",
                "varsIgnorePattern": "^_"
            }
        ]

Anyone have opinions?

Update: In commit 092f156 I've done "Option 1".

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.55%. Comparing base (c51fef1) to head (df89efc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2940   +/-   ##
=======================================
  Coverage   89.55%   89.55%           
=======================================
  Files         193      193           
  Lines        9698     9698           
  Branches     2011     2011           
=======================================
  Hits         8685     8685           
  Misses       1013     1013           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

files: ["test/**/*.js", "test/**/*.mjs"],
rules: {
"no-unused-vars": "off",
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer note: We turn on the same rule for .ts files in test/... dirs.
See #2940 (comment) for discussion.

@trentm trentm marked this pull request as ready for review August 25, 2025 16:05
@trentm trentm requested a review from a team as a code owner August 25, 2025 16:05
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phew.. a lot of files to look at 😅
thanks for working on this, looks great

@pichlermarc pichlermarc enabled auto-merge (squash) August 27, 2025 16:48
@pichlermarc pichlermarc merged commit ca26f63 into open-telemetry:main Aug 29, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions pkg:auto-configuration-propagators pkg:auto-instrumentations-node pkg:auto-instrumentations-web pkg:host-metrics pkg:id-generator-aws-xray pkg:instrumentation-amqplib pkg:instrumentation-aws-lambda pkg:instrumentation-aws-sdk pkg:instrumentation-bunyan pkg:instrumentation-cassandra-driver pkg:instrumentation-connect pkg:instrumentation-cucumber pkg:instrumentation-dataloader pkg:instrumentation-dns pkg:instrumentation-document-load pkg:instrumentation-express pkg:instrumentation-fastify pkg:instrumentation-fs pkg:instrumentation-generic-pool pkg:instrumentation-graphql pkg:instrumentation-hapi pkg:instrumentation-ioredis pkg:instrumentation-kafkajs pkg:instrumentation-knex pkg:instrumentation-koa pkg:instrumentation-long-task pkg:instrumentation-lru-memoizer pkg:instrumentation-memcached pkg:instrumentation-mongodb pkg:instrumentation-mongoose pkg:instrumentation-mysql pkg:instrumentation-mysql2 pkg:instrumentation-nestjs-core pkg:instrumentation-net pkg:instrumentation-oracledb pkg:instrumentation-pg pkg:instrumentation-pino pkg:instrumentation-redis pkg:instrumentation-restify pkg:instrumentation-router pkg:instrumentation-runtime-node pkg:instrumentation-socket.io pkg:instrumentation-tedious pkg:instrumentation-undici pkg:instrumentation-user-interaction pkg:instrumentation-winston pkg:plugin-react-load pkg:propagation-utils pkg:propagator-aws-xray pkg:propagator-aws-xray-lambda pkg:propagator-instana pkg:propagator-ot-trace pkg:redis-common pkg:resource-detector-alibaba-cloud pkg:resource-detector-aws pkg:resource-detector-azure pkg:resource-detector-container pkg:resource-detector-gcp pkg:resource-detector-github pkg:resource-detector-instana pkg:sampler-aws-xray pkg:sql-common pkg:test-utils pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found.
Projects
None yet
Development

Successfully merging this pull request may close these issues.