Skip to content

Commit 14a9aab

Browse files
committed
docs: update README.md
1 parent 3c0e3c6 commit 14a9aab

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ The format of the configuration is as follows:
194194
### Settings to Configure <code>check-examples</code>
195195

196196
The settings below all impact the `check-examples` rule and default to
197-
no-op/false except for `eslintrcForExamples` which defaults to `true`.
197+
no-op/false except as noted.
198198

199199
JSDoc specs use of an optional `<caption>` element at the beginning of
200200
`@example`. The following setting requires its use.
@@ -228,6 +228,9 @@ applied to the JavaScript found within the `@example` tags (as determined
228228
to be applicable by the above regex settings). They are ordered by
229229
decreasing precedence:
230230

231+
* `settings.jsdoc.allowInlineConfig` - If not set to `false`, will allow
232+
inline config within the `@example` to override other config. Defaults
233+
to `true`.
231234
* `settings.jsdoc.noDefaultExampleRules` - Setting to `true` will disable the
232235
default rules which are expected to be troublesome for most documentation
233236
use. See the section below for the specific default rules.
@@ -240,13 +243,20 @@ decreasing precedence:
240243
[other plugins](https://github.com/eslint/eslint-plugin-markdown), e.g.,
241244
if one sets `matchingFileName` to `dummy.md` so that `@example` rules will
242245
follow one's Markdown rules).
243-
* `settings.jsdoc.configFile` - A config file. Corresponds to `-c`.
246+
* `settings.jsdoc.configFile` - A config file. Corresponds to ESLint's `-c`.
244247
* `settings.jsdoc.eslintrcForExamples` - Defaults to `true` in adding rules
245248
based on an `.eslintrc.*` file. Setting to `false` corresponds to
246-
`--no-eslintrc`.
249+
ESLint's `--no-eslintrc`.
247250
* `settings.jsdoc.baseConfig` - An object of rules with the same schema
248251
as `.eslintrc.*` for defaults
249252

253+
Finally, the following rule pertains to inline disable directives:
254+
255+
- `settings.jsdoc.reportUnusedDisableDirectives` - If not set to `false`,
256+
this will report disabled directives which are not used (and thus not
257+
needed). Defaults to `true`. Corresponds to ESLint's
258+
`--report-unused-disable-directives`.
259+
250260
<a name="eslint-plugin-jsdoc-settings-settings-to-configure-check-examples-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
251261
#### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
252262

@@ -279,11 +289,13 @@ Works in conjunction with the following settings:
279289
* `captionRequired`
280290
* `exampleCodeRegex`
281291
* `rejectExampleCodeRegex`
292+
* `allowInlineConfig` - Defaults to `true`
282293
* `noDefaultExampleRules`
283294
* `matchingFileName`
284295
* `configFile`
285296
* `eslintrcForExamples` - Defaults to `true`
286297
* `baseConfig`
298+
* `reportUnusedDisableDirectives` - Defaults to `true`
287299

288300
Inline ESLint config within `@example` JavaScript is allowed, though the
289301
disabling of ESLint directives which are not needed by the resolved rules
@@ -384,6 +396,21 @@ function quux () {
384396
}
385397
// Settings: {"jsdoc":{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}}
386398
// Message: undefined
399+
400+
/**
401+
* @example test() // eslint-disable-line semi
402+
*/
403+
function quux () {}
404+
// Settings: {"jsdoc":{"eslintrcForExamples":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}}
405+
// Message: undefined
406+
407+
/**
408+
* @example
409+
test() // eslint-disable-line semi
410+
*/
411+
function quux () {}
412+
// Settings: {"jsdoc":{"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
413+
// Message: undefined
387414
```
388415

389416
The following patterns are not considered problems:
@@ -436,6 +463,19 @@ function quux () {
436463

437464
}
438465
// Settings: {"jsdoc":{"captionRequired":true,"eslintrcForExamples":false}}
466+
467+
/**
468+
* @example test() // eslint-disable-line semi
469+
*/
470+
function quux () {}
471+
// Settings: {"jsdoc":{"eslintrcForExamples":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}}
472+
473+
/**
474+
* @example
475+
test() // eslint-disable-line semi
476+
*/
477+
function quux () {}
478+
// Settings: {"jsdoc":{"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
439479
```
440480

441481

@@ -583,6 +623,16 @@ function quux ({a, b} = {}) {
583623
function quux ([a, b] = []) {
584624

585625
}
626+
627+
/**
628+
* Assign the project to a list of employees.
629+
* @param {Object[]} employees - The employees who are responsible for the project.
630+
* @param {string} employees[].name - The name of an employee.
631+
* @param {string} employees[].department - The employee's department.
632+
*/
633+
function assign (employees) {
634+
635+
};
586636
```
587637

588638

@@ -782,7 +832,7 @@ function quux (foo) {
782832
}
783833
// Settings: {"jsdoc":{"additionalTagNames":{"customTags":["baz","bar"]}}}
784834

785-
/**
835+
/**
786836
* @abstract
787837
* @access
788838
* @alias
@@ -870,9 +920,9 @@ RegExp
870920
<a name="eslint-plugin-jsdoc-rules-check-types-why-not-capital-case-everything"></a>
871921
#### Why not capital case everything?
872922

873-
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
923+
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
874924

875-
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
925+
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
876926

877927
So in a sense, there two types of strings in Javascript; `{string}` literals, also called primitives and `{String}` Objects. We use the primitives because it's easier to write and uses less memory. `{String}` and `{string}` are technically both valid, but they are not the same.
878928

@@ -2190,3 +2240,5 @@ function quux() {
21902240

21912241
}
21922242
```
2243+
2244+

0 commit comments

Comments
 (0)