From 91bce94010bec3b10769ff9fc5719e1a16f3b232 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 2 Nov 2024 15:14:40 +0100 Subject: [PATCH] tools: lint README lists more strictly PR-URL: https://github.com/nodejs/node/pull/55625 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Rafael Gonzaga --- README.md | 6 +++--- tools/lint-readme-lists.mjs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8f01a50eb37..69777ccb2da 100644 --- a/README.md +++ b/README.md @@ -409,7 +409,7 @@ For information about the governance of the Node.js project, see **Filip Skokan** <> (he/him) * [pimterry](https://github.com/pimterry) - **Tim Perry** <> (he/him) -* [pmarchini](https://github.com/pmarchini) +* [pmarchini](https://github.com/pmarchini) - **Pietro Marchini** <> (he/him) * [Qard](https://github.com/Qard) - **Stephen Belanger** <> (he/him) @@ -515,7 +515,7 @@ For information about the governance of the Node.js project, see **Hitesh Kanwathirtha** <> (he/him) * [dmabupt](https://github.com/dmabupt) - **Xu Meng** <> (he/him) -* [dnlup](https://github.com/dnlup) +* [dnlup](https://github.com/dnlup) - **dnlup** <> * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - **Robert Jefe Lindstaedt** <> @@ -757,7 +757,7 @@ maintaining the Node.js project. **Mert Can Altin** <> * [preveen-stack](https://github.com/preveen-stack) - **Preveen Padmanabhan** <> (he/him) -* [RedYetiDev](https://github.com/redyetidev) - +* [RedYetiDev](https://github.com/RedYetiDev) - **Aviv Keller** <> (they/them) * [VoltrexKeyva](https://github.com/VoltrexKeyva) - **Mohammed Keyvanzadeh** <> (he/him) diff --git a/tools/lint-readme-lists.mjs b/tools/lint-readme-lists.mjs index f6c05b46bdf..97992b79b1e 100755 --- a/tools/lint-readme-lists.mjs +++ b/tools/lint-readme-lists.mjs @@ -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, @@ -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('#### ')) { @@ -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' @@ -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.');