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 <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
  • Loading branch information
aduh95 committed Nov 5, 2024
1 parent 8d0526f commit 7ce7eab
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** <<panva.ip@gmail.com>> (he/him)
* [pimterry](https://github.com/pimterry) -
**Tim Perry** <<pimterry@gmail.com>> (he/him)
* [pmarchini](https://github.com/pmarchini)
* [pmarchini](https://github.com/pmarchini) -
**Pietro Marchini** <<pietro.marchini94@gmail.com>> (he/him)
* [Qard](https://github.com/Qard) -
**Stephen Belanger** <<admin@stephenbelanger.com>> (he/him)
Expand Down Expand Up @@ -515,7 +515,7 @@ For information about the governance of the Node.js project, see
**Hitesh Kanwathirtha** <<digitalinfinity@gmail.com>> (he/him)
* [dmabupt](https://github.com/dmabupt) -
**Xu Meng** <<dmabupt@gmail.com>> (he/him)
* [dnlup](https://github.com/dnlup)
* [dnlup](https://github.com/dnlup) -
**dnlup** <<dnlup.dev@gmail.com>>
* [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) -
**Robert Jefe Lindstaedt** <<robert.lindstaedt@gmail.com>>
Expand Down Expand Up @@ -757,7 +757,7 @@ maintaining the Node.js project.
**Mert Can Altin** <<mertgold60@gmail.com>>
* [preveen-stack](https://github.com/preveen-stack) -
**Preveen Padmanabhan** <<wide4head@gmail.com>> (he/him)
* [RedYetiDev](https://github.com/redyetidev) -
* [RedYetiDev](https://github.com/RedYetiDev) -
**Aviv Keller** <<redyetidev@gmail.com>> (they/them)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
**Mohammed Keyvanzadeh** <<mohammadkeyvanzade94@gmail.com>> (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 7ce7eab

Please sign in to comment.