Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 25, 2023
1 parent c9beaab commit 034930a
Show file tree
Hide file tree
Showing 20 changed files with 837 additions and 872 deletions.
File renamed without changes.
49 changes: 49 additions & 0 deletions lib/check-files.js
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)
}
41 changes: 0 additions & 41 deletions lib/check/check-files.js

This file was deleted.

11 changes: 0 additions & 11 deletions lib/check/index.js

This file was deleted.

40 changes: 0 additions & 40 deletions lib/check/merge-landmarks.js

This file was deleted.

62 changes: 0 additions & 62 deletions lib/check/merge-references.js

This file was deleted.

138 changes: 0 additions & 138 deletions lib/check/validate.js

This file was deleted.

12 changes: 6 additions & 6 deletions lib/constants.js
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.
Loading

0 comments on commit 034930a

Please sign in to comment.