Rewrite docs linter
1. I want to set the stage to deal with #2898 properly. 2. `request` was deprecated years ago. Decided that it's better to just move to native Node.js APIs in its place. 3. `glob` was outdated, and it's easier to just toss it than to upgrade across a major version. 4. I switched to using Marked's "lexer" directly so I'm not fussing with the complexity of renderers. This of course necessitated a more complex file processor as its "lexer" is really an AST parser. I also decided to go a few steps further: - Drop the cache to simplify everything. I might reverse this later, but just caching URLs per-page should be enough to prevent the world from crashing down. - Drop some more dependencies, so I don't have to come back to this later nearly as quickly. - Upgrade to a more modern language version in the scripts. - Update Marked. It was super outdated. - Add line and column numbers to the warnings. That took quite a bit of work, thanks to a missing Marked feature plus a bug in Marked.
This commit is contained in:
parent
3a633ce99c
commit
0d095d1373
15 changed files with 1201 additions and 1154 deletions
35
scripts/_lint-docs/task-queue.js
Normal file
35
scripts/_lint-docs/task-queue.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use strict"
|
||||
|
||||
// CI needs a much lower limit so it doesn't hang.
|
||||
const maxConcurrency = process.env.CI === "true" ? 5 : 20
|
||||
|
||||
const queue = []
|
||||
let running = 0
|
||||
|
||||
function runTask(task, callback) {
|
||||
process.nextTick(task, (...args) => {
|
||||
process.nextTick(callback, ...args)
|
||||
if (running === maxConcurrency) {
|
||||
const [nextTask, nextCallback] = queue.splice(0, 2)
|
||||
runTask(nextTask, nextCallback)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {any[]} A
|
||||
* @param {(callback: (...args: A) => void) => void} task
|
||||
* @param {(...args: A) => void} callback
|
||||
*/
|
||||
function submitTask(task, callback) {
|
||||
if (running < maxConcurrency) {
|
||||
running++
|
||||
runTask(task, callback)
|
||||
} else {
|
||||
queue.push(task, callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
submitTask,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue