Skip to content

Commit 8464c02

Browse files
aduh95marco-ippolito
authored andcommitted
tools: add a linter for README lists
PR-URL: #52476 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
1 parent 18ae7a4 commit 8464c02

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

.github/workflows/linters.yml

+7
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,10 @@ jobs:
179179
persist-credentials: false
180180
# GH Actions squashes all PR commits, HEAD^ refers to the base branch.
181181
- run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }}
182+
lint-readme:
183+
runs-on: ubuntu-latest
184+
steps:
185+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
186+
with:
187+
persist-credentials: false
188+
- run: tools/lint-readme-lists.mjs

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ For information about the governance of the Node.js project, see
343343
**Erick Wendel** <<erick.workspace@gmail.com>> (he/him)
344344
* [Ethan-Arrowood](https://github.com/Ethan-Arrowood) -
345345
**Ethan Arrowood** <<ethan@arrowood.dev>> (he/him)
346-
* [fhinkel](https://github.com/fhinkel) -
347-
**Franziska Hinkelmann** <<franziska.hinkelmann@gmail.com>> (she/her)
348346
* [F3n67u](https://github.com/F3n67u) -
349347
**Feng Yu** <<F3n67u@outlook.com>> (he/him)
348+
* [fhinkel](https://github.com/fhinkel) -
349+
**Franziska Hinkelmann** <<franziska.hinkelmann@gmail.com>> (she/her)
350350
* [Flarna](https://github.com/Flarna) -
351351
**Gerhard Stöbich** <<deb2001-github@yahoo.de>> (he/they)
352352
* [gabrielschulhof](https://github.com/gabrielschulhof) -
@@ -429,12 +429,12 @@ For information about the governance of the Node.js project, see
429429
**Stephen Belanger** <<admin@stephenbelanger.com>> (he/him)
430430
* [RafaelGSS](https://github.com/RafaelGSS) -
431431
**Rafael Gonzaga** <<rafael.nunu@hotmail.com>> (he/him)
432-
* [rluvaton](https://github.com/rluvaton) -
433-
**Raz Luvaton** <<rluvaton@gmail.com>> (he/him)
434432
* [richardlau](https://github.com/richardlau) -
435433
**Richard Lau** <<rlau@redhat.com>>
436434
* [rickyes](https://github.com/rickyes) -
437435
**Ricky Zhou** <<0x19951125@gmail.com>> (he/him)
436+
* [rluvaton](https://github.com/rluvaton) -
437+
**Raz Luvaton** <<rluvaton@gmail.com>> (he/him)
438438
* [ronag](https://github.com/ronag) -
439439
**Robert Nagy** <<ronagy@icloud.com>>
440440
* [ruyadorno](https://github.com/ruyadorno) -
@@ -477,10 +477,10 @@ For information about the governance of the Node.js project, see
477477
**Khaidi Chu** <<i@2333.moe>> (he/him)
478478
* [yashLadha](https://github.com/yashLadha) -
479479
**Yash Ladha** <<yash@yashladha.in>> (he/him)
480-
* [ZYSzys](https://github.com/ZYSzys) -
481-
**Yongsheng Zhang** <<zyszys98@gmail.com>> (he/him)
482480
* [zcbenz](https://github.com/zcbenz) -
483481
**Cheng Zhao** <<zcbenz@gmail.com>> (he/him)
482+
* [ZYSzys](https://github.com/ZYSzys) -
483+
**Yongsheng Zhang** <<zyszys98@gmail.com>> (he/him)
484484

485485
<details>
486486

@@ -495,10 +495,10 @@ For information about the governance of the Node.js project, see
495495
**Aleksei Koziatinskii** <<ak239spb@gmail.com>>
496496
* [andrasq](https://github.com/andrasq) -
497497
**Andras** <<andras@kinvey.com>>
498-
* [AnnaMag](https://github.com/AnnaMag) -
499-
**Anna M. Kedzierska** <<anna.m.kedzierska@gmail.com>>
500498
* [AndreasMadsen](https://github.com/AndreasMadsen) -
501499
**Andreas Madsen** <<amwebdk@gmail.com>> (he/him)
500+
* [AnnaMag](https://github.com/AnnaMag) -
501+
**Anna M. Kedzierska** <<anna.m.kedzierska@gmail.com>>
502502
* [aqrln](https://github.com/aqrln) -
503503
**Alexey Orlenko** <<eaglexrlnk@gmail.com>> (he/him)
504504
* [bcoe](https://github.com/bcoe) -
@@ -741,10 +741,10 @@ maintaining the Node.js project.
741741
**Mert Can Altin** <<mertgold60@gmail.com>>
742742
* [Mesteery](https://github.com/Mesteery) -
743743
**Mestery** <<mestery@protonmail.com>> (he/him)
744-
* [preveen-stack](https://github.com/preveen-stack) -
745-
**Preveen Padmanabhan** <<wide4head@gmail.com>> (he/him)
746744
* [PoojaDurgad](https://github.com/PoojaDurgad) -
747745
**Pooja Durgad** <<Pooja.D.P@ibm.com>>
746+
* [preveen-stack](https://github.com/preveen-stack) -
747+
**Preveen Padmanabhan** <<wide4head@gmail.com>> (he/him)
748748
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
749749
**Mohammed Keyvanzadeh** <<mohammadkeyvanzade94@gmail.com>> (he/him)
750750

tools/lint-readme-lists.mjs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
3+
// Validates the list in the README are in the correct order.
4+
5+
import { open } from 'node:fs/promises';
6+
7+
const lists = [
8+
'TSC voting members',
9+
'TSC regular members',
10+
'TSC emeriti members',
11+
'Collaborators',
12+
'Collaborator emeriti',
13+
'Triagers',
14+
];
15+
const tscMembers = new Set();
16+
17+
const readme = await open(new URL('../README.md', import.meta.url), 'r');
18+
19+
let currentList = null;
20+
let previousGithubHandle;
21+
let lineNumber = 0;
22+
23+
for await (const line of readme.readLines()) {
24+
lineNumber++;
25+
if (line.startsWith('### ')) {
26+
currentList = lists[lists.indexOf(line.slice(4))];
27+
previousGithubHandle = null;
28+
} else if (line.startsWith('#### ')) {
29+
currentList = lists[lists.indexOf(line.slice(5))];
30+
previousGithubHandle = null;
31+
} else if (currentList && line.startsWith('* [')) {
32+
const currentGithubHandle = line.slice(3, line.indexOf(']')).toLowerCase();
33+
if (previousGithubHandle && previousGithubHandle >= currentGithubHandle) {
34+
throw new Error(`${currentGithubHandle} should be listed before ${previousGithubHandle} in the ${currentList} list (README.md:${lineNumber})`);
35+
}
36+
37+
if (currentList === 'TSC voting members' || currentList === 'TSC regular members') {
38+
tscMembers.add(currentGithubHandle);
39+
} else if (currentList === 'Collaborators') {
40+
tscMembers.delete(currentGithubHandle);
41+
}
42+
previousGithubHandle = currentGithubHandle;
43+
}
44+
}
45+
46+
if (tscMembers.size !== 0) {
47+
throw new Error(`Some TSC members are not listed as Collaborators: ${Array.from(tscMembers)}`);
48+
}

0 commit comments

Comments
 (0)