Skip to content

Conversation

jcscottiii
Copy link
Collaborator

@jcscottiii jcscottiii commented Jul 23, 2025

This commit introduces two main features to improve data quality and ease of use:

Schema Validation:

A schemas.json file is added to define a strict schema for each of the mapping files.
A new lint-schemas.js script validates the mapping files against these schemas. It also checks that all feature IDs exist in the web-features package.

Combined Data:

A new combine-mappings.js script aggregates data from all individual mapping files into a single web-features-mappings.combined.json file. This provides a single, convenient file for data consumers.
The package.json has been updated with lint:schemas and combine scripts to run these new tools. The README and .gitignore have also been updated accordingly.

@jcscottiii
Copy link
Collaborator Author

I started to put some changes up. This is not ready for review yet. I will update this later @captainbrosset

@jcscottiii jcscottiii changed the title begin adding schemas and lint feat: Add schema validation and data combination script Aug 19, 2025
@jcscottiii jcscottiii force-pushed the jcscottiii/schemas-lint branch from 575e95a to b95a191 Compare August 19, 2025 19:54
@jcscottiii
Copy link
Collaborator Author

There are actual lint errors in the data currently:

$ npm run lint:schemas 

> lint:schemas
> node lint-schemas.js

Linting mapping files against schemas...

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/wpt.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/wpt.json is valid.
  Error: Feature ID "viewport-segments" does not exist in web-features.
  Error: Feature ID "viewport" does not exist in web-features.
  Error: Feature ID "mixin" does not exist in web-features.

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/state-of-surveys.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/state-of-surveys.json is valid.

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/standards-positions.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/standards-positions.json is valid.

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/mdn-docs.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/mdn-docs.json is valid.
  Error: Feature ID "gravity-sensor" does not exist in web-features.

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/interop.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/interop.json is valid.

Linting /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/chrome-use-counters.json...
  /usr/local/google/home/jamescscott/code/final/web-features-mappings/mappings/chrome-use-counters.json is valid.


Linting failed with errors.

@jcscottiii jcscottiii marked this pull request as ready for review August 19, 2025 19:55
@jcscottiii
Copy link
Collaborator Author

@captainbrosset This is ready for review.

cc: @foolip

Copy link
Contributor

@captainbrosset captainbrosset left a comment

Choose a reason for hiding this comment

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

This looks great to me at a high level. If others want to dig in deeper into the technical details, then great. But I won't, both because I'm not super familiar with schemas and validation, but also because this early in the life of the repo, I don't think we need to block this, and can instead always go back and iterate quickly on these files if needed.

@captainbrosset
Copy link
Contributor

There are actual lint errors in the data currently

Very interesting. I honestly don't know where these unknown IDs come from. Maybe they were created at some point in the web-features repo and then removed, but that seems unlikely.
Seems like the best course of action here is to just remove the corresponding entries.

@captainbrosset
Copy link
Contributor

Error: Feature ID "viewport-segments" does not exist in web-features.

It's weird because WPT does have a feature called viewport-segments: https://wpt.fyi/results/?label=experimental&label=master&aligned&q=feature%3Aviewport-segments

So this ID definitely existed at some point.

@foolip
Copy link

foolip commented Aug 28, 2025

IDs in WPT aren't validated and might not exist in web-features. This one did show up in an audit previously:
web-platform-dx/web-features#3051 (comment)

I've sent web-platform-dx/web-features#3285 to make it exist!

@captainbrosset
Copy link
Contributor

@foolip cool! Maybe we can add this repo (web-features-mappings) to the list of data sources that the consumer audit checks!

This commit introduces two main features to improve data quality and ease of use:

Schema Validation:

A schemas.json file is added to define a strict schema for each of the mapping files.
A new lint-schemas.js script validates the mapping files against these schemas. It also checks that all feature IDs exist in the web-features package.

Combined Data:

A new combine-mappings.js script aggregates data from all individual mapping files into a single web-features-mappings.combined.json file. This provides a single, convenient file for data consumers.
The package.json has been updated with lint:schemas and combine scripts to run these new tools. The README and .gitignore have also been updated accordingly.
@jcscottiii jcscottiii force-pushed the jcscottiii/schemas-lint branch from b95a191 to 766c75d Compare August 28, 2025 14:26
@jcscottiii
Copy link
Collaborator Author

I rebased these changes and it should merge cleanly now. I don't have access to merge this.

Regarding fixing the lint errors, I filed #3

@captainbrosset captainbrosset merged commit 2540eba into web-platform-dx:main Aug 28, 2025
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