Skip to content

Commit b4beb95

Browse files
committed
Merge branch 'master' into add-more-type-checks-to-valid-types
* master: feat: add fixer for no-types (#350) fix(check-param-names): ensure polyfilling `Object.entries` for Node 6 fix(check-param-names): provide fixer duplicate param names (remove extra); partial fix for #47 chore(npm): update deps (comment-parser, lodash) and devDep (husky, mocha) fix(require-param): reporting all missing jsdoc params (#348) docs(check-examples): fix heading level docs(readme): remove section "Reference to jscs-jsdoc" chore: update Babel devDeps
2 parents 765f6ed + 5863029 commit b4beb95

File tree

11 files changed

+203
-146
lines changed

11 files changed

+203
-146
lines changed

.README/README.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,6 @@ JSDoc linting rules for ESLint.
99

1010
{"gitdown": "contents"}
1111

12-
### Reference to jscs-jsdoc
13-
14-
This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
15-
16-
| `eslint-plugin-jsdoc` | `jscs-jsdoc` |
17-
| --- | --- |
18-
| [`check-alignment`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-alignment) | N/A |
19-
| [`check-examples`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-examples) | N/A |
20-
| [`check-indentation`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-indentation) | N/A |
21-
| [`check-param-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-param-names) | [`checkParamNames`](https://github.com/jscs-dev/jscs-jsdoc#checkparamnames) |
22-
| [`check-syntax`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-syntax) | N/A |
23-
| [`check-tag-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-tag-names) | N/A ~ [`checkAnnotations`](https://github.com/jscs-dev/jscs-jsdoc#checkannotations) |
24-
| [`check-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-types) | [`checkTypes`](https://github.com/jscs-dev/jscs-jsdoc#checktypes) |
25-
| [`newline-after-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description) | [`requireNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirenewlineafterdescription) and [`disallowNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#disallownewlineafterdescription) |
26-
| [`require-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description) | N/A |
27-
| [`require-description-complete-sentence`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence) | [`requireDescriptionCompleteSentence`](https://github.com/jscs-dev/jscs-jsdoc#requiredescriptioncompletesentence) |
28-
| [`require-example`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-example) | N/A |
29-
| [`require-hyphen-before-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description) | [`requireHyphenBeforeDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirehyphenbeforedescription) |
30-
| [`require-param`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param) | [`checkParamExistence`](https://github.com/jscs-dev/jscs-jsdoc#checkparamexistence) |
31-
| [`require-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-description) | [`requireParamDescription`](https://github.com/jscs-dev/jscs-jsdoc#requireparamdescription) |
32-
| [`require-param-name`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-name) | N/A |
33-
| [`require-param-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type) | [`requireParamTypes`](https://github.com/jscs-dev/jscs-jsdoc#requireparamtypes) |
34-
| [`require-returns`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns) | [`requireReturn`](https://github.com/jscs-dev/jscs-jsdoc#requirereturn) |
35-
| [`require-returns-check`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check) | [`requireReturn`](https://github.com/jscs-dev/jscs-jsdoc#requirereturncheck) |
36-
| [`require-returns-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-description) | [`requireReturnDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirereturndescription) |
37-
| [`require-returns-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type) | [`requireReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#requirereturntypes) |
38-
| [`valid-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types) | N/A |
39-
| [`no-undefined-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-undefined-types) | N/A |
40-
| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |
41-
| N/A | [`checkRedundantParams`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantparams) |
42-
| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |
43-
| N/A | [`checkRedundantAccess`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantaccess) |
44-
| N/A | [`enforceExistence`](https://github.com/jscs-dev/jscs-jsdoc#enforceexistence) |
45-
| N/A | [`leadingUnderscoreAccess`](https://github.com/jscs-dev/jscs-jsdoc#leadingunderscoreaccess) |
46-
4712
## Installation
4813

4914
Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally.

.README/rules/check-examples.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.
44

5-
### Options
5+
#### Options
66

77
The options below all default to no-op/`false` except as noted.
88

9-
#### `captionRequired`
9+
##### `captionRequired`
1010

1111
JSDoc specs use of an optional `<caption>` element at the beginning of
1212
`@example`.
1313

1414
The option `captionRequired` insists on a `<caption>` being present at
1515
the beginning of any `@example`.
1616

17-
#### `exampleCodeRegex` and `rejectExampleCodeRegex`
17+
##### `exampleCodeRegex` and `rejectExampleCodeRegex`
1818

1919
JSDoc does not specify a formal means for delimiting code blocks within
2020
`@example` (it uses generic syntax highlighting techniques for its own
@@ -37,7 +37,7 @@ If neither is in use, all examples will be matched. Note also that even if
3737
`captionRequired` is not set, any initial `<caption>` will be stripped out
3838
before doing the regex matching.
3939

40-
#### `paddedIndent`
40+
##### `paddedIndent`
4141

4242
This integer property allows one to add a fixed amount of whitespace at the
4343
beginning of the second or later lines of the example to be stripped so as
@@ -55,7 +55,7 @@ out before evaluation.
5555
*/
5656
```
5757

58-
#### `reportUnusedDisableDirectives`
58+
##### `reportUnusedDisableDirectives`
5959

6060
If not set to `false`, `reportUnusedDisableDirectives` will report disabled
6161
directives which are not used (and thus not needed). Defaults to `true`.

README.md

Lines changed: 60 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
JSDoc linting rules for ESLint.
1010

1111
* [eslint-plugin-jsdoc](#eslint-plugin-jsdoc)
12-
* [Reference to jscs-jsdoc](#eslint-plugin-jsdoc-reference-to-jscs-jsdoc)
1312
* [Installation](#eslint-plugin-jsdoc-installation)
1413
* [Configuration](#eslint-plugin-jsdoc-configuration)
1514
* [Settings](#eslint-plugin-jsdoc-settings)
@@ -20,7 +19,6 @@ JSDoc linting rules for ESLint.
2019
* [Rules](#eslint-plugin-jsdoc-rules)
2120
* [`check-alignment`](#eslint-plugin-jsdoc-rules-check-alignment)
2221
* [`check-examples`](#eslint-plugin-jsdoc-rules-check-examples)
23-
* [Options](#eslint-plugin-jsdoc-rules-options)
2422
* [`check-indentation`](#eslint-plugin-jsdoc-rules-check-indentation)
2523
* [`check-param-names`](#eslint-plugin-jsdoc-rules-check-param-names)
2624
* [`check-syntax`](#eslint-plugin-jsdoc-rules-check-syntax)
@@ -47,42 +45,6 @@ JSDoc linting rules for ESLint.
4745
* [`valid-types`](#eslint-plugin-jsdoc-rules-valid-types)
4846

4947

50-
<a name="eslint-plugin-jsdoc-reference-to-jscs-jsdoc"></a>
51-
### Reference to jscs-jsdoc
52-
53-
This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
54-
55-
| `eslint-plugin-jsdoc` | `jscs-jsdoc` |
56-
| --- | --- |
57-
| [`check-alignment`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-alignment) | N/A |
58-
| [`check-examples`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-examples) | N/A |
59-
| [`check-indentation`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-indentation) | N/A |
60-
| [`check-param-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-param-names) | [`checkParamNames`](https://github.com/jscs-dev/jscs-jsdoc#checkparamnames) |
61-
| [`check-syntax`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-syntax) | N/A |
62-
| [`check-tag-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-tag-names) | N/A ~ [`checkAnnotations`](https://github.com/jscs-dev/jscs-jsdoc#checkannotations) |
63-
| [`check-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-types) | [`checkTypes`](https://github.com/jscs-dev/jscs-jsdoc#checktypes) |
64-
| [`newline-after-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description) | [`requireNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirenewlineafterdescription) and [`disallowNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#disallownewlineafterdescription) |
65-
| [`require-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description) | N/A |
66-
| [`require-description-complete-sentence`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence) | [`requireDescriptionCompleteSentence`](https://github.com/jscs-dev/jscs-jsdoc#requiredescriptioncompletesentence) |
67-
| [`require-example`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-example) | N/A |
68-
| [`require-hyphen-before-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description) | [`requireHyphenBeforeDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirehyphenbeforedescription) |
69-
| [`require-param`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param) | [`checkParamExistence`](https://github.com/jscs-dev/jscs-jsdoc#checkparamexistence) |
70-
| [`require-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-description) | [`requireParamDescription`](https://github.com/jscs-dev/jscs-jsdoc#requireparamdescription) |
71-
| [`require-param-name`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-name) | N/A |
72-
| [`require-param-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type) | [`requireParamTypes`](https://github.com/jscs-dev/jscs-jsdoc#requireparamtypes) |
73-
| [`require-returns`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns) | [`requireReturn`](https://github.com/jscs-dev/jscs-jsdoc#requirereturn) |
74-
| [`require-returns-check`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check) | [`requireReturn`](https://github.com/jscs-dev/jscs-jsdoc#requirereturncheck) |
75-
| [`require-returns-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-description) | [`requireReturnDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirereturndescription) |
76-
| [`require-returns-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type) | [`requireReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#requirereturntypes) |
77-
| [`valid-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types) | N/A |
78-
| [`no-undefined-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-undefined-types) | N/A |
79-
| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |
80-
| N/A | [`checkRedundantParams`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantparams) |
81-
| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |
82-
| N/A | [`checkRedundantAccess`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantaccess) |
83-
| N/A | [`enforceExistence`](https://github.com/jscs-dev/jscs-jsdoc#enforceexistence) |
84-
| N/A | [`leadingUnderscoreAccess`](https://github.com/jscs-dev/jscs-jsdoc#leadingunderscoreaccess) |
85-
8648
<a name="eslint-plugin-jsdoc-installation"></a>
8749
## Installation
8850

@@ -464,22 +426,22 @@ function quux (foo) {}
464426

465427
Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.
466428

467-
<a name="eslint-plugin-jsdoc-rules-options"></a>
468-
### Options
429+
<a name="eslint-plugin-jsdoc-rules-check-examples-options"></a>
430+
#### Options
469431

470432
The options below all default to no-op/`false` except as noted.
471433

472-
<a name="eslint-plugin-jsdoc-rules-options-captionrequired"></a>
473-
#### <code>captionRequired</code>
434+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-captionrequired"></a>
435+
##### <code>captionRequired</code>
474436

475437
JSDoc specs use of an optional `<caption>` element at the beginning of
476438
`@example`.
477439

478440
The option `captionRequired` insists on a `<caption>` being present at
479441
the beginning of any `@example`.
480442

481-
<a name="eslint-plugin-jsdoc-rules-options-examplecoderegex-and-rejectexamplecoderegex"></a>
482-
#### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
443+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-examplecoderegex-and-rejectexamplecoderegex"></a>
444+
##### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
483445

484446
JSDoc does not specify a formal means for delimiting code blocks within
485447
`@example` (it uses generic syntax highlighting techniques for its own
@@ -502,8 +464,8 @@ If neither is in use, all examples will be matched. Note also that even if
502464
`captionRequired` is not set, any initial `<caption>` will be stripped out
503465
before doing the regex matching.
504466

505-
<a name="eslint-plugin-jsdoc-rules-options-paddedindent"></a>
506-
#### <code>paddedIndent</code>
467+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-paddedindent"></a>
468+
##### <code>paddedIndent</code>
507469

508470
This integer property allows one to add a fixed amount of whitespace at the
509471
beginning of the second or later lines of the example to be stripped so as
@@ -521,8 +483,8 @@ out before evaluation.
521483
*/
522484
```
523485

524-
<a name="eslint-plugin-jsdoc-rules-options-reportunuseddisabledirectives"></a>
525-
#### <code>reportUnusedDisableDirectives</code>
486+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-reportunuseddisabledirectives"></a>
487+
##### <code>reportUnusedDisableDirectives</code>
526488

527489
If not set to `false`, `reportUnusedDisableDirectives` will report disabled
528490
directives which are not used (and thus not needed). Defaults to `true`.
@@ -533,7 +495,7 @@ disabling of ESLint directives which are not needed by the resolved rules
533495
will be reported as with the ESLint `--report-unused-disable-directives`
534496
command.
535497

536-
<a name="eslint-plugin-jsdoc-rules-options-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig"></a>
498+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig"></a>
537499
#### Options for Determining ESLint Rule Applicability (<code>allowInlineConfig</code>, <code>noDefaultExampleRules</code>, <code>matchingFileName</code>, <code>configFile</code>, <code>eslintrcForExamples</code>, and <code>baseConfig</code>)
538500

539501
The following options determine which individual ESLint rules will be
@@ -564,7 +526,7 @@ decreasing precedence:
564526
* `baseConfig` - An object of rules with the same schema
565527
as `.eslintrc.*` for defaults
566528

567-
<a name="eslint-plugin-jsdoc-rules-options-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
529+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
568530
##### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
569531

570532
* `eol-last` - Insisting that a newline "always" be at the end is less likely
@@ -5812,6 +5774,30 @@ function quux (foo) {
58125774
}
58135775
// Message: Missing JSDoc @param "foo" declaration.
58145776

5777+
/**
5778+
*
5779+
*/
5780+
function quux (foo, bar) {
5781+
5782+
}
5783+
// Message: Missing JSDoc @param "foo" declaration.
5784+
5785+
/**
5786+
* @param bar
5787+
*/
5788+
function quux (foo, bar, baz) {
5789+
5790+
}
5791+
// Message: Missing JSDoc @param "foo" declaration.
5792+
5793+
/**
5794+
* @param baz
5795+
*/
5796+
function quux (foo, bar, baz) {
5797+
5798+
}
5799+
// Message: Missing JSDoc @param "foo" declaration.
5800+
58155801
/**
58165802
* @param
58175803
*/
@@ -7295,31 +7281,31 @@ function quux() {
72957281
// Message: Tag @callback must have a namepath
72967282

72977283
/**
7298-
* @constant {str%ng}
7299-
*/
7300-
const FOO = 'foo';
7284+
* @constant {str%ng}
7285+
*/
7286+
const FOO = 'foo';
73017287
// Message: Syntax error in type: str%ng
73027288

73037289
/**
7304-
* @typedef {str%ng} UserString
7305-
*/
7290+
* @typedef {str%ng} UserString
7291+
*/
73067292
// Message: Syntax error in type: str%ng
73077293

73087294
/**
7309-
* @typedef {string} UserStr%ng
7310-
*/
7295+
* @typedef {string} UserStr%ng
7296+
*/
73117297
// Message: Syntax error in type: UserStr%ng
73127298

73137299
/**
7314-
* @extends
7315-
*/
7316-
class Bar {};
7300+
* @extends
7301+
*/
7302+
class Bar {};
73177303
// Message: Tag @extends must have either a type or namepath
73187304

73197305
/**
7320-
* @type
7321-
*/
7322-
let foo;
7306+
* @type
7307+
*/
7308+
let foo;
73237309
// Message: Tag @type must have a type
73247310
````
73257311

@@ -7419,23 +7405,23 @@ function quux() {
74197405
}
74207406

74217407
/**
7422-
* @constant {string}
7423-
*/
7424-
const FOO = 'foo';
7408+
* @constant {string}
7409+
*/
7410+
const FOO = 'foo';
74257411

74267412
/**
7427-
* @extends Foo
7428-
*/
7429-
class Bar {};
7413+
* @extends Foo
7414+
*/
7415+
class Bar {};
74307416

74317417
/**
7432-
* @extends {Foo<String>}
7433-
*/
7434-
class Bar {};
7418+
* @extends {Foo<String>}
7419+
*/
7420+
class Bar {};
74357421

74367422
/**
7437-
* @typedef {number|string} UserDefinedType
7438-
*/
7423+
* @typedef {number|string} UserDefinedType
7424+
*/
74397425

74407426
/**
74417427
* @typedef {number|string}

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"comment-parser": "^0.6.0",
8+
"comment-parser": "^0.6.1",
99
"debug": "^4.1.1",
1010
"flat-map-polyfill": "^0.3.8",
1111
"jsdoctypeparser": "5.0.1",
12-
"lodash": "^4.17.14",
12+
"lodash": "^4.17.15",
13+
"object.entries-ponyfill": "^1.0.1",
1314
"regextras": "^0.6.1"
1415
},
1516
"description": "JSDoc linting rules for ESLint.",
1617
"devDependencies": {
17-
"@babel/cli": "^7.5.0",
18-
"@babel/core": "^7.5.4",
19-
"@babel/node": "^7.5.0",
18+
"@babel/cli": "^7.5.5",
19+
"@babel/core": "^7.5.5",
20+
"@babel/node": "^7.5.5",
2021
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
21-
"@babel/preset-env": "^7.5.4",
22-
"@babel/register": "^7.4.4",
22+
"@babel/preset-env": "^7.5.5",
23+
"@babel/register": "^7.5.5",
2324
"@typescript-eslint/parser": "^1.12.0",
2425
"babel-eslint": "^10.0.2",
2526
"babel-plugin-add-module-exports": "^1.0.2",
@@ -29,8 +30,8 @@
2930
"eslint-config-canonical": "^17.1.4",
3031
"gitdown": "^3.1.1",
3132
"glob": "^7.1.4",
32-
"husky": "^3.0.0",
33-
"mocha": "^6.1.4",
33+
"husky": "^3.0.1",
34+
"mocha": "^6.2.0",
3435
"nyc": "^14.1.1",
3536
"semantic-release": "^15.13.18",
3637
"typescript": "^3.5.3"

src/iterateJsdoc.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// eslint-disable-next-line import/no-named-default
2+
import {default as commentParser, stringify as commentStringify} from 'comment-parser';
13
import _ from 'lodash';
2-
import commentParser from 'comment-parser';
34
import jsdocUtils from './jsdocUtils';
45
import getJSDocComment from './eslint/getJSDocComment';
56

@@ -87,6 +88,23 @@ const getUtils = (
8788

8889
const utils = {};
8990

91+
utils.stringify = (tagBlock) => {
92+
let indent = sourceCode.text.match(/^\n*([ \t]+)/);
93+
/* istanbul ignore next */
94+
indent = indent ? indent[1] + indent[1].charAt() : ' ';
95+
96+
return commentStringify([tagBlock], {indent}).slice(indent.length - 1);
97+
};
98+
99+
utils.reportJSDoc = (msg, tag, handler) => {
100+
report(msg, (fixer) => {
101+
handler();
102+
const replacement = utils.stringify(jsdoc);
103+
104+
return fixer.replaceText(jsdocNode, replacement);
105+
}, tag);
106+
};
107+
90108
utils.getFunctionParameterNames = () => {
91109
return jsdocUtils.getFunctionParameterNames(node);
92110
};

0 commit comments

Comments
 (0)