Skip to content

Baseline status lookup - #342

Open
smsnedden wants to merge 4 commits into
cloudflare:mainfrom
smsnedden:baseline-status-lookup
Open

Baseline status lookup#342
smsnedden wants to merge 4 commits into
cloudflare:mainfrom
smsnedden:baseline-status-lookup

Conversation

@smsnedden

Copy link
Copy Markdown
Contributor

This adds a standalone lookup that maps MDN Browser Compatibility Data (BCD) keys to their Baseline status using the web-features package.

The HTML, CSS, and JavaScript detectors produce BCD keys, so this provides a shared, detector-independent classification step. Connecting the lookup to those detectors and producing status-grouped output will follow in later changes.

Changes

Baseline status lookup

Adds lookupBaselineStatus, which:

  • Builds a BCD-key-to-feature-ID index once for constant-time lookups.
  • Handles the feature, moved, and split records provided by web-features.
  • Prefers per-compat-key status when available, falling back to feature-level status.
  • Returns null for unknown BCD keys.
  • Preserves the classification supplied by web-features, including false, without reclassification.
  • Includes feature names, Baseline dates, browser support, and discouraged-feature metadata.
  • Returns independent copies of mutable metadata so callers cannot affect subsequent lookups.

Result types

Adds types describing Baseline classifications, supported browsers, discouraged-feature metadata, and lookup results:

export interface BaselineLookupResult {
  featureId: string;
  featureName: string;
  baseline: BaselineStatus;
  baselineLowDate: string | null;
  baselineHighDate: string | null;
  support: BaselineSupport;
  discouraged?: Discouraged;
}

Baseline date strings are returned as represented by web-features, including uncertainty prefixes such as where applicable.

Dependency

Adds web-features as a runtime dependency. Because it contains evolving Baseline data, keeping classifications current requires periodically updating the resolved version in package-lock.json and reviewing any resulting test changes. The compatible version range permits these updates but does not update existing lockfiles automatically. This PR does not introduce an automated refresh schedule.

Tests

Adds unit coverage for:

  • Widely available and Newly available features.
  • Unknown BCD keys.
  • Preserving an unclassified false status.
  • Per-compat-key status precedence.
  • Discouraged-feature metadata.
  • Isolation of returned metadata from caller mutation.
  • Omission of discouraged metadata for ordinary features.

Comment thread packages/telescope/src/types.ts Outdated
| '4g'
| 'fios'
| false;
'3g' | '3gfast' | '3gslow' | '2g' | 'cable' | 'dsl' | '4g' | 'fios' | false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: was this "unwound" to a single line from a formatter, or manually?

(I'd generally prefer each on its own line for readability and maintainability, when an item gets added or removed it just affects a single line).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was unwound from a formatter, I'll restore the existing one-per-line formatting now.

@sergeychernyshev sergeychernyshev Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's use prettier linter to format code and make sure we codify our preferences as rules.

Comment thread packages/telescope/src/baselineStatus.ts
Add a standalone, Node-side lookup mapping MDN Browser Compatibility Data
(BCD) keys to their Baseline status via the web-features package. Prefers
per-compat-key status when available and returns the raw classification
without reclassification.

This is a self-contained slice; wiring it to the HTML/CSS/JS feature
detectors follows in a later change.
@smsnedden
smsnedden force-pushed the baseline-status-lookup branch from 836f521 to 1d2ec03 Compare August 4, 2026 18:16

@sergeychernyshev sergeychernyshev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adding more types would help with maintenance in the future.

}
}

const featureId = bcdKeyToFeatureId.get(bcdKey);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's define types for these variables so we don't get some weird data as we update the web-features package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants