-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}`); | ||
} |