Skip to content

refactor(lint): add eslint-plugin-baseline-js for browser compatibility#1019

Merged
overbalance merged 14 commits intomainfrom
overbalance/add-eslint-baseline
Dec 15, 2025
Merged

refactor(lint): add eslint-plugin-baseline-js for browser compatibility#1019
overbalance merged 14 commits intomainfrom
overbalance/add-eslint-baseline

Conversation

@overbalance
Copy link
Copy Markdown
Member

@overbalance overbalance commented Dec 12, 2025

What problem is this solving?

Adds automated checking for Web API browser compatibility, ensuring SDK code only uses APIs that are "widely available" (30+ months across all major browsers).

Short description of changes

  • Add eslint-plugin-baseline-js with type-aware parsing for source files
  • Add standalone eslint config for compiled output to catch non-baseline APIs from dependencies
  • Reorganize lint/check scripts: sdk:check = sdk:check:tsc + sdk:check:eslint
  • Simplify validate-sdk.js by removing redundant AST-based baseline analysis
  • Retain es-check on compiled output as syntax verification safety net
  • Remove unused scripts/build.js
  • Split CI validate-build job into separate SDK/CLI build and validate steps

Testing

  • Verified eslint catches non-baseline APIs in source (e.g., navigator.scheduling)
  • Verified es-check catches ES version violations (private fields in ES6, using in ES2022)
  • Verified eslint on dist catches non-baseline APIs from bundled dependencies
  • All existing tests pass

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 12, 2025

Chrome DevTools Protocol Tracing (Script: 102.49ms, Heap: 13.09MB)
Number of Requests Size of Requests Script Duration Task Duration Heap Used Size
Requests +3 requests +29.68 KB
Page Loaded +14.00 ms +8.19 ms +0.91 MB
Generate 100 fetch requests +16.26 ms +77.12 ms +1.73 MB
Generate 100 XHR requests +40.11 ms +112.22 ms +2.31 MB
Click 100 buttons and generate 100 logs +24.11 ms +29.03 ms +2.92 MB
Throw a 100 exceptions +0.81 ms +11.52 ms +2.17 MB
End Session +7.21 ms +21.24 ms +3.05 MB
Total +3 requests +29.68 KB +102.49 ms +259.31 ms +13.09 MB
Lighthouse (Script Eval: 46.40ms)
Difference Description
Total Blocking Time 0 ms Difference in Total Blocking Time: Sum of all time periods between FCP and Time to Interactive, when task length exceeded 50ms, expressed in milliseconds. Learn more about the Total Blocking Time metric.
Main Thread Time +60.83 ms Difference in Main Thread Time: Consider reducing the time spent parsing, compiling and executing JS. You may find delivering smaller JS payloads helps with this. Learn how to minimize main-thread work
Script Evaluation Time +46.40 ms Difference in Script Evaluation Time: Consider reducing the time spent parsing, compiling, and executing JS. You may find delivering smaller JS payloads helps with this. Learn how to reduce Javascript execution time.
Platform Tests (vite-7 gzip: 47.99KB)

vite-7 Platform Tests

Total Uncompressed Size Total Gzip Size
vite-7 - esnext +164.67 KB +47.99 KB
vite-7 - es2015 +171.51 KB +49.67 KB

vite-otel-latest Platform Tests

Total Uncompressed Size Total Gzip Size
vite-otel-latest - esnext +163.74 KB +49.69 KB
vite-otel-latest - es2015 +170.50 KB +51.32 KB

webpack-5 Platform Tests

Total Uncompressed Size Total Gzip Size
webpack-5 - esnext +121.11 KB +43.18 KB
webpack-5 - es2015 +122.22 KB +44.65 KB

@overbalance overbalance changed the title feat(lint): add eslint-plugin-baseline-js for browser compatibility refactor(lint): add eslint-plugin-baseline-js for browser compatibility Dec 12, 2025
@overbalance overbalance marked this pull request as ready for review December 12, 2025 23:59
@overbalance overbalance requested a review from a team as a code owner December 12, 2025 23:59
Copy link
Copy Markdown
Contributor

@jpmunz jpmunz left a comment

Choose a reason for hiding this comment

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

confirming this is not adding new functionality correct? The idea is to keep the same validation we had before but leverage eslint-plugin-baseline-js instead of our custom code?

export class FetchTransport implements IExporterTransport {
public constructor(private readonly _config: FetchRequestParameters) {}

/* eslint-disable baseline-js/use-baseline -- compression-streams baseline widely available since May 2023, plugin data stale */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this needed given the ignoreFeatures in eslint.dist.config.js?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes because comments are stripped out of compiled output.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure I follow, if this was removed the rule still triggers even though ignoreFeatures: ['compression-streams', 'proto'] is set? What is ignoreFeatures then configuring?

Copy link
Copy Markdown
Member Author

@overbalance overbalance Dec 15, 2025

Choose a reason for hiding this comment

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

eslint.config.js validates source code (which doesn't ignore features, hence the disable comments) and eslint.dist.config.js is used to validate compiled output. The IIFE file is stripped of comments so it was more convenient to add ignoreFeatures for all files in the dist folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah ok I understand now, thanks!

Comment thread eslint.dist.config.js Outdated
'error',
{
available: 'widely',
// compression-streams: widely available since May 2023, plugin data stale
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is pretty long ago for the plugin to not take it into account, is it updated regularly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wrote this poorly. CS was added to all browsers thirty months ago but only became "widely available" in November 2025. I'll revise.

@overbalance overbalance requested a review from jpmunz December 15, 2025 20:41
@overbalance overbalance merged commit e9718c9 into main Dec 15, 2025
29 of 31 checks passed
@overbalance overbalance deleted the overbalance/add-eslint-baseline branch December 15, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants