Skip to content

Commit

Permalink
tools: add a linter for README lists
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
aduh95 committed Apr 29, 2024
1 parent 9b18df9 commit 8ae1507
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,10 @@ jobs:
persist-credentials: false
# GH Actions squashes all PR commits, HEAD^ refers to the base branch.
- run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }}
lint-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- run: tools/lint-readme-lists.mjs
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ For information about the governance of the Node.js project, see
**Erick Wendel** <<[email protected]>> (he/him)
* [Ethan-Arrowood](https://github.com/Ethan-Arrowood) -
**Ethan Arrowood** <<[email protected]>> (he/him)
* [fhinkel](https://github.com/fhinkel) -
**Franziska Hinkelmann** <<[email protected]>> (she/her)
* [F3n67u](https://github.com/F3n67u) -
**Feng Yu** <<[email protected]>> (he/him)
* [fhinkel](https://github.com/fhinkel) -
**Franziska Hinkelmann** <<[email protected]>> (she/her)
* [Flarna](https://github.com/Flarna) -
**Gerhard Stöbich** <<[email protected]>> (he/they)
* [gabrielschulhof](https://github.com/gabrielschulhof) -
Expand Down Expand Up @@ -429,12 +429,12 @@ For information about the governance of the Node.js project, see
**Stephen Belanger** <<[email protected]>> (he/him)
* [RafaelGSS](https://github.com/RafaelGSS) -
**Rafael Gonzaga** <<[email protected]>> (he/him)
* [rluvaton](https://github.com/rluvaton) -
**Raz Luvaton** <<[email protected]>> (he/him)
* [richardlau](https://github.com/richardlau) -
**Richard Lau** <<[email protected]>>
* [rickyes](https://github.com/rickyes) -
**Ricky Zhou** <<[email protected]>> (he/him)
* [rluvaton](https://github.com/rluvaton) -
**Raz Luvaton** <<[email protected]>> (he/him)
* [ronag](https://github.com/ronag) -
**Robert Nagy** <<[email protected]>>
* [ruyadorno](https://github.com/ruyadorno) -
Expand Down Expand Up @@ -477,10 +477,10 @@ For information about the governance of the Node.js project, see
**Khaidi Chu** <<[email protected]>> (he/him)
* [yashLadha](https://github.com/yashLadha) -
**Yash Ladha** <<[email protected]>> (he/him)
* [ZYSzys](https://github.com/ZYSzys) -
**Yongsheng Zhang** <<[email protected]>> (he/him)
* [zcbenz](https://github.com/zcbenz) -
**Cheng Zhao** <<[email protected]>> (he/him)
* [ZYSzys](https://github.com/ZYSzys) -
**Yongsheng Zhang** <<[email protected]>> (he/him)

<details>

Expand All @@ -495,10 +495,10 @@ For information about the governance of the Node.js project, see
**Aleksei Koziatinskii** <<[email protected]>>
* [andrasq](https://github.com/andrasq) -
**Andras** <<[email protected]>>
* [AnnaMag](https://github.com/AnnaMag) -
**Anna M. Kedzierska** <<[email protected]>>
* [AndreasMadsen](https://github.com/AndreasMadsen) -
**Andreas Madsen** <<[email protected]>> (he/him)
* [AnnaMag](https://github.com/AnnaMag) -
**Anna M. Kedzierska** <<[email protected]>>
* [aqrln](https://github.com/aqrln) -
**Alexey Orlenko** <<[email protected]>> (he/him)
* [bcoe](https://github.com/bcoe) -
Expand Down Expand Up @@ -741,10 +741,10 @@ maintaining the Node.js project.
**Mert Can Altin** <<[email protected]>>
* [Mesteery](https://github.com/Mesteery) -
**Mestery** <<[email protected]>> (he/him)
* [preveen-stack](https://github.com/preveen-stack) -
**Preveen Padmanabhan** <<[email protected]>> (he/him)
* [PoojaDurgad](https://github.com/PoojaDurgad) -
**Pooja Durgad** <<[email protected]>>
* [preveen-stack](https://github.com/preveen-stack) -
**Preveen Padmanabhan** <<[email protected]>> (he/him)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
**Mohammed Keyvanzadeh** <<[email protected]>> (he/him)

Expand Down
48 changes: 48 additions & 0 deletions tools/lint-readme-lists.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node

// Validates the list in the README are in the correct order.

import { open } from 'node:fs/promises';

const lists = [
'TSC voting members',
'TSC regular members',
'TSC emeriti members',
'Collaborators',
'Collaborator emeriti',
'Triagers',
];
const tscMembers = new Set();

const readme = await open(new URL('../README.md', import.meta.url), 'r');

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

for await (const line of readme.readLines()) {
lineNumber++;
if (line.startsWith('### ')) {
currentList = lists[lists.indexOf(line.slice(4))];
previousGithubHandle = null;
} else if (line.startsWith('#### ')) {
currentList = lists[lists.indexOf(line.slice(5))];
previousGithubHandle = null;
} else if (currentList && line.startsWith('* [')) {
const currentGithubHandle = line.slice(3, line.indexOf(']')).toLowerCase();
if (previousGithubHandle && previousGithubHandle >= currentGithubHandle) {
throw new Error(`${currentGithubHandle} should be listed before ${previousGithubHandle} in the ${currentList} list (README.md:${lineNumber})`);
}

if (currentList === 'TSC voting members' || currentList === 'TSC regular members') {
tscMembers.add(currentGithubHandle);
} else if (currentList === 'Collaborators') {
tscMembers.delete(currentGithubHandle);
}
previousGithubHandle = currentGithubHandle;
}
}

if (tscMembers.size !== 0) {
throw new Error(`Some TSC members are not listed as Collaborators: ${Array.from(tscMembers)}`);
}

0 comments on commit 8ae1507

Please sign in to comment.