eslint-plugin-jsdoc 46.4.6 → 46.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/package.json +14 -12
- package/dist/WarnSettings.d.ts +0 -17
- package/dist/WarnSettings.d.ts.map +0 -1
- package/dist/alignTransform.d.ts +0 -32
- package/dist/alignTransform.d.ts.map +0 -1
- package/dist/defaultTagOrder.d.ts +0 -5
- package/dist/defaultTagOrder.d.ts.map +0 -1
- package/dist/exportParser.d.ts +0 -41
- package/dist/exportParser.d.ts.map +0 -1
- package/dist/getDefaultTagStructureForMode.d.ts +0 -11
- package/dist/getDefaultTagStructureForMode.d.ts.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/iterateJsdoc.d.ts +0 -460
- package/dist/iterateJsdoc.d.ts.map +0 -1
- package/dist/jsdocUtils.d.ts +0 -421
- package/dist/jsdocUtils.d.ts.map +0 -1
- package/dist/rules/checkAccess.d.ts +0 -3
- package/dist/rules/checkAccess.d.ts.map +0 -1
- package/dist/rules/checkAlignment.d.ts +0 -3
- package/dist/rules/checkAlignment.d.ts.map +0 -1
- package/dist/rules/checkExamples.d.ts +0 -4
- package/dist/rules/checkExamples.d.ts.map +0 -1
- package/dist/rules/checkIndentation.d.ts +0 -3
- package/dist/rules/checkIndentation.d.ts.map +0 -1
- package/dist/rules/checkLineAlignment.d.ts +0 -10
- package/dist/rules/checkLineAlignment.d.ts.map +0 -1
- package/dist/rules/checkParamNames.d.ts +0 -3
- package/dist/rules/checkParamNames.d.ts.map +0 -1
- package/dist/rules/checkPropertyNames.d.ts +0 -3
- package/dist/rules/checkPropertyNames.d.ts.map +0 -1
- package/dist/rules/checkSyntax.d.ts +0 -3
- package/dist/rules/checkSyntax.d.ts.map +0 -1
- package/dist/rules/checkTagNames.d.ts +0 -3
- package/dist/rules/checkTagNames.d.ts.map +0 -1
- package/dist/rules/checkTypes.d.ts +0 -3
- package/dist/rules/checkTypes.d.ts.map +0 -1
- package/dist/rules/checkValues.d.ts +0 -3
- package/dist/rules/checkValues.d.ts.map +0 -1
- package/dist/rules/emptyTags.d.ts +0 -3
- package/dist/rules/emptyTags.d.ts.map +0 -1
- package/dist/rules/implementsOnClasses.d.ts +0 -3
- package/dist/rules/implementsOnClasses.d.ts.map +0 -1
- package/dist/rules/importsAsDependencies.d.ts +0 -3
- package/dist/rules/importsAsDependencies.d.ts.map +0 -1
- package/dist/rules/informativeDocs.d.ts +0 -3
- package/dist/rules/informativeDocs.d.ts.map +0 -1
- package/dist/rules/matchDescription.d.ts +0 -3
- package/dist/rules/matchDescription.d.ts.map +0 -1
- package/dist/rules/matchName.d.ts +0 -3
- package/dist/rules/matchName.d.ts.map +0 -1
- package/dist/rules/multilineBlocks.d.ts +0 -3
- package/dist/rules/multilineBlocks.d.ts.map +0 -1
- package/dist/rules/noBadBlocks.d.ts +0 -3
- package/dist/rules/noBadBlocks.d.ts.map +0 -1
- package/dist/rules/noBlankBlockDescriptions.d.ts +0 -3
- package/dist/rules/noBlankBlockDescriptions.d.ts.map +0 -1
- package/dist/rules/noBlankBlocks.d.ts +0 -3
- package/dist/rules/noBlankBlocks.d.ts.map +0 -1
- package/dist/rules/noDefaults.d.ts +0 -3
- package/dist/rules/noDefaults.d.ts.map +0 -1
- package/dist/rules/noMissingSyntax.d.ts +0 -10
- package/dist/rules/noMissingSyntax.d.ts.map +0 -1
- package/dist/rules/noMultiAsterisks.d.ts +0 -3
- package/dist/rules/noMultiAsterisks.d.ts.map +0 -1
- package/dist/rules/noRestrictedSyntax.d.ts +0 -3
- package/dist/rules/noRestrictedSyntax.d.ts.map +0 -1
- package/dist/rules/noTypes.d.ts +0 -3
- package/dist/rules/noTypes.d.ts.map +0 -1
- package/dist/rules/noUndefinedTypes.d.ts +0 -3
- package/dist/rules/noUndefinedTypes.d.ts.map +0 -1
- package/dist/rules/requireAsteriskPrefix.d.ts +0 -3
- package/dist/rules/requireAsteriskPrefix.d.ts.map +0 -1
- package/dist/rules/requireDescription.d.ts +0 -3
- package/dist/rules/requireDescription.d.ts.map +0 -1
- package/dist/rules/requireDescriptionCompleteSentence.d.ts +0 -3
- package/dist/rules/requireDescriptionCompleteSentence.d.ts.map +0 -1
- package/dist/rules/requireExample.d.ts +0 -3
- package/dist/rules/requireExample.d.ts.map +0 -1
- package/dist/rules/requireFileOverview.d.ts +0 -3
- package/dist/rules/requireFileOverview.d.ts.map +0 -1
- package/dist/rules/requireHyphenBeforeParamDescription.d.ts +0 -3
- package/dist/rules/requireHyphenBeforeParamDescription.d.ts.map +0 -1
- package/dist/rules/requireJsdoc.d.ts +0 -9
- package/dist/rules/requireJsdoc.d.ts.map +0 -1
- package/dist/rules/requireParam.d.ts +0 -4
- package/dist/rules/requireParam.d.ts.map +0 -1
- package/dist/rules/requireParamDescription.d.ts +0 -3
- package/dist/rules/requireParamDescription.d.ts.map +0 -1
- package/dist/rules/requireParamName.d.ts +0 -3
- package/dist/rules/requireParamName.d.ts.map +0 -1
- package/dist/rules/requireParamType.d.ts +0 -3
- package/dist/rules/requireParamType.d.ts.map +0 -1
- package/dist/rules/requireProperty.d.ts +0 -3
- package/dist/rules/requireProperty.d.ts.map +0 -1
- package/dist/rules/requirePropertyDescription.d.ts +0 -3
- package/dist/rules/requirePropertyDescription.d.ts.map +0 -1
- package/dist/rules/requirePropertyName.d.ts +0 -3
- package/dist/rules/requirePropertyName.d.ts.map +0 -1
- package/dist/rules/requirePropertyType.d.ts +0 -3
- package/dist/rules/requirePropertyType.d.ts.map +0 -1
- package/dist/rules/requireReturns.d.ts +0 -3
- package/dist/rules/requireReturns.d.ts.map +0 -1
- package/dist/rules/requireReturnsCheck.d.ts +0 -3
- package/dist/rules/requireReturnsCheck.d.ts.map +0 -1
- package/dist/rules/requireReturnsDescription.d.ts +0 -3
- package/dist/rules/requireReturnsDescription.d.ts.map +0 -1
- package/dist/rules/requireReturnsType.d.ts +0 -3
- package/dist/rules/requireReturnsType.d.ts.map +0 -1
- package/dist/rules/requireThrows.d.ts +0 -3
- package/dist/rules/requireThrows.d.ts.map +0 -1
- package/dist/rules/requireYields.d.ts +0 -3
- package/dist/rules/requireYields.d.ts.map +0 -1
- package/dist/rules/requireYieldsCheck.d.ts +0 -3
- package/dist/rules/requireYieldsCheck.d.ts.map +0 -1
- package/dist/rules/sortTags.d.ts +0 -3
- package/dist/rules/sortTags.d.ts.map +0 -1
- package/dist/rules/tagLines.d.ts +0 -3
- package/dist/rules/tagLines.d.ts.map +0 -1
- package/dist/rules/textEscaping.d.ts +0 -3
- package/dist/rules/textEscaping.d.ts.map +0 -1
- package/dist/rules/validTypes.d.ts +0 -3
- package/dist/rules/validTypes.d.ts.map +0 -1
- package/dist/tagNames.d.ts +0 -16
- package/dist/tagNames.d.ts.map +0 -1
- package/dist/utils/hasReturnValue.d.ts +0 -20
- package/dist/utils/hasReturnValue.d.ts.map +0 -1
- package/docs/advanced.md +0 -102
- package/docs/rules/check-access.md +0 -193
- package/docs/rules/check-alignment.md +0 -169
- package/docs/rules/check-examples.md +0 -784
- package/docs/rules/check-indentation.md +0 -296
- package/docs/rules/check-line-alignment.md +0 -1002
- package/docs/rules/check-param-names.md +0 -1035
- package/docs/rules/check-property-names.md +0 -244
- package/docs/rules/check-syntax.md +0 -80
- package/docs/rules/check-tag-names.md +0 -1132
- package/docs/rules/check-types.md +0 -1198
- package/docs/rules/check-values.md +0 -409
- package/docs/rules/empty-tags.md +0 -220
- package/docs/rules/implements-on-classes.md +0 -219
- package/docs/rules/imports-as-dependencies.md +0 -99
- package/docs/rules/informative-docs.md +0 -400
- package/docs/rules/match-description.md +0 -1008
- package/docs/rules/match-name.md +0 -249
- package/docs/rules/multiline-blocks.md +0 -398
- package/docs/rules/no-bad-blocks.md +0 -174
- package/docs/rules/no-blank-block-descriptions.md +0 -91
- package/docs/rules/no-blank-blocks.md +0 -98
- package/docs/rules/no-defaults.md +0 -207
- package/docs/rules/no-missing-syntax.md +0 -275
- package/docs/rules/no-multi-asterisks.md +0 -278
- package/docs/rules/no-restricted-syntax.md +0 -383
- package/docs/rules/no-types.md +0 -168
- package/docs/rules/no-undefined-types.md +0 -789
- package/docs/rules/require-asterisk-prefix.md +0 -297
- package/docs/rules/require-description-complete-sentence.md +0 -820
- package/docs/rules/require-description.md +0 -585
- package/docs/rules/require-example.md +0 -390
- package/docs/rules/require-file-overview.md +0 -324
- package/docs/rules/require-hyphen-before-param-description.md +0 -281
- package/docs/rules/require-jsdoc.md +0 -1857
- package/docs/rules/require-param-description.md +0 -238
- package/docs/rules/require-param-name.md +0 -163
- package/docs/rules/require-param-type.md +0 -227
- package/docs/rules/require-param.md +0 -1820
- package/docs/rules/require-property-description.md +0 -88
- package/docs/rules/require-property-name.md +0 -79
- package/docs/rules/require-property-type.md +0 -79
- package/docs/rules/require-property.md +0 -128
- package/docs/rules/require-returns-check.md +0 -1053
- package/docs/rules/require-returns-description.md +0 -181
- package/docs/rules/require-returns-type.md +0 -144
- package/docs/rules/require-returns.md +0 -1191
- package/docs/rules/require-throws.md +0 -326
- package/docs/rules/require-yields-check.md +0 -544
- package/docs/rules/require-yields.md +0 -823
- package/docs/rules/sort-tags.md +0 -635
- package/docs/rules/tag-lines.md +0 -551
- package/docs/rules/text-escaping.md +0 -177
- package/docs/rules/valid-types.md +0 -881
- package/docs/settings.md +0 -362
- package/tsconfig-prod.json +0 -20
- package/tsconfig.json +0 -21
|
@@ -1,784 +0,0 @@
|
|
|
1
|
-
<a name="user-content-check-examples"></a>
|
|
2
|
-
<a name="check-examples"></a>
|
|
3
|
-
# <code>check-examples</code>
|
|
4
|
-
|
|
5
|
-
* [Options](#user-content-check-examples-options)
|
|
6
|
-
* [`captionRequired`](#user-content-check-examples-options-captionrequired)
|
|
7
|
-
* [`exampleCodeRegex` and `rejectExampleCodeRegex`](#user-content-check-examples-options-examplecoderegex-and-rejectexamplecoderegex)
|
|
8
|
-
* [`paddedIndent`](#user-content-check-examples-options-paddedindent)
|
|
9
|
-
* [`reportUnusedDisableDirectives`](#user-content-check-examples-options-reportunuseddisabledirectives)
|
|
10
|
-
* [Options for Determining ESLint Rule Applicability (`allowInlineConfig`, `noDefaultExampleRules`, `matchingFileName`, `configFile`, `checkEslintrc`, and `baseConfig`)](#user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig)
|
|
11
|
-
* [Rules Disabled by Default Unless `noDefaultExampleRules` is Set to `true`](#user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true)
|
|
12
|
-
* [Options for checking other than `@example` (`checkDefaults`, `checkParams`, or `checkProperties`)](#user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-options-for-checking-other-than-example-checkdefaults-checkparams-or-checkproperties)
|
|
13
|
-
* [Context and settings](#user-content-check-examples-context-and-settings)
|
|
14
|
-
* [Failing examples](#user-content-check-examples-failing-examples)
|
|
15
|
-
* [Passing examples](#user-content-check-examples-passing-examples)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
> **NOTE**: This rule currently does not work in ESLint 8 (we are waiting for
|
|
19
|
-
> [issue 14745](https://github.com/eslint/eslint/issues/14745)).
|
|
20
|
-
|
|
21
|
-
Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules. Also
|
|
22
|
-
has options to lint the default values of optional `@param`/`@arg`/`@argument`
|
|
23
|
-
and `@property`/`@prop` tags or the values of `@default`/`@defaultvalue` tags.
|
|
24
|
-
|
|
25
|
-
<a name="user-content-check-examples-options"></a>
|
|
26
|
-
<a name="check-examples-options"></a>
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
The options below all default to no-op/`false` except as noted.
|
|
30
|
-
|
|
31
|
-
<a name="user-content-check-examples-options-captionrequired"></a>
|
|
32
|
-
<a name="check-examples-options-captionrequired"></a>
|
|
33
|
-
### <code>captionRequired</code>
|
|
34
|
-
|
|
35
|
-
JSDoc specs use of an optional `<caption>` element at the beginning of
|
|
36
|
-
`@example`.
|
|
37
|
-
|
|
38
|
-
The option `captionRequired` insists on a `<caption>` being present at
|
|
39
|
-
the beginning of any `@example`.
|
|
40
|
-
|
|
41
|
-
Used only for `@example`.
|
|
42
|
-
|
|
43
|
-
<a name="user-content-check-examples-options-examplecoderegex-and-rejectexamplecoderegex"></a>
|
|
44
|
-
<a name="check-examples-options-examplecoderegex-and-rejectexamplecoderegex"></a>
|
|
45
|
-
### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
|
|
46
|
-
|
|
47
|
-
JSDoc does not specify a formal means for delimiting code blocks within
|
|
48
|
-
`@example` (it uses generic syntax highlighting techniques for its own
|
|
49
|
-
syntax highlighting). The following options determine whether a given
|
|
50
|
-
`@example` tag will have the `check-examples` checks applied to it:
|
|
51
|
-
|
|
52
|
-
* `exampleCodeRegex` - Regex which whitelists lintable
|
|
53
|
-
examples. If a parenthetical group is used, the first one will be used,
|
|
54
|
-
so you may wish to use `(?:...)` groups where you do not wish the
|
|
55
|
-
first such group treated as one to include. If no parenthetical group
|
|
56
|
-
exists or matches, the whole matching expression will be used.
|
|
57
|
-
An example might be ````"^```(?:js|javascript)([\\s\\S]*)```\s*$"````
|
|
58
|
-
to only match explicitly fenced JavaScript blocks. Defaults to only
|
|
59
|
-
using the `u` flag, so to add your own flags, encapsulate your
|
|
60
|
-
expression as a string, but like a literal, e.g., ````/```js.*```/gi````.
|
|
61
|
-
Note that specifying a global regular expression (i.e., with `g`) will
|
|
62
|
-
allow independent linting of matched blocks within a single `@example`.
|
|
63
|
-
* `rejectExampleCodeRegex` - Regex blacklist which rejects
|
|
64
|
-
non-lintable examples (has priority over `exampleCodeRegex`). An example
|
|
65
|
-
might be ```"^`"``` to avoid linting fenced blocks which may indicate
|
|
66
|
-
a non-JavaScript language. See `exampleCodeRegex` on how to add flags
|
|
67
|
-
if the default `u` is not sufficient.
|
|
68
|
-
|
|
69
|
-
If neither is in use, all examples will be matched. Note also that even if
|
|
70
|
-
`captionRequired` is not set, any initial `<caption>` will be stripped out
|
|
71
|
-
before doing the regex matching.
|
|
72
|
-
|
|
73
|
-
<a name="user-content-check-examples-options-paddedindent"></a>
|
|
74
|
-
<a name="check-examples-options-paddedindent"></a>
|
|
75
|
-
### <code>paddedIndent</code>
|
|
76
|
-
|
|
77
|
-
This integer property allows one to add a fixed amount of whitespace at the
|
|
78
|
-
beginning of the second or later lines of the example to be stripped so as
|
|
79
|
-
to avoid linting issues with the decorative whitespace. For example, if set
|
|
80
|
-
to a value of `4`, the initial whitespace below will not trigger `indent`
|
|
81
|
-
rule errors as the extra 4 spaces on each subsequent line will be stripped
|
|
82
|
-
out before evaluation.
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
/**
|
|
86
|
-
* @example
|
|
87
|
-
* anArray.filter((a) => {
|
|
88
|
-
* return a.b;
|
|
89
|
-
* });
|
|
90
|
-
*/
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Only applied to `@example` linting.
|
|
94
|
-
|
|
95
|
-
<a name="user-content-check-examples-options-reportunuseddisabledirectives"></a>
|
|
96
|
-
<a name="check-examples-options-reportunuseddisabledirectives"></a>
|
|
97
|
-
### <code>reportUnusedDisableDirectives</code>
|
|
98
|
-
|
|
99
|
-
If not set to `false`, `reportUnusedDisableDirectives` will report disabled
|
|
100
|
-
directives which are not used (and thus not needed). Defaults to `true`.
|
|
101
|
-
Corresponds to ESLint's [`--report-unused-disable-directives`](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives).
|
|
102
|
-
|
|
103
|
-
Inline ESLint config within `@example` JavaScript is allowed (or within
|
|
104
|
-
`@default`, etc.), though the disabling of ESLint directives which are not
|
|
105
|
-
needed by the resolved rules will be reported as with the ESLint
|
|
106
|
-
`--report-unused-disable-directives` command.
|
|
107
|
-
|
|
108
|
-
<a name="user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig"></a>
|
|
109
|
-
<a name="check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig"></a>
|
|
110
|
-
## Options for Determining ESLint Rule Applicability (<code>allowInlineConfig</code>, <code>noDefaultExampleRules</code>, <code>matchingFileName</code>, <code>configFile</code>, <code>checkEslintrc</code>, and <code>baseConfig</code>)
|
|
111
|
-
|
|
112
|
-
The following options determine which individual ESLint rules will be
|
|
113
|
-
applied to the JavaScript found within the `@example` tags (as determined
|
|
114
|
-
to be applicable by the above regex options) or for the other tags checked by
|
|
115
|
-
`checkDefaults`, `checkParams`, or `checkProperties` options. They are ordered
|
|
116
|
-
by decreasing precedence:
|
|
117
|
-
|
|
118
|
-
* `allowInlineConfig` - If not set to `false`, will allow
|
|
119
|
-
inline config within the `@example` to override other config. Defaults
|
|
120
|
-
to `true`.
|
|
121
|
-
* `noDefaultExampleRules` - Setting to `true` will disable the
|
|
122
|
-
default rules which are expected to be troublesome for most documentation
|
|
123
|
-
use. See the section below for the specific default rules.
|
|
124
|
-
* `configFile` - A config file. Corresponds to ESLint's [`-c`](https://eslint.org/docs/user-guide/command-line-interface#-c---config).
|
|
125
|
-
* `matchingFileName` - Option for a file name (even non-existent) to trigger
|
|
126
|
-
specific rules defined in one's config; usable with ESLint `.eslintrc.*`
|
|
127
|
-
`overrides` -> `files` globs, to apply a desired subset of rules with
|
|
128
|
-
`@example` (besides allowing for rules specific to examples, this option
|
|
129
|
-
can be useful for enabling reuse of the same rules within `@example` as
|
|
130
|
-
with JavaScript Markdown lintable by
|
|
131
|
-
[other plugins](https://github.com/eslint/eslint-plugin-markdown), e.g.,
|
|
132
|
-
if one sets `matchingFileName` to `dummy.md/*.js` so that `@example`
|
|
133
|
-
rules will follow rules for fenced JavaScript blocks within one's Markdown
|
|
134
|
-
rules). (In ESLint 6's processor API and `eslint-plugin-markdown` < 2, one
|
|
135
|
-
would instead use `dummy.md`.) For `@example` only.
|
|
136
|
-
* `matchingFileNameDefaults` - As with `matchingFileName` but for use with
|
|
137
|
-
`checkDefaults` and defaulting to `.jsdoc-defaults` as extension.
|
|
138
|
-
* `matchingFileNameParams` - As with `matchingFileName` but for use with
|
|
139
|
-
`checkParams` and defaulting to `.jsdoc-params` as extension.
|
|
140
|
-
* `matchingFileNameProperties` As with `matchingFileName` but for use with
|
|
141
|
-
`checkProperties` and defaulting to `.jsdoc-properties` as extension.
|
|
142
|
-
* `checkEslintrc` - Defaults to `true` in adding rules
|
|
143
|
-
based on an `.eslintrc.*` file. Setting to `false` corresponds to
|
|
144
|
-
ESLint's [`--no-eslintrc`](https://eslint.org/docs/user-guide/command-line-interface#--no-eslintrc).
|
|
145
|
-
If `matchingFileName` is set, this will automatically be `true` and
|
|
146
|
-
will use the config corresponding to that file. If `matchingFileName` is
|
|
147
|
-
not set and this value is set to `false`, the `.eslintrc.*` configs will
|
|
148
|
-
not be checked. If `matchingFileName` is not set, and this is unset or
|
|
149
|
-
set to `true`, the `.eslintrc.*` configs will be checked as though the file
|
|
150
|
-
name were the same as the file containing the example, with any file
|
|
151
|
-
extension changed to `".md/*.js"` (and if there is no file extension,
|
|
152
|
-
`"dummy.md/*.js"` will be the result). This allows convenient sharing of
|
|
153
|
-
similar rules with often also context-free Markdown as well as use of
|
|
154
|
-
`overrides` as described under `matchingFileName`. Note that this option
|
|
155
|
-
(whether set by `matchingFileName` or set manually to `true`) may come at
|
|
156
|
-
somewhat of a performance penalty as the file's existence is checked by
|
|
157
|
-
eslint.
|
|
158
|
-
* `baseConfig` - Set to an object of rules with the same schema
|
|
159
|
-
as `.eslintrc.*` for defaults.
|
|
160
|
-
|
|
161
|
-
<a name="user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
|
|
162
|
-
<a name="check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
|
|
163
|
-
### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
|
|
164
|
-
|
|
165
|
-
* `eol-last` - Insisting that a newline "always" be at the end is less likely
|
|
166
|
-
to be desired in sample code as with the code file convention.
|
|
167
|
-
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
|
|
168
|
-
within examples.
|
|
169
|
-
* `no-multiple-empty-lines` - This rule may be problematic for projects which
|
|
170
|
-
use an initial newline just to start an example. Also, projects may wish to
|
|
171
|
-
use extra lines within examples just for easier illustration
|
|
172
|
-
purposes.
|
|
173
|
-
* `no-undef` - Many variables in examples will be `undefined`.
|
|
174
|
-
* `no-unused-vars` - It is common to define variables for clarity without
|
|
175
|
-
always using them within examples.
|
|
176
|
-
* `padded-blocks` - It can generally look nicer to pad a little even if one's
|
|
177
|
-
code follows more stringency as far as block padding.
|
|
178
|
-
* `jsdoc/require-file-overview` - Shouldn't check example for jsdoc blocks.
|
|
179
|
-
* `jsdoc/require-jsdoc` - Wouldn't expect jsdoc blocks within jsdoc blocks.
|
|
180
|
-
* `import/no-unresolved` - One wouldn't generally expect example paths to
|
|
181
|
-
resolve relative to the current JavaScript file as one would with real code.
|
|
182
|
-
* `import/unambiguous` - Snippets in examples are likely too short to always
|
|
183
|
-
include full import/export info.
|
|
184
|
-
* `node/no-missing-import` - See `import/no-unresolved`.
|
|
185
|
-
* `node/no-missing-require` - See `import/no-unresolved`.
|
|
186
|
-
|
|
187
|
-
For `checkDefaults`, `checkParams`, and `checkProperties`, the following
|
|
188
|
-
expression-oriented rules will be used by default as well:
|
|
189
|
-
|
|
190
|
-
* `quotes` - Will insist on "double".
|
|
191
|
-
* `semi` - Will insist on "never".
|
|
192
|
-
* `strict` - Disabled.
|
|
193
|
-
* `no-empty-function` - Disabled.
|
|
194
|
-
* `no-new` - Disabled.
|
|
195
|
-
* `no-unused-expressions` - Disabled.
|
|
196
|
-
* `chai-friendly/no-unused-expressions` - Disabled.
|
|
197
|
-
|
|
198
|
-
<a name="user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-options-for-checking-other-than-example-checkdefaults-checkparams-or-checkproperties"></a>
|
|
199
|
-
<a name="check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-options-for-checking-other-than-example-checkdefaults-checkparams-or-checkproperties"></a>
|
|
200
|
-
### Options for checking other than <code>@example</code> (<code>checkDefaults</code>, <code>checkParams</code>, or <code>checkProperties</code>)
|
|
201
|
-
|
|
202
|
-
* `checkDefaults` - Whether to check the values of `@default`/`@defaultvalue` tags
|
|
203
|
-
* `checkParams` - Whether to check `@param`/`@arg`/`@argument` default values
|
|
204
|
-
* `checkProperties` - Whether to check `@property`/`@prop` default values
|
|
205
|
-
|
|
206
|
-
<a name="user-content-check-examples-context-and-settings"></a>
|
|
207
|
-
<a name="check-examples-context-and-settings"></a>
|
|
208
|
-
## Context and settings
|
|
209
|
-
|
|
210
|
-
|||
|
|
211
|
-
|---|---|
|
|
212
|
-
|Context|everywhere|
|
|
213
|
-
|Tags|`example`|
|
|
214
|
-
|Recommended|false|
|
|
215
|
-
|Options|`allowInlineConfig`, `baseConfig`, `captionRequired`, `checkDefaults`, `checkEslintrc`, `checkParams`, `checkProperties`, `configFile`, `exampleCodeRegex`, `matchingFileName`, `matchingFileNameDefaults`, `matchingFileNameParams`, `matchingFileNameProperties`, `noDefaultExampleRules`, `paddedIndent`, `rejectExampleCodeRegex`, `reportUnusedDisableDirectives`|
|
|
216
|
-
|
|
217
|
-
<a name="user-content-check-examples-failing-examples"></a>
|
|
218
|
-
<a name="check-examples-failing-examples"></a>
|
|
219
|
-
## Failing examples
|
|
220
|
-
|
|
221
|
-
The following patterns are considered problems:
|
|
222
|
-
|
|
223
|
-
````js
|
|
224
|
-
/**
|
|
225
|
-
* @example alert('hello')
|
|
226
|
-
*/
|
|
227
|
-
function quux () {
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc":false}]
|
|
231
|
-
// Message: @example error (no-alert): Unexpected alert.
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @example alert('hello')
|
|
235
|
-
*/
|
|
236
|
-
class quux {
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc":false}]
|
|
240
|
-
// Message: @example error (no-alert): Unexpected alert.
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* @example ```js
|
|
244
|
-
alert('hello');
|
|
245
|
-
```
|
|
246
|
-
*/
|
|
247
|
-
function quux () {
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
|
|
251
|
-
// Message: @example error (semi): Extra semicolon.
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* @example
|
|
255
|
-
*
|
|
256
|
-
* ```js alert('hello'); ```
|
|
257
|
-
*/
|
|
258
|
-
function quux () {
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
|
|
262
|
-
// Message: @example error (semi): Extra semicolon.
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* @example
|
|
266
|
-
* ```js alert('hello'); ```
|
|
267
|
-
*/
|
|
268
|
-
var quux = {
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
|
|
272
|
-
// Message: @example error (semi): Extra semicolon.
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* @example ```
|
|
276
|
-
* js alert('hello'); ```
|
|
277
|
-
*/
|
|
278
|
-
function quux () {
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}]
|
|
282
|
-
// Message: @example error (semi): Extra semicolon.
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @example <b>Not JavaScript</b>
|
|
286
|
-
*/
|
|
287
|
-
function quux () {
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* @example quux2();
|
|
292
|
-
*/
|
|
293
|
-
function quux2 () {
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s*$"}]
|
|
297
|
-
// Message: @example error (semi): Extra semicolon.
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* @example
|
|
301
|
-
* quux(); // does something useful
|
|
302
|
-
*/
|
|
303
|
-
function quux () {
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
|
|
307
|
-
// Message: @example error (no-undef): 'quux' is not defined.
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* @example <caption>Valid usage</caption>
|
|
311
|
-
* quux(); // does something useful
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* quux('random unwanted arg'); // results in an error
|
|
315
|
-
*/
|
|
316
|
-
function quux () {
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
// "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
|
|
320
|
-
// Message: Caption is expected for examples.
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* @example quux();
|
|
324
|
-
*/
|
|
325
|
-
function quux () {
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
329
|
-
// Message: @example error (indent): Expected indentation of 0 spaces but found 1.
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* @example test() // eslint-disable-line semi
|
|
333
|
-
*/
|
|
334
|
-
function quux () {}
|
|
335
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}]
|
|
336
|
-
// Message: @example error: Unused eslint-disable directive (no problems were reported from 'semi').
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* @example
|
|
340
|
-
test() // eslint-disable-line semi
|
|
341
|
-
*/
|
|
342
|
-
function quux () {}
|
|
343
|
-
// "jsdoc/check-examples": ["error"|"warn", {"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
|
|
344
|
-
// Message: @example error (semi): Missing semicolon.
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* @example const j = 5;
|
|
348
|
-
* quux2();
|
|
349
|
-
*/
|
|
350
|
-
function quux2 () {
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
// "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"../../jsdocUtils.js"}]
|
|
354
|
-
// Message: @example warning (id-length): Identifier name 'j' is too short (< 2).
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* @example const k = 5;
|
|
358
|
-
* quux2();
|
|
359
|
-
*/
|
|
360
|
-
function quux2 () {
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
// "jsdoc/check-examples": ["error"|"warn", {"configFile":".eslintrc.json","matchingFileName":"../../jsdocUtils.js"}]
|
|
364
|
-
// Message: @example warning (id-length): Identifier name 'k' is too short (< 2).
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* @example const m = 5;
|
|
368
|
-
* quux2();
|
|
369
|
-
*/
|
|
370
|
-
function quux2 () {
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
// Message: @example warning (id-length): Identifier name 'm' is too short (< 2).
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* @example const i = 5;
|
|
377
|
-
* quux2()
|
|
378
|
-
*/
|
|
379
|
-
function quux2 () {
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
// "jsdoc/check-examples": ["error"|"warn", {"paddedIndent":2}]
|
|
383
|
-
// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* @example
|
|
387
|
-
* const i = 5;
|
|
388
|
-
* quux2()
|
|
389
|
-
*/
|
|
390
|
-
function quux2 () {
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @example const idx = 5;
|
|
397
|
-
* quux2()
|
|
398
|
-
*/
|
|
399
|
-
function quux2 () {
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
// "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"dummy.js"}]
|
|
403
|
-
// Message: @example error (semi): Missing semicolon.
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* @example const idx = 5;
|
|
407
|
-
*
|
|
408
|
-
* quux2()
|
|
409
|
-
*/
|
|
410
|
-
function quux2 () {
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
// "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"dummy.js"}]
|
|
414
|
-
// Message: @example error (semi): Missing semicolon.
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* @example const idx = 5;
|
|
418
|
-
*
|
|
419
|
-
* quux2()
|
|
420
|
-
*/
|
|
421
|
-
function quux2 () {
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"matchingFileName":"dummy.js"}]
|
|
425
|
-
// Message: @example error: Parsing error: The keyword 'const' is reserved
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @example // begin
|
|
429
|
-
alert('hello')
|
|
430
|
-
// end
|
|
431
|
-
*/
|
|
432
|
-
function quux () {
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc":false,"exampleCodeRegex":"// begin[\\s\\S]*// end","noDefaultExampleRules":true}]
|
|
436
|
-
// Message: @example warning (semi): Missing semicolon.
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* @typedef {string} Foo
|
|
440
|
-
* @example <caption></caption>
|
|
441
|
-
* 'foo'
|
|
442
|
-
*/
|
|
443
|
-
// "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
|
|
444
|
-
// Message: Caption is expected for examples.
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* @example
|
|
448
|
-
* const list: number[] = [1, 2, 3]
|
|
449
|
-
* quux(list);
|
|
450
|
-
*/
|
|
451
|
-
function quux () {
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc":false}]
|
|
455
|
-
// Message: @example error (semi): Missing semicolon.
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* @example
|
|
459
|
-
* const test = something.find((_) => {
|
|
460
|
-
* return _
|
|
461
|
-
* });
|
|
462
|
-
*/
|
|
463
|
-
function quux () {
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}}}]
|
|
467
|
-
// Message: @example error (semi): Missing semicolon.
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* @example <caption>Say `Hello!` to the user.</caption>
|
|
471
|
-
* First, import the function:
|
|
472
|
-
*
|
|
473
|
-
* ```js
|
|
474
|
-
* import popup from './popup'
|
|
475
|
-
* const aConstInSameScope = 5;
|
|
476
|
-
* ```
|
|
477
|
-
*
|
|
478
|
-
* Then use it like this:
|
|
479
|
-
*
|
|
480
|
-
* ```js
|
|
481
|
-
* const aConstInSameScope = 7;
|
|
482
|
-
* popup('Hello!')
|
|
483
|
-
* ```
|
|
484
|
-
*
|
|
485
|
-
* Here is the result on macOS:
|
|
486
|
-
*
|
|
487
|
-
* 
|
|
488
|
-
*/
|
|
489
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/^```(?:js|javascript)\\n([\\s\\S]*?)```$/gm"}]
|
|
490
|
-
// Message: @example error (semi): Missing semicolon.
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* @example // begin
|
|
494
|
-
alert('hello')
|
|
495
|
-
// end
|
|
496
|
-
* And here is another example:
|
|
497
|
-
// begin
|
|
498
|
-
alert('there')
|
|
499
|
-
// end
|
|
500
|
-
*/
|
|
501
|
-
function quux () {
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/\\/\\/ begin[\\s\\S]*?// end/g","noDefaultExampleRules":true}]
|
|
505
|
-
// Message: @example warning (semi): Missing semicolon.
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* @example
|
|
509
|
-
* quux();
|
|
510
|
-
*/
|
|
511
|
-
function quux () {
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
515
|
-
// Message: @example error (indent): Expected indentation of 0 spaces but found 2.
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* @default 'abc'
|
|
519
|
-
*/
|
|
520
|
-
const str = 'abc';
|
|
521
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
|
|
522
|
-
// Message: @default error (quotes): Strings must use doublequote.
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* @param {myType} [name='abc']
|
|
526
|
-
*/
|
|
527
|
-
function quux () {
|
|
528
|
-
}
|
|
529
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
|
|
530
|
-
// Message: @param error (quotes): Strings must use doublequote.
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @property {myType} [name='abc']
|
|
534
|
-
*/
|
|
535
|
-
const obj = {};
|
|
536
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
|
|
537
|
-
// Message: @property error (quotes): Strings must use doublequote.
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Test function.
|
|
541
|
-
*
|
|
542
|
-
* @example <caption>functionName (paramOne: string, paramTwo?: any,
|
|
543
|
-
* paramThree?: any): boolean</caption> test()
|
|
544
|
-
*
|
|
545
|
-
* @param {string} paramOne Parameter description.
|
|
546
|
-
* @param {any} [paramTwo] Parameter description.
|
|
547
|
-
* @param {any} [paramThree] Parameter description.
|
|
548
|
-
* @returns {boolean} Return description.
|
|
549
|
-
*/
|
|
550
|
-
const functionName = function (paramOne, paramTwo,
|
|
551
|
-
paramThree) {
|
|
552
|
-
return false;
|
|
553
|
-
};
|
|
554
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"captionRequired":true,"checkEslintrc":false}]
|
|
555
|
-
// Message: @example error (semi): Missing semicolon.
|
|
556
|
-
````
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
<a name="user-content-check-examples-passing-examples"></a>
|
|
561
|
-
<a name="check-examples-passing-examples"></a>
|
|
562
|
-
## Passing examples
|
|
563
|
-
|
|
564
|
-
The following patterns are not considered problems:
|
|
565
|
-
|
|
566
|
-
````js
|
|
567
|
-
/**
|
|
568
|
-
* @example ```js
|
|
569
|
-
alert('hello');
|
|
570
|
-
```
|
|
571
|
-
*/
|
|
572
|
-
function quux () {
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* @example ```js
|
|
579
|
-
alert('hello');
|
|
580
|
-
```
|
|
581
|
-
*/
|
|
582
|
-
function quux () {
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/```js([\\s\\S]*)```/"}]
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* @example
|
|
589
|
-
* // arbitrary example content
|
|
590
|
-
*/
|
|
591
|
-
function quux () {
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false}]
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* @example
|
|
598
|
-
* quux(); // does something useful
|
|
599
|
-
*/
|
|
600
|
-
function quux () {
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* @example quux();
|
|
607
|
-
*/
|
|
608
|
-
function quux () {
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* @example <caption>Valid usage</caption>
|
|
615
|
-
* quux(); // does something useful
|
|
616
|
-
*
|
|
617
|
-
* @example <caption>Invalid usage</caption>
|
|
618
|
-
* quux('random unwanted arg'); // results in an error
|
|
619
|
-
*/
|
|
620
|
-
function quux () {
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
// "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* @example test() // eslint-disable-line semi
|
|
627
|
-
*/
|
|
628
|
-
function quux () {}
|
|
629
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}]
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* @example
|
|
633
|
-
test() // eslint-disable-line semi
|
|
634
|
-
*/
|
|
635
|
-
function quux () {}
|
|
636
|
-
// "jsdoc/check-examples": ["error"|"warn", {"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* @example ```js
|
|
640
|
-
alert('hello')
|
|
641
|
-
```
|
|
642
|
-
*/
|
|
643
|
-
var quux = {
|
|
644
|
-
|
|
645
|
-
};
|
|
646
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* @example
|
|
650
|
-
* foo(function (err) {
|
|
651
|
-
* throw err;
|
|
652
|
-
* });
|
|
653
|
-
*/
|
|
654
|
-
function quux () {}
|
|
655
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* @example
|
|
659
|
-
* const list: number[] = [1, 2, 3];
|
|
660
|
-
* quux(list);
|
|
661
|
-
*/
|
|
662
|
-
function quux () {
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc":false}]
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* @example const ident = 5;
|
|
669
|
-
* quux2();
|
|
670
|
-
* bar();
|
|
671
|
-
*/
|
|
672
|
-
function quux2 () {
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
// "jsdoc/check-examples": ["error"|"warn", {"paddedIndent":2}]
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* @example
|
|
679
|
-
* function quux() {
|
|
680
|
-
* bar();
|
|
681
|
-
* }
|
|
682
|
-
*/
|
|
683
|
-
function quux () {
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
687
|
-
|
|
688
|
-
// Comment
|
|
689
|
-
a();
|
|
690
|
-
|
|
691
|
-
export default {};
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
*
|
|
695
|
-
*/
|
|
696
|
-
function f () {
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Does quux
|
|
702
|
-
* @example
|
|
703
|
-
* // Do it!
|
|
704
|
-
* quux();
|
|
705
|
-
*/
|
|
706
|
-
function quux () {
|
|
707
|
-
}
|
|
708
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"plugins":["jsdoc"],"rules":{"jsdoc/require-file-overview":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* @default "abc"
|
|
712
|
-
*/
|
|
713
|
-
const str = 'abc';
|
|
714
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* @default
|
|
718
|
-
*/
|
|
719
|
-
const str = 'abc';
|
|
720
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* @param {myType} [name="abc"]
|
|
724
|
-
*/
|
|
725
|
-
function quux () {
|
|
726
|
-
}
|
|
727
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* @param {myType} name
|
|
731
|
-
*/
|
|
732
|
-
function quux () {
|
|
733
|
-
}
|
|
734
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* @property {myType} [name="abc"]
|
|
738
|
-
*/
|
|
739
|
-
const obj = {};
|
|
740
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* @property {myType} [name]
|
|
744
|
-
*/
|
|
745
|
-
const obj = {};
|
|
746
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* @default 'abc'
|
|
750
|
-
*/
|
|
751
|
-
const str = 'abc';
|
|
752
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":false,"matchingFileNameDefaults":"dummy.js"}]
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* @param {myType} [name='abc']
|
|
756
|
-
*/
|
|
757
|
-
function quux () {
|
|
758
|
-
}
|
|
759
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkParams":false,"matchingFileNameParams":"dummy.js"}]
|
|
760
|
-
|
|
761
|
-
/**
|
|
762
|
-
* @property {myType} [name='abc']
|
|
763
|
-
*/
|
|
764
|
-
const obj = {};
|
|
765
|
-
// "jsdoc/check-examples": ["error"|"warn", {"checkProperties":false,"matchingFileNameProperties":"dummy.js"}]
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Test function.
|
|
769
|
-
*
|
|
770
|
-
* @example <caption>functionName (paramOne: string, paramTwo?: any,
|
|
771
|
-
* paramThree?: any): boolean</caption> test();
|
|
772
|
-
*
|
|
773
|
-
* @param {string} paramOne Parameter description.
|
|
774
|
-
* @param {any} [paramTwo] Parameter description.
|
|
775
|
-
* @param {any} [paramThree] Parameter description.
|
|
776
|
-
* @returns {boolean} Return description.
|
|
777
|
-
*/
|
|
778
|
-
const functionName = function (paramOne, paramTwo,
|
|
779
|
-
paramThree) {
|
|
780
|
-
return false;
|
|
781
|
-
};
|
|
782
|
-
// "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"captionRequired":true,"checkEslintrc":false}]
|
|
783
|
-
````
|
|
784
|
-
|