Skip to content

Commit 3965c34

Browse files
committed
docs: update jsdocs
Address review comments from jfmengels#301.
1 parent 4a54b16 commit 3965c34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+360
-132
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ module.exports = {
128128
'no-unused-expressions': 'off', // This rule is replaced with the TSESlint version.
129129
'@typescript-eslint/no-unused-expressions': 'error', // Support TS stuff.
130130
'@typescript-eslint/no-throw-literal': 'error', // Recommended in v8 (w/rename to `only-throw-error`)
131-
'@typescript-eslint/prefer-namespace-keyword': 'error', // Recommended in v8
131+
'@typescript-eslint/prefer-find': 'error', // Recommended in v8
132+
'@typescript-eslint/prefer-includes': 'error', // Recommended in v8
133+
'@typescript-eslint/prefer-regexp-exec': 'error', // Recommended in v8
132134

133135
// Unsafe
134136
'@typescript-eslint/no-unsafe-assignment': 'off', // Blocked on typescript-eslint/typescript-eslint#1682.

lib/anonymize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This module aims to make the paths and versions used in the CLI generic
2+
* @file This module aims to make the paths and versions used in the CLI generic,
33
* so that the CLI tests (in the `test/` folder) have the same output on different
44
* machines, and also the same output when only the CLI version changes.
55
*/

lib/app-wrapper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function initWithWorker(elmModulePath, flags) {
8181

8282
/**
8383
* @param {string | symbol} port
84+
* @returns {Listened<unknown>}
8485
*/
8586
function send(port) {
8687
return (/** @type {unknown} */ data) => {
@@ -137,6 +138,7 @@ function initializeListeners() {
137138
/**
138139
* @param {string} elmModulePath
139140
* @param {Flags} flags
141+
* @returns {ReviewApp}
140142
*/
141143
function initWithoutWorker(elmModulePath, flags) {
142144
const elmModule = loadCompiledElmApp(elmModulePath);
@@ -146,6 +148,9 @@ function initWithoutWorker(elmModulePath, flags) {
146148
return app;
147149
}
148150

151+
/**
152+
* @returns {void}
153+
*/
149154
function stop() {
150155
if (worker) {
151156
worker.terminate();

lib/autofix.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const StyledMessage = require('./styled-message');
2727
* @param {Options} options
2828
* @param {ReviewApp} app
2929
* @param {VersionString} elmVersion
30+
* @returns {void}
3031
*/
3132
function subscribe(options, app, elmVersion) {
3233
AppState.subscribe(

lib/build.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/**
2+
* @import {CompileOptions, Sources} from '../vendor/types/node-elm-compiler';
23
* @import {AppHash, BuildResult} from './types/build';
34
* @import {ApplicationElmJson, ElmJson} from './types/content';
4-
* @import {VersionString} from './types/version';
5+
* @import {ErrorMessageInfo} from './types/error-message';
56
* @import {Options, Template} from './types/options';
67
* @import {Path} from './types/path';
7-
* @import {CompileOptions, Sources} from '../vendor/types/node-elm-compiler';
8+
* @import {VersionString} from './types/version';
89
*/
910
const path = require('node:path');
1011
const crypto = require('node:crypto');
@@ -334,6 +335,7 @@ async function createTemplateProject(
334335
* @param {Options} options
335336
* @param {string} userSrc
336337
* @param {ApplicationElmJson} elmJson
338+
* @returns {ApplicationElmJson}
337339
*/
338340
function updateSourceDirectories(options, userSrc, elmJson) {
339341
let sourceDirectories = [
@@ -359,10 +361,10 @@ function updateSourceDirectories(options, userSrc, elmJson) {
359361

360362
/**
361363
* @param {Options} options
362-
* @param {string} dest
363-
* @param {string} elmModulePath
364+
* @param {Path} dest
365+
* @param {Path} elmModulePath
364366
* @param {Sources} compileTargets
365-
* @param {string} elmBinary
367+
* @param {Path} elmBinary
366368
* @param {boolean} isReviewApp
367369
* @returns {Promise<string | null>}
368370
*/
@@ -455,6 +457,7 @@ async function compileElmProject(
455457
/**
456458
* @param {Options} options
457459
* @param {string} stderr
460+
* @returns {ErrorMessageInfo}
458461
*/
459462
function compilationError(options, stderr) {
460463
if (stderr.includes('DEBUG REMNANTS')) {
@@ -496,6 +499,7 @@ function compilationError(options, stderr) {
496499
* @param {Options} options
497500
* @param {Path} reviewElmJsonPath
498501
* @param {ElmJson} reviewElmJson
502+
* @returns {void}
499503
*/
500504
function validateElmReviewVersion(options, reviewElmJsonPath, reviewElmJson) {
501505
if (options.localElmReviewSrc) {

lib/debug.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const options = AppState.getOptions();
44

55
/**
66
* @param {string} message
7+
* @returns {void}
78
*/
89
function log(message) {
910
if (options.debug) {

lib/elm-files.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @import {ElmFile, Source, Readme, ElmJson, ElmJsonData, SourceDirectories, Ast} from './types/content';
2+
* @import {Ast, ElmFile, ElmJson, ProjectFiles, Readme, Source, SourceDirectories} from './types/content';
33
* @import {ReviewOptions} from './types/options';
44
* @import {Path} from './types/path';
55
*/
@@ -19,14 +19,6 @@ const AppState = require('./state');
1919

2020
const defaultGlob = '**/*.elm$';
2121

22-
/**
23-
* @typedef {object} ProjectFiles
24-
* @property {ElmJsonData} elmJsonData
25-
* @property {Readme | null} readme
26-
* @property {ElmFile[]} elmFiles
27-
* @property {Path[]} sourceDirectories
28-
*/
29-
3022
/**
3123
* Get all files from the project.
3224
*

lib/error-message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function stacktrace(debug, error) {
9797
* @param {boolean} debug
9898
* @param {CustomError} error
9999
* @param {Path} [defaultPath]
100-
* @returns {unknown}
100+
* @returns {{type: string; title: string; path: string | undefined; message: string[]; stack: string | undefined}}
101101
*/
102102
function formatJson(debug, error, defaultPath) {
103103
return {

lib/fs-wrapper.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const fsp = fs.promises;
99
* Read a JSON file.
1010
*
1111
* @param {Path} file
12-
* @param {Reviver | undefined} [reviver=undefined]
12+
* @param {Reviver} [reviver]
1313
* @returns {Promise<unknown>}
1414
*/
1515
async function readJsonFile(file, reviver) {
@@ -19,10 +19,9 @@ async function readJsonFile(file, reviver) {
1919
}
2020

2121
/**
22-
*
2322
* @param {string} data
2423
* @param {Path} file
25-
* @param {Reviver | undefined} reviver
24+
* @param {Reviver} [reviver]
2625
* @returns {unknown}
2726
*/
2827
function parseJsonFromFile(data, file, reviver) {
@@ -46,8 +45,8 @@ function readJsonFileSync(file) {
4645
/**
4746
* Read a file using Promises.
4847
*
49-
* @param {string} file
50-
* @param {fs.BaseEncodingOptions & { flag?: fs.OpenMode | undefined }} [options={encoding: 'utf8'}]
48+
* @param {Path} file
49+
* @param {fs.BaseEncodingOptions & { flag?: fs.OpenMode | undefined }} [options]
5150
* @returns {Promise<string>}
5251
*/
5352
async function readFile(file, options) {
@@ -58,10 +57,10 @@ async function readFile(file, options) {
5857
/**
5958
* Write a JSON file.
6059
*
61-
* @param {string} file
60+
* @param {Path} file
6261
* @param {unknown} content
63-
* @param {string | number | undefined} [space=undefined]
64-
* @param {Replacer | undefined} [replacer=undefined]
62+
* @param {string | number | undefined} [space]
63+
* @param {Replacer} [replacer]
6564
* @returns {Promise<void>}
6665
*/
6766
async function writeJson(file, content, space, replacer) {
@@ -85,7 +84,8 @@ function mkdirpSync(dir) {
8584
}
8685

8786
/**
88-
* @param {fs.PathLike} file
87+
* @param {Path} file
88+
* @returns {Promise<void>}
8989
*/
9090
async function remove(file) {
9191
await fsp.rm(

lib/help.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ ${Flags.buildFlags('fix', null)}
5656
);
5757
}
5858

59+
/**
60+
* @returns {void}
61+
*/
5962
function suppress() {
6063
const orange = chalk.keyword('orange');
6164

@@ -97,6 +100,9 @@ ${Flags.buildFlags('suppress', 'suppress')}
97100
);
98101
}
99102

103+
/**
104+
* @returns {void}
105+
*/
100106
function init() {
101107
console.log(
102108
// prettier-ignore
@@ -117,6 +123,9 @@ ${Flags.buildFlags('init', 'init')}
117123
);
118124
}
119125

126+
/**
127+
* @returns {void}
128+
*/
120129
function newPackage() {
121130
console.log(
122131
// prettier-ignore
@@ -138,6 +147,9 @@ ${Flags.buildFlags('new-package', 'new-package')}
138147
);
139148
}
140149

150+
/**
151+
* @returns {void}
152+
*/
141153
function newRule() {
142154
console.log(`The new-rule command adds an empty rule to your review configuration or
143155
review package.
@@ -161,6 +173,9 @@ ${Flags.buildFlags('new-rule', 'new-rule')}
161173
`);
162174
}
163175

176+
/**
177+
* @returns {void}
178+
*/
164179
function prepareOffline() {
165180
console.log(`The prepare-offline command allows the tool to run in offline mode using
166181
the ${chalk.cyan('--offline')} flag.

0 commit comments

Comments
 (0)