Skip to content

Support editor lookup by GitHub username#2054

Merged
kfranqueiro merged 8 commits intomainfrom
kgf-editor-github
Mar 6, 2026
Merged

Support editor lookup by GitHub username#2054
kfranqueiro merged 8 commits intomainfrom
kgf-editor-github

Conversation

@kfranqueiro
Copy link
Contributor

@kfranqueiro kfranqueiro commented Mar 3, 2026

This PR implements resolving GitHub usernames via the data-editor-github attribute, as an alternative to data-editor-id.

As this involves requests to GitHub's users API, the GH_TOKEN environment variable is checked for a token to pass.

Changes

  • Adds new resolveGithubUsernameToId utility function to lib/rules/util.js, which resolves a GitHub username to a W3C ID
    • Edge cases: returns null if the GitHub username is not found in either system (404); throws an error if any other HTTP error occurs
    • Lookups that result in success or 404 are temporarily cached, to avoid redundant lookups in the case of multiple runs, or multiple affected rules within the same run
  • Adds logic to rule modules headers/dl.js, headers/editor-participation.js, and metadata/editor-ids.js pertaining to GitHub username lookup; each of these checks for null return values and catches errors to report the appropriate error message
  • Moves getEditorIDs logic from lib/validator.js to lib/rules/metadata/editor-ids.js, as this was the only place it was used, and this relegates all resolveGithubUsernameToId calls to rules modules
  • Adds mention of data-editor-github to editorSection rule in lib/rules.json
  • Adds localization strings for new error cases under each rule
    • These have been added individually to work well with sr.error within each rule module, although they have the same content; the thought was that the more critical sr.throw would be excessive
  • Tests:
    • Adds mocks for both the GitHub and W3C API calls, including cases that resolve with 404 or 500 status
    • Adds success/missing/failure tests for the two headers-related rules, and a Basics test for the metadata resolution
  • Misc:
    • Removes explicit target from tsconfig, which was set to an excessively-old value which caused an interop issue with octokit's typings (the default is esnext when module is nodenext)

@kfranqueiro kfranqueiro requested a review from deniak March 3, 2026 23:10
@kfranqueiro kfranqueiro marked this pull request as ready for review March 4, 2026 21:23
@kfranqueiro kfranqueiro merged commit 58c4784 into main Mar 6, 2026
10 checks passed
@kfranqueiro kfranqueiro deleted the kgf-editor-github branch March 6, 2026 15:08
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.

2 participants