Skip to content

Commit 380fec0

Browse files
Merge pull request #205 from kazizi55/feature/inplement-eslint-jsdoc
chore: add eslint-plugin-jsdoc
2 parents db57a67 + b9cd7a7 commit 380fec0

File tree

11 files changed

+8634
-3471
lines changed

11 files changed

+8634
-3471
lines changed

library/.eslintrc.cjs

+33
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
extends: [
55
'eslint:recommended',
66
'plugin:@typescript-eslint/recommended',
7+
'plugin:jsdoc/recommended-typescript-error',
78
'plugin:regexp/recommended',
89
'plugin:security/recommended',
910
],
@@ -41,6 +42,38 @@ module.exports = {
4142
'@typescript-eslint/consistent-type-imports': 'warn',
4243
'@typescript-eslint/no-non-null-assertion': 'off',
4344

45+
// Imports
46+
'no-duplicate-imports': 'off',
47+
'import/extensions': ['error', 'always'],
48+
49+
// JSDoc
50+
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
51+
'jsdoc/sort-tags': [
52+
'error',
53+
{
54+
linesBetween: 1,
55+
tagSequence: [
56+
{ tags: ['deprecated'] },
57+
{ tags: ['param'] },
58+
{ tags: ['returns'] },
59+
],
60+
},
61+
],
62+
// NOTE: For overloads functions, we only require a JSDoc at the top
63+
// SEE: https://github.com/gajus/eslint-plugin-jsdoc/issues/666
64+
'jsdoc/require-jsdoc': [
65+
'error',
66+
{
67+
contexts: [
68+
'ExportNamedDeclaration[declaration.type="TSDeclareFunction"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="TSDeclareFunction"])',
69+
'ExportNamedDeclaration[declaration.type="FunctionDeclaration"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="FunctionDeclaration"])',
70+
],
71+
require: {
72+
FunctionDeclaration: false,
73+
},
74+
},
75+
],
76+
4477
// Security
4578
'security/detect-object-injection': 'off', // Too many false positives
4679
'security/detect-unsafe-regex': 'off', // Too many false positives, see https://github.com/eslint-community/eslint-plugin-security/issues/28 - we use the redos-detector plugin instead

library/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to the library will be documented in this file.
55
## vX.X.X (Month DD, YYYY)
66

77
- Change structure of schemas, validations and transformations to make properties accessible (pull request #211)
8+
- Fix errors in JSDoc comments and add JSDoc ESLint plugin (pull request #205)
89

910
## v0.20.1 (November 2, 2023)
1011

library/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@vitest/coverage-v8": "^0.33.0",
5959
"eslint": "^8.43.0",
6060
"eslint-plugin-import": "^2.28.1",
61+
"eslint-plugin-jsdoc": "^46.8.2",
6162
"eslint-plugin-redos-detector": "^2.1.1",
6263
"eslint-plugin-regexp": "^1.15.0",
6364
"eslint-plugin-security": "^1.7.1",

library/src/methods/brand/brand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type SchemaWithBrand<
3939
* Brands the output type of a schema.
4040
*
4141
* @param schema The scheme to be branded.
42-
* @param brand The brand name.
42+
* @param name The brand name.
4343
*
4444
* @returns The branded schema.
4545
*/

library/src/schemas/nullish/nullish.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export type NullishSchema<
3333
* Creates a nullish schema.
3434
*
3535
* @param wrapped The wrapped schema.
36-
* @param default_ The default value.
3736
*
3837
* @returns A nullish schema.
3938
*/

library/src/schemas/union/unionAsync.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type UnionSchemaAsync<
4141
/**
4242
* Creates an async union schema.
4343
*
44-
* @param union The union options.
44+
* @param options The union options.
4545
* @param message The error message.
4646
*
4747
* @returns An async union schema.

library/src/types/pipe.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export type BaseValidation<TInput = any> = {
4747
/**
4848
* Parses unknown input based on its requirement.
4949
*
50-
* @internal This is an internal API.
51-
*
5250
* @param input The input to be parsed.
5351
*
5452
* @returns The parse result.
53+
*
54+
* @internal
5555
*/
5656
_parse(input: TInput): PipeResult<TInput>;
5757
};
@@ -71,11 +71,11 @@ export type BaseValidationAsync<TInput = any> = {
7171
/**
7272
* Parses unknown input based on its requirement.
7373
*
74-
* @internal This is an internal API.
75-
*
7674
* @param input The input to be parsed.
7775
*
7876
* @returns The parse result.
77+
*
78+
* @internal
7979
*/
8080
_parse(input: TInput): Promise<PipeResult<TInput>>;
8181
};
@@ -91,11 +91,11 @@ export type BaseTransformation<TInput = any> = {
9191
/**
9292
* Parses unknown input based on its requirement.
9393
*
94-
* @internal This is an internal API.
95-
*
9694
* @param input The input to be parsed.
9795
*
9896
* @returns The parse result.
97+
*
98+
* @internal
9999
*/
100100
_parse(input: TInput): PipeResult<TInput>;
101101
};
@@ -111,11 +111,11 @@ export type BaseTransformationAsync<TInput = any> = {
111111
/**
112112
* Parses unknown input based on its requirement.
113113
*
114-
* @internal This is an internal API.
115-
*
116114
* @param input The input to be parsed.
117115
*
118116
* @returns The parse result.
117+
*
118+
* @internal
119119
*/
120120
_parse(input: TInput): Promise<PipeResult<TInput>>;
121121
};

library/src/types/schema.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ export type BaseSchema<TInput = any, TOutput = TInput> = {
4343
/**
4444
* Parses unknown input based on its schema.
4545
*
46-
* @internal This is an internal API.
47-
*
4846
* @param input The input to be parsed.
4947
* @param info The parse info.
5048
*
5149
* @returns The parse result.
50+
*
51+
* @internal
5252
*/
5353
_parse(input: unknown, info?: ParseInfo): _ParseResult<TOutput>;
5454
/**
5555
* Input and output type.
5656
*
57-
* @internal This is an internal API.
57+
* @internal
5858
*/
5959
_types?: { input: TInput; output: TOutput };
6060
};
@@ -70,18 +70,18 @@ export type BaseSchemaAsync<TInput = any, TOutput = TInput> = {
7070
/**
7171
* Parses unknown input based on its schema.
7272
*
73-
* @internal This is an internal API.
74-
*
7573
* @param input The input to be parsed.
7674
* @param info The parse info.
7775
*
7876
* @returns The parse result.
77+
*
78+
* @internal
7979
*/
8080
_parse(input: unknown, info?: ParseInfo): Promise<_ParseResult<TOutput>>;
8181
/**
8282
* Input and output type.
8383
*
84-
* @internal This is an internal API.
84+
* @internal
8585
*/
8686
_types?: { input: TInput; output: TOutput };
8787
};

library/src/utils/executePipe/executePipeAsync.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getIssue, getPipeInfo } from './utils/index.ts';
1515
*
1616
* @param input The input value.
1717
* @param pipe The pipe to be executed.
18-
* @param parseInfo The validation info.
18+
* @param parseInfo The parse info.
1919
* @param reason The issue reason.
2020
*
2121
* @returns The output value.

library/src/utils/getPipeIssues/getPipeIssues.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getIssues } from '../getIssues/getIssues.ts';
88
* @param validation The validation name.
99
* @param message The error message.
1010
* @param input The input value.
11+
* @param requirement The requirement.
1112
*
1213
* @returns The pipeline result object.
1314
*/

0 commit comments

Comments
 (0)