Skip to content

Repo: next major version of schema #257

@43081j

Description

@43081j

The current replacement manifests are limited in that they mostly focus on npm packages and node engines.

In the next major version, we should try account for other engines and possibly syntax replacements.

Engine constraints

The current manifests can specify a nodeVersion like so:

"nodeVersion": "6.0.0",

The ESLint plugin takes this and compares it against the package.json engines field to decide if to suggest this replacement or not.

This should be a little more generic such that we can represent:

  • Other engines (e.g. bun, deno, etc)
  • Browsers (e.g. native replacements available in a specific Chrome version)

Syntax replacements

Not all environments have the original module specifiers available. For example, we may be analyzing a bundle rather than a project.

In those cases, this data isn't useful since we don't know which modules we're using.

It may be useful if a replacement can have both:

  • A module specifier
  • Syntax patterns

Then if either matches, we consider that module being in use.

Representing doc links

We currently hard code mdnPath like this:

      "mdnPath": "Global_Objects/Array/includes",

This isn't great since we may want to link to other parts of MDN.

Similarly, we have a docPath which is hard coded to be used to build URLs to this repo.

This again isn't great since we want docs on the e18e site now, and not always via the same route.

We need a new way, maybe just a URL:

  "docUrl": "FULL URL HERE"

How far do we go?

I want to avoid going too generic where we end up with whats basically a JSON conditional logic system. Lots of those exist in the wild and feel like they are too much for this project since we're working in a well understood space/structure.

We should try keep things simple but not too hard coded.

Example

Something like this:

    {
      "type": "native",
      "moduleName": "array-includes",
-     "nodeVersion": "6.0.0",
+     "constraints": [
+       { "type": "engine", "name": "node", "minVersion": "6.0.0" }
+     ],
      "replacement": "Array.prototype.includes",
-     "mdnPath": "Global_Objects/Array/includes",
+     "docUrl": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes",
-     "category": "native"
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions