Skip to content

Commit 95f67ab

Browse files
committed
refactor: better docs
1 parent b7e8597 commit 95f67ab

File tree

8 files changed

+22
-10
lines changed

8 files changed

+22
-10
lines changed

bin/cli.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,4 @@ await runGenerators({
119119

120120
linter.report(reporter);
121121

122-
if (linter.hasError()) {
123-
exit(1);
124-
}
122+
exit(Number(linter.hasError()));

src/linter/index.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ import { missingChangeVersion } from './rules/missing-change-version.mjs';
66
import { missingIntroducedIn } from './rules/missing-introduced-in.mjs';
77

88
/**
9-
* Lint issues in ApiDocMetadataEntry entries
9+
* Creates a linter instance to validate ApiDocMetadataEntry entries
1010
*
1111
* @param {boolean} dryRun Whether to run the linter in dry-run mode
1212
*/
1313
const createLinter = dryRun => {
1414
/**
15+
* Lint issues found during validations
16+
*
1517
* @type {Array<import('./types.d.ts').LintIssue>}
1618
*/
1719
const issues = [];
1820

1921
/**
22+
* Lint rules to validate the entries against
23+
*
2024
* @type {Array<import('./types.d.ts').LintRule>}
2125
*/
2226
const rules = [
@@ -26,6 +30,8 @@ const createLinter = dryRun => {
2630
];
2731

2832
/**
33+
* Validates a ApiDocMetadataEntry entry against all defined rules
34+
*
2935
* @param {ApiDocMetadataEntry} entry
3036
* @returns {void}
3137
*/
@@ -40,6 +46,8 @@ const createLinter = dryRun => {
4046
};
4147

4248
/**
49+
* Validates an array of ApiDocMetadataEntry entries against all defined rules
50+
*
4351
* @param {ApiDocMetadataEntry[]} entries
4452
* @returns {void}
4553
*/
@@ -50,7 +58,10 @@ const createLinter = dryRun => {
5058
};
5159

5260
/**
53-
* @param {keyof reporters} reporterName
61+
* Reports found issues using the specified reporter
62+
*
63+
* @param {keyof typeof reporters} reporterName Reporter name
64+
* @returns {void}
5465
*/
5566
const report = reporterName => {
5667
if (dryRun) {
@@ -65,7 +76,7 @@ const createLinter = dryRun => {
6576
};
6677

6778
/**
68-
* Returns whether there are any issues with a level of 'error'
79+
* Checks if any error-level issues were found during linting
6980
*
7081
* @returns {boolean}
7182
*/

src/linter/reporters/console.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const levelToColorMap = {
1212
};
1313

1414
/**
15+
* Console reporter
16+
*
1517
* @type {import('../types.d.ts').Reporter}
1618
*/
1719
export default issue => {

src/linter/reporters/github.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const actions = {
99
};
1010

1111
/**
12-
* GitHub action reporter for
12+
* GitHub actions reporter
1313
*
1414
* @type {import('../types.d.ts').Reporter}
1515
*/

src/linter/rules/invalid-change-version.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LINT_MESSAGES } from '../../constants.mjs';
22
import { validateVersion } from '../utils/semver.mjs';
33

44
/**
5-
* Checks if any change version is invalid.
5+
* Checks if any change version is invalid
66
*
77
* @param {ApiDocMetadataEntry} entry
88
* @returns {Array<import('../types').LintIssue>}

src/linter/rules/missing-change-version.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Checks if any change version is missing.
2+
* Checks if any change version is missing
33
*
44
* @param {ApiDocMetadataEntry} entry
55
* @returns {Array<import('../types').LintIssue>}

src/linter/rules/missing-introduced-in.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LINT_MESSAGES } from '../../constants.mjs';
22

33
/**
4-
* Checks if `introduced_in` field is missing in the API doc entry.
4+
* Checks if `introduced_in` field is missing
55
*
66
* @param {ApiDocMetadataEntry} entry
77
* @returns {Array<import('../types.d.ts').LintIssue>}

src/linter/utils/semver.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Validates a semver version string
33
*
44
* @param {string} version
5+
* @returns {boolean}
56
*/
67
export const validateVersion = version => {
78
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string

0 commit comments

Comments
 (0)