Skip to content

Commit

Permalink
style: run eslint-jsdoc
Browse files Browse the repository at this point in the history
I'm not adding it because @imports support needs Node 18.
  • Loading branch information
lishaduck committed Jun 22, 2024
1 parent b1060f7 commit db63e7f
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 17 deletions.
4 changes: 4 additions & 0 deletions lib/anonymize.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
/**
* Strip the version and paths out of the given string.
* This is only used for tests to make them pass even when the version/paths change.
*
* @param {Options} options
* @param {string} string
* @returns {string}
Expand All @@ -36,6 +37,7 @@ function pathsAndVersions(options, string) {
/**
* Strip the paths out of the given string.
* This is only used for tests to make them pass even when it's run on different machines.
*
* @param {Options} options
* @param {Path} filePath
* @returns {Path}
Expand All @@ -51,6 +53,7 @@ function anonymizePath(options, filePath) {
/**
* Strip the version out of the given string.
* This is only used for tests to make them pass even when the version changes.
*
* @param {string} string
* @returns {string}
*/
Expand All @@ -61,6 +64,7 @@ function replaceVersion(string) {

/**
* Get the version to print to the user.
*
* @param {Options} options
* @returns {string}
*/
Expand Down
3 changes: 3 additions & 0 deletions lib/autofix.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {

/**
* Subscribe to fix requests to prompt the user.
*
* @param {Options} options
* @param {App} app
* @param {ElmVersion} elmVersion
Expand All @@ -41,6 +42,7 @@ function subscribe(options, app, elmVersion) {

/**
* Subscribe to fix requests to prompt the user.
*
* @param {Options} options
* @param {App} app
* @param {ElmVersion} elmVersion
Expand Down Expand Up @@ -160,6 +162,7 @@ function checkIfAFixConfirmationIsStillExpected(app) {

/**
* Format a file using elm-format
*
* @param {Options} options
* @param {File} file
* @param {Path} filePath
Expand Down
2 changes: 2 additions & 0 deletions lib/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {

/**
* Start a benchmark labelled with the given name.
*
* @param {Options} options
* @param {string} name
* @returns {void}
Expand All @@ -21,6 +22,7 @@ function start(options, name) {

/**
* End a benchmark labelled with the given name.
*
* @param {Options} options
* @param {string} name
* @returns {void}
Expand Down
9 changes: 7 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const astCodecSrc = path.join(__dirname, '../ast-codec/src');
/**
* Get the hash associated to the current review application.
* This is either retrieved from a cache or computed.
*
* @param {Options} options
* @param {Path} userSrc
* @param {Path} reviewElmJsonPath
Expand Down Expand Up @@ -87,6 +88,7 @@ async function cachedBuild(

/**
* Build a review application.
*
* @param {Options} options
* @returns {Promise<BuildResult>}
*/
Expand All @@ -110,6 +112,7 @@ Please remove one of them and try re-running.`

/**
* Build a review application from a local configuration.
*
* @param {Options} options
* @returns {Promise<BuildResult>}
*/
Expand Down Expand Up @@ -195,6 +198,7 @@ I can help set you up with an initial configuration if you run ${chalk.magenta('

/**
* Build a review application from a remote GitHub template configuration.
*
* @param {Options} options
* @param {Template} template
* @returns {Promise<BuildResult>}
Expand Down Expand Up @@ -291,6 +295,7 @@ async function buildFromGitHubTemplate(options, template) {

/**
* Create a local temporary project to build an Elm application in.
*
* @param {Options} options
* @param {Path} userSrc
* @param {Path} projectFolder
Expand Down Expand Up @@ -353,7 +358,7 @@ function unique(array) {
}

/**
* @typedef {Object} CompileOptions
* @typedef {object} CompileOptions
* @property {string} cwd
* @property {string} output
* @property {boolean} debug
Expand All @@ -366,7 +371,7 @@ function unique(array) {
*/

/**
* @typedef {Object} ProcessOptions
* @typedef {object} ProcessOptions
* @property {NodeJS.ProcessEnv} env
* @property {('ignore' | 'inherit' | 'pipe')[]} stdio
*/
Expand Down
6 changes: 4 additions & 2 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const AppState = require('./state');
/** @import {Path} from "./types/path" */

/**
* @template {Object} T
* @template {object} T
* @param {Path} folder
* @param {string} key
* @param {() => Promise<T | null>} fn
Expand All @@ -30,14 +30,16 @@ async function getOrCompute(folder, key, fn) {

/**
* Set of folders that we already ensured exist.
*
* @type {Set<string>}
*/
const ensuredFolders = new Set();

/**
* Cache a file on the filesystem.
*
* @param {string} filepath - Path to the file ending in ".json"
* @param {Object} content
* @param {object} content
* @returns {Promise<void>}
*/
async function cacheJsonFile(filepath, content) {
Expand Down
4 changes: 3 additions & 1 deletion lib/dependency-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class OfflineAvailableVersionLister {
}

/**
* Cache of existing versions according to the package website. */
* Cache of existing versions according to the package website.
*/
class OnlineVersionsCache {
/** @type {Map<string, string[]>} */
map = new Map();
Expand Down Expand Up @@ -232,6 +233,7 @@ class OnlineVersionsCache {
class OnlineAvailableVersionLister {
/**
* Memoization cache to avoid doing the same work twice in list.
*
* @type {Map<string, string[]>}
*/
memoCache = new Map();
Expand Down
1 change: 1 addition & 0 deletions lib/elm-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function create(options) {
{
/**
* Get and respond to messages from the Elm application.
*
* @param {unknown} _
* @param {string} rawMessage
* @returns {null}
Expand Down
3 changes: 2 additions & 1 deletion lib/elm-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function flatMap(array, fn) {
}

/**
* @typedef {Object} ProjectFiles
* @typedef {object} ProjectFiles
* @property {ElmJsonData} elmJsonData
* @property {Readme | null} readme
* @property {ElmFile[]} elmFiles
Expand All @@ -52,6 +52,7 @@ function flatMap(array, fn) {

/**
* Get all files from the project.
*
* @param {ReviewOptions} options
* @param {string} elmSyntaxVersion
* @returns {Promise<ProjectFiles>}
Expand Down
1 change: 1 addition & 0 deletions lib/extra-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const OsHelpers = require('./os-helpers');

/**
* Collect the extra files requested by the rules.
*
* @param {ExtraFileRequest[]} requests
* @returns {Promise<NonElmFiles>}
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ function buildFlag(subcommand, flag) {
return ` ${flag.color(`--${flag.name}${flagArgs}`)}
${description
.map(
/** @param {string} desc
/**
* @param {string} desc
* @returns {string}
*/
(desc) => (desc ? ` ${desc}` : '')
Expand Down
11 changes: 7 additions & 4 deletions lib/fs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {rimraf} = require('rimraf');

/**
* Read a JSON file.
*
* @param {string} file
* @param {((this: any, key: string, value: any) => any) | undefined} reviver
* @returns {Promise<any>}
Expand All @@ -29,7 +30,7 @@ async function readJsonFile(file, reviver = undefined) {

/**
* @param {Path} file
* @returns {Object}
* @returns {object}
*/
function readJsonFileSync(file) {
const data = fs.readFileSync(file, 'utf8');
Expand All @@ -38,8 +39,9 @@ function readJsonFileSync(file) {

/**
* Read a file using Promises.
*
* @param {string} file
* @param {Object} options
* @param {object} options
* @returns {Promise<string>}
*/
function readFile(file, options = 'utf8') {
Expand All @@ -58,10 +60,11 @@ const writeFile = util.promisify(fs.writeFile);

/**
* Write a JSON file.
*
* @param {string} file
* @param {Object} content
* @param {object} content
* @param {string | number | undefined} space
* @param {((this: any, key: string, value: any) => any) | undefined} [replacer=undefined]
* @param {((this: any, key: string, value: any) => any) | undefined} [replacer]
* @returns {Promise<void>}
*/
function writeJson(file, content, space, replacer) {
Expand Down
1 change: 1 addition & 0 deletions lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {hash};

/**
* Hash a string.
*
* @param {string} content
* @returns {string}
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/min-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
* If given an input version string smaller than the hardcoded `minimalVersion`,
* it will return the minimal version.
* Otherwise, the input version string is returned.
*
* @param {VersionString} version - input version string, e.g. "1.0"
* @returns {VersionString}
*/
Expand All @@ -48,6 +49,7 @@ function updateToAtLeastMinimalVersion(version) {

/**
* Throws an error if the passed elm-review version is not compatible with this runner.
*
* @param {Options} options
* @param {Path} elmJsonPath - path to an elm.json file
* @param {VersionString} version - version string, e.g. "1.0"
Expand Down
1 change: 1 addition & 0 deletions lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ let containsHelp = false;

/**
* Compute the options for this run.
*
* @param {string[]} processArgv
* @returns { Options }
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/parse-elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const path = require('path');
/**
* A worker and the information whether it is currently busy.
*
* @typedef {Object} CustomWorker
* @typedef {object} CustomWorker
* @property {Worker} worker
* @property {boolean} busy
*/
Expand Down
1 change: 1 addition & 0 deletions lib/path-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {

/**
* Format a path so that you can `cd` it.
*
* @param {string} path
* @returns {string}
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/project-json-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const elmRoot =
* @param {string} elmVersion
* @param {string} name
* @param {string} packageVersion
* @returns {Promise<Object>}
* @returns {Promise<object>}
*/
function getElmJson(options, elmVersion, name, packageVersion) {
// Look for the dependency in ELM_HOME first
Expand Down Expand Up @@ -114,7 +114,7 @@ function getPackagePathInElmHome(elmVersion, name) {
* @param {string} elmVersion
* @param {string} name
* @param {string} packageVersion
* @returns {Promise<Object>}
* @returns {Promise<object>}
*/
function getDocsJson(options, elmVersion, name, packageVersion) {
return FS.readJsonFile(
Expand Down Expand Up @@ -176,7 +176,7 @@ async function readFromPackagesWebsite(

/**
* @param {Path} cacheLocation
* @param {Object} json
* @param {object} json
* @returns {Promise<void>}
*/
async function cacheFile(cacheLocation, json) {
Expand Down
1 change: 1 addition & 0 deletions lib/promisify-port.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Allows to treat a pair of ports as one promise.
* It sends a message into `sendTrough` and resolves the promise with the first "response" data on `subscribeTo`.
*
* @template DataIn,DataOut
* @param {import("./types/promisify-port").PortsToPromise<DataIn, DataOut>} obj
* @returns {PromiseLike<DataOut>}
Expand Down
2 changes: 2 additions & 0 deletions lib/remote-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function getLatestCommitForReference(options, template, reference) {

/**
* Download the elm.json file.
*
* @param {Options} options
* @param {Template} template
* @param {Path} reviewElmJsonPath
Expand Down Expand Up @@ -256,6 +257,7 @@ function downloadFile(url, dest) {

/**
* Make a request to the GitHub API.
*
* @param {Options} options
* @param {string} url
* @param {((arg: JsonResponse) => {title: string, message: string})} [handleNotFound]
Expand Down
1 change: 1 addition & 0 deletions lib/result-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const promisesToResolve = new Map();
// Depending on whether this is running in a worker or not, the options will be slightly different.
/**
* Load cache results.
*
* @param {Options} options
* @param {string[]} ignoredDirs
* @param {string[]} ignoredFiles
Expand Down
5 changes: 3 additions & 2 deletions lib/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const model = {

/**
* Update the state of the application.
*
* @param { Msg } message - What happened
* @returns { Model }
*/
Expand Down Expand Up @@ -258,8 +259,8 @@ function initializedApp() {
}

/**
* @param {{subscribe: SubscribePort, unsubscribe: (fn: function) => void}} port
* @param {function} subscriptionFunction
* @param {{subscribe: SubscribePort, unsubscribe: (fn: Function) => void}} port
* @param {Function} subscriptionFunction
* @returns {Model}
*/
function subscribe(port, subscriptionFunction) {
Expand Down

0 comments on commit db63e7f

Please sign in to comment.