Skip to content

Commit

Permalink
tools: lint README lists more strictly
Browse files Browse the repository at this point in the history
PR-URL: #55625
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
  • Loading branch information
aduh95 authored and ruyadorno committed Nov 27, 2024
1 parent 0a7f301 commit 456b023
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ For information about the governance of the Node.js project, see
**Filip Skokan** <<[email protected]>> (he/him)
* [pimterry](https://github.com/pimterry) -
**Tim Perry** <<[email protected]>> (he/him)
* [pmarchini](https://github.com/pmarchini)
* [pmarchini](https://github.com/pmarchini) -
**Pietro Marchini** <<[email protected]>> (he/him)
* [Qard](https://github.com/Qard) -
**Stephen Belanger** <<[email protected]>> (he/him)
Expand Down Expand Up @@ -515,7 +515,7 @@ For information about the governance of the Node.js project, see
**Hitesh Kanwathirtha** <<[email protected]>> (he/him)
* [dmabupt](https://github.com/dmabupt) -
**Xu Meng** <<[email protected]>> (he/him)
* [dnlup](https://github.com/dnlup)
* [dnlup](https://github.com/dnlup) -
**dnlup** <<[email protected]>>
* [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) -
**Robert Jefe Lindstaedt** <<[email protected]>>
Expand Down Expand Up @@ -757,7 +757,7 @@ maintaining the Node.js project.
**Mert Can Altin** <<[email protected]>>
* [preveen-stack](https://github.com/preveen-stack) -
**Preveen Padmanabhan** <<[email protected]>> (he/him)
* [RedYetiDev](https://github.com/redyetidev) -
* [RedYetiDev](https://github.com/RedYetiDev) -
**Aviv Keller** <<[email protected]>> (they/them)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
**Mohammed Keyvanzadeh** <<[email protected]>> (he/him)
Expand Down
18 changes: 16 additions & 2 deletions tools/lint-readme-lists.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import assert from 'node:assert';
import { open } from 'node:fs/promises';
import { argv } from 'node:process';

const ghHandleLine = /^\* \[(.+)\]\(https:\/\/github\.com\/\1\) -$/;
const memberInfoLine = /^ {2}\*\*[^*]+\*\* <<[^@]+@.+\.[a-z]+>>( \(\w+(\/[^)/]+)+\))?( - \[Support me\]\(.+\))?$/;

const lists = {
'__proto__': null,

Expand All @@ -26,12 +29,19 @@ const tscMembers = new Set();
const readme = await open(new URL('../README.md', import.meta.url), 'r');

let currentList = null;
let previousGithubHandleInfoRequired;
let previousGithubHandle;
let lineNumber = 0;

for await (const line of readme.readLines()) {
lineNumber++;
if (line.startsWith('### ')) {
if (previousGithubHandleInfoRequired) {
if (!memberInfoLine.test(line)) {
throw new Error(`${previousGithubHandleInfoRequired} info are not formatted correctly (README.md:${lineNumber})`);
}
previousGithubHandle = previousGithubHandleInfoRequired;
previousGithubHandleInfoRequired = null;
} else if (line.startsWith('### ')) {
currentList = line.slice(4);
previousGithubHandle = null;
} else if (line.startsWith('#### ')) {
Expand All @@ -49,6 +59,10 @@ for await (const line of readme.readLines()) {
);
}

if (!ghHandleLine.test(line)) {
throw new Error(`${currentGithubHandle} is not formatted correctly (README.md:${lineNumber})`);
}

if (
currentList === 'TSC voting members' ||
currentList === 'TSC regular members'
Expand All @@ -60,7 +74,7 @@ for await (const line of readme.readLines()) {
if (lists[currentList]) {
(actualMembers[lists[currentList]] ??= new Set()).add(currentGithubHandle);
}
previousGithubHandle = currentGithubHandleLowerCase;
previousGithubHandleInfoRequired = currentGithubHandleLowerCase;
}
}
console.info('Lists are in the alphabetical order.');
Expand Down

0 comments on commit 456b023

Please sign in to comment.