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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Ulises Gascón <[email protected]>
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 10 additions & 10 deletions
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** <<[email protected]>> (he/him)
344344
* [Ethan-Arrowood](https://github.com/Ethan-Arrowood) -
345345
**Ethan Arrowood** <<[email protected]>> (he/him)
346-
* [fhinkel](https://github.com/fhinkel) -
347-
**Franziska Hinkelmann** <<[email protected]>> (she/her)
348346
* [F3n67u](https://github.com/F3n67u) -
349347
**Feng Yu** <<[email protected]>> (he/him)
348+
* [fhinkel](https://github.com/fhinkel) -
349+
**Franziska Hinkelmann** <<[email protected]>> (she/her)
350350
* [Flarna](https://github.com/Flarna) -
351351
**Gerhard Stöbich** <<[email protected]>> (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** <<[email protected]>> (he/him)
430430
* [RafaelGSS](https://github.com/RafaelGSS) -
431431
**Rafael Gonzaga** <<[email protected]>> (he/him)
432-
* [rluvaton](https://github.com/rluvaton) -
433-
**Raz Luvaton** <<[email protected]>> (he/him)
434432
* [richardlau](https://github.com/richardlau) -
435433
**Richard Lau** <<[email protected]>>
436434
* [rickyes](https://github.com/rickyes) -
437435
**Ricky Zhou** <<[email protected]>> (he/him)
436+
* [rluvaton](https://github.com/rluvaton) -
437+
**Raz Luvaton** <<[email protected]>> (he/him)
438438
* [ronag](https://github.com/ronag) -
439439
**Robert Nagy** <<[email protected]>>
440440
* [ruyadorno](https://github.com/ruyadorno) -
@@ -477,10 +477,10 @@ For information about the governance of the Node.js project, see
477477
**Khaidi Chu** <<[email protected]>> (he/him)
478478
* [yashLadha](https://github.com/yashLadha) -
479479
**Yash Ladha** <<[email protected]>> (he/him)
480-
* [ZYSzys](https://github.com/ZYSzys) -
481-
**Yongsheng Zhang** <<[email protected]>> (he/him)
482480
* [zcbenz](https://github.com/zcbenz) -
483481
**Cheng Zhao** <<[email protected]>> (he/him)
482+
* [ZYSzys](https://github.com/ZYSzys) -
483+
**Yongsheng Zhang** <<[email protected]>> (he/him)
484484

485485
<details>
486486

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

tools/lint-readme-lists.mjs

Lines changed: 48 additions & 0 deletions
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)