Skip to content

Commit 034930a

Browse files
committed
Refactor code-style
1 parent c9beaab commit 034930a

20 files changed

+837
-872
lines changed
File renamed without changes.

lib/check-files.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @typedef {import('./index.js').Landmarks} Landmarks
3+
*/
4+
5+
import {constants, promises as fs} from 'node:fs'
6+
7+
/**
8+
* @param {Landmarks} landmarks
9+
* Landmarks.
10+
* @param {ReadonlyArray<string>} references
11+
* References.
12+
* @returns {Promise<undefined>}
13+
* Nothing.
14+
*/
15+
export async function checkFiles(landmarks, references) {
16+
/** @type {Array<Promise<undefined>>} */
17+
const promises = []
18+
19+
for (const filePath of references) {
20+
const marks = landmarks.get(filePath)
21+
22+
if (!marks) {
23+
/** @type {Map<string, boolean>} */
24+
const map = new Map()
25+
26+
landmarks.set(filePath, map)
27+
28+
promises.push(
29+
fs.access(filePath, constants.F_OK).then(
30+
/**
31+
* @returns {undefined}
32+
*/
33+
function () {
34+
map.set('', true)
35+
},
36+
/**
37+
* @param {NodeJS.ErrnoException} error
38+
* @returns {undefined}
39+
*/
40+
function (error) {
41+
map.set('', error.code !== 'ENOENT' && error.code !== 'ENOTDIR')
42+
}
43+
)
44+
)
45+
}
46+
}
47+
48+
await Promise.all(promises)
49+
}

lib/check/check-files.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

lib/check/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/check/merge-landmarks.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

lib/check/merge-references.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/check/validate.js

Lines changed: 0 additions & 138 deletions
This file was deleted.

lib/constants.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export const constants = {
2-
sourceId: 'remark-validate-links',
3-
headingRuleId: 'missing-heading',
4-
headingInFileRuleId: 'missing-heading-in-file',
1+
export const constants = /** @type {const} */ ({
52
fileRuleId: 'missing-file',
3+
headingInFileRuleId: 'missing-heading-in-file',
4+
headingRuleId: 'missing-heading',
65
landmarkId: 'remarkValidateLinksLandmarks',
7-
referenceId: 'remarkValidateLinksReferences'
8-
}
6+
referenceId: 'remarkValidateLinksReferences',
7+
sourceId: 'remark-validate-links'
8+
})
File renamed without changes.

0 commit comments

Comments
 (0)