Skip to content

Commit 10dd7d4

Browse files
committed
chore: turn on jsdoc linting for existing jsdoc in all files
1 parent b9d4731 commit 10dd7d4

File tree

8 files changed

+56
-43
lines changed

8 files changed

+56
-43
lines changed

.eslintrc.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ module.exports = defineConfig({
1818
'plugin:@typescript-eslint/recommended',
1919
'plugin:@typescript-eslint/recommended-requiring-type-checking',
2020
'plugin:prettier/recommended',
21+
'plugin:jsdoc/recommended-typescript-error',
2122
],
2223
parser: '@typescript-eslint/parser',
2324
parserOptions: {
2425
project: ['./tsconfig.json'],
2526
sourceType: 'module',
2627
warnOnUnsupportedTypeScriptVersion: false,
2728
},
28-
plugins: ['@typescript-eslint', 'prettier', 'deprecation'],
29+
plugins: ['@typescript-eslint', 'prettier', 'deprecation', 'jsdoc'],
2930
rules: {
3031
// We may want to use this in the future
3132
'no-useless-escape': 'off',
@@ -77,40 +78,39 @@ module.exports = defineConfig({
7778
{ allowNumber: true, allowBoolean: true },
7879
],
7980
'@typescript-eslint/unbound-method': 'off',
81+
82+
'jsdoc/require-jsdoc': 'off',
83+
'jsdoc/no-types': 'error',
84+
'jsdoc/require-returns': 'off',
85+
'jsdoc/tag-lines': 'off',
86+
'jsdoc/sort-tags': [
87+
'error',
88+
{
89+
tagSequence: [
90+
{ tags: ['template'] },
91+
{ tags: ['internal'] },
92+
{ tags: ['param'] },
93+
{ tags: ['returns'] },
94+
{ tags: ['throws'] },
95+
{ tags: ['see'] },
96+
{ tags: ['example'] },
97+
{ tags: ['since'] },
98+
{ tags: ['default'] },
99+
{ tags: ['deprecated'] },
100+
],
101+
},
102+
],
103+
},
104+
settings: {
105+
jsdoc: {
106+
mode: 'typescript',
107+
},
80108
},
81109
overrides: [
82110
{
83111
files: ['src/**/*.ts'],
84-
plugins: ['jsdoc'],
85-
extends: ['plugin:jsdoc/recommended-error'],
86112
rules: {
87-
'jsdoc/no-types': 'error',
88-
'jsdoc/require-param-type': 'off',
89-
'jsdoc/require-returns-type': 'off',
90-
'jsdoc/require-returns': 'off',
91-
'jsdoc/tag-lines': 'off',
92-
'jsdoc/sort-tags': [
93-
'error',
94-
{
95-
tagSequence: [
96-
{ tags: ['template'] },
97-
{ tags: ['internal'] },
98-
{ tags: ['param'] },
99-
{ tags: ['returns'] },
100-
{ tags: ['throws'] },
101-
{ tags: ['see'] },
102-
{ tags: ['example'] },
103-
{ tags: ['since'] },
104-
{ tags: ['default'] },
105-
{ tags: ['deprecated'] },
106-
],
107-
},
108-
],
109-
},
110-
settings: {
111-
jsdoc: {
112-
mode: 'typescript',
113-
},
113+
'jsdoc/require-jsdoc': 'error',
114114
},
115115
},
116116
{

src/modules/date/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function toDate(
2323
return date;
2424
}
2525

26+
/**
27+
* Module to generate dates (without methods requiring localized data).
28+
*/
2629
export class SimpleDateModule {
2730
constructor(protected readonly faker: SimpleFaker) {
2831
bindThisToMemberFunctions(this);

src/modules/helpers/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ function legacyRegexpStringParse(
158158
return string;
159159
}
160160

161+
/**
162+
* Module with various helper methods providing basic (seed-dependent) operations useful for implementing faker methods (without methods requiring localized data).
163+
*/
161164
export class SimpleHelpersModule {
162165
/**
163166
* Global store of unique values.

test/modules/location.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ function kilometersToMiles(miles: number) {
1212
}
1313

1414
/**
15-
* Returns the number of decimal places a number has
15+
* Returns the number of decimal places a number has.
16+
*
17+
* @param num The number to check.
1618
*/
1719
function precision(num: number): number {
1820
const decimalPart = num.toString().split('.')[1];

test/scripts/apidoc/__snapshots__/signature.spec.ts.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = `
4343
"returns": "T",
4444
"seeAlsos": [],
4545
"since": "",
46-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L357",
46+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L358",
4747
"throws": undefined,
4848
}
4949
`;
@@ -198,7 +198,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = `
198198
"test.apidoc.methodWithExample()",
199199
],
200200
"since": "",
201-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L277",
201+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L278",
202202
"throws": undefined,
203203
}
204204
`;
@@ -250,7 +250,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecatedOption 1`] = `
250250
"returns": "number",
251251
"seeAlsos": [],
252252
"since": "",
253-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L298",
253+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L299",
254254
"throws": undefined,
255255
}
256256
`;
@@ -268,7 +268,7 @@ exports[`signature > analyzeSignature() > methodWithExample 1`] = `
268268
"returns": "number",
269269
"seeAlsos": [],
270270
"since": "",
271-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L266",
271+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L267",
272272
"throws": undefined,
273273
}
274274
`;
@@ -288,7 +288,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = `
288288
"test.apidoc.methodWithDeprecated()",
289289
],
290290
"since": "",
291-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L325",
291+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L326",
292292
"throws": undefined,
293293
}
294294
`;
@@ -308,7 +308,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBacktic
308308
"test.apidoc.methodWithDeprecated() with parameter <code>bar</code> and <code>baz</code>.",
309309
],
310310
"since": "",
311-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L335",
311+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L336",
312312
"throws": undefined,
313313
}
314314
`;
@@ -325,7 +325,7 @@ exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = `
325325
"returns": "number",
326326
"seeAlsos": [],
327327
"since": "1.0.0",
328-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L344",
328+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L345",
329329
"throws": undefined,
330330
}
331331
`;
@@ -342,7 +342,7 @@ exports[`signature > analyzeSignature() > methodWithThrows 1`] = `
342342
"returns": "number",
343343
"seeAlsos": [],
344344
"since": "",
345-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L286",
345+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L287",
346346
"throws": "a Faker error",
347347
}
348348
`;
@@ -491,7 +491,7 @@ It also has a more complex description.</p>
491491
"returns": "number",
492492
"seeAlsos": [],
493493
"since": "",
494-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L216",
494+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L217",
495495
"throws": undefined,
496496
}
497497
`;
@@ -530,7 +530,7 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault
530530
"returns": "number",
531531
"seeAlsos": [],
532532
"since": "",
533-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L252",
533+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L253",
534534
"throws": undefined,
535535
}
536536
`;
@@ -596,7 +596,7 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = `
596596
"returns": "number",
597597
"seeAlsos": [],
598598
"since": "",
599-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L186",
599+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L187",
600600
"throws": undefined,
601601
}
602602
`;
@@ -635,7 +635,7 @@ exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`]
635635
"returns": "number",
636636
"seeAlsos": [],
637637
"since": "",
638-
"sourcePath": "test/scripts/apidoc/signature.example.ts#L234",
638+
"sourcePath": "test/scripts/apidoc/signature.example.ts#L235",
639639
"throws": undefined,
640640
}
641641
`;

test/scripts/apidoc/signature.example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export class SignatureTest {
182182
* @param options.b The string parameter.
183183
* @param options.c The boolean parameter.
184184
* @param options.d The method parameter.
185+
* @param options.e The LiteralUnion parameter.
185186
*/
186187
optionsParamMethod(options: {
187188
a: number;

test/scripts/apidoc/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { mapByName } from '../../../scripts/apidoc/utils';
1212

1313
/**
1414
* Returns a record with the (Module-Name -> (Method-Name -> Method-Signature)) for the project.
15+
*
16+
* @param options The TypeDoc options.
17+
* @param includeTestModules Whether to include the test modules.
1518
*/
1619
export function loadProjectModules(
1720
options?: Partial<TypeDocOptions>,

test/support/times.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Generates a number sequence from 1 to `length`.
33
*
44
* @param length The length of the sequence.
5+
*
56
* @returns The sequence.
67
*/
78
export function times(length: number): number[] {

0 commit comments

Comments
 (0)