-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
837 additions
and
872 deletions.
There are no files selected for viewing
File renamed without changes.
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,49 @@ | ||
/** | ||
* @typedef {import('./index.js').Landmarks} Landmarks | ||
*/ | ||
|
||
import {constants, promises as fs} from 'node:fs' | ||
|
||
/** | ||
* @param {Landmarks} landmarks | ||
* Landmarks. | ||
* @param {ReadonlyArray<string>} references | ||
* References. | ||
* @returns {Promise<undefined>} | ||
* Nothing. | ||
*/ | ||
export async function checkFiles(landmarks, references) { | ||
/** @type {Array<Promise<undefined>>} */ | ||
const promises = [] | ||
|
||
for (const filePath of references) { | ||
const marks = landmarks.get(filePath) | ||
|
||
if (!marks) { | ||
/** @type {Map<string, boolean>} */ | ||
const map = new Map() | ||
|
||
landmarks.set(filePath, map) | ||
|
||
promises.push( | ||
fs.access(filePath, constants.F_OK).then( | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function () { | ||
map.set('', true) | ||
}, | ||
/** | ||
* @param {NodeJS.ErrnoException} error | ||
* @returns {undefined} | ||
*/ | ||
function (error) { | ||
map.set('', error.code !== 'ENOENT' && error.code !== 'ENOTDIR') | ||
} | ||
) | ||
) | ||
} | ||
} | ||
|
||
await Promise.all(promises) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export const constants = { | ||
sourceId: 'remark-validate-links', | ||
headingRuleId: 'missing-heading', | ||
headingInFileRuleId: 'missing-heading-in-file', | ||
export const constants = /** @type {const} */ ({ | ||
fileRuleId: 'missing-file', | ||
headingInFileRuleId: 'missing-heading-in-file', | ||
headingRuleId: 'missing-heading', | ||
landmarkId: 'remarkValidateLinksLandmarks', | ||
referenceId: 'remarkValidateLinksReferences' | ||
} | ||
referenceId: 'remarkValidateLinksReferences', | ||
sourceId: 'remark-validate-links' | ||
}) |
File renamed without changes.
Oops, something went wrong.