Skip to content

Commit 67e8c5d

Browse files
committed
BREAKING CHANGE(require-description): remove noDefaults option and change contexts to always override defaults
1 parent 11cf9f5 commit 67e8c5d

File tree

4 files changed

+18
-38
lines changed

4 files changed

+18
-38
lines changed

.README/rules/require-description.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ Requires that all functions have a description.
99

1010
An options object may have any of the following properties:
1111

12-
- `contexts` - Set to a string or array of strings representing the AST context
12+
- `contexts` - Set to an array of strings representing the AST context
1313
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
14+
Overrides the defaults.
1415
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
1516
block avoids the need for a `@description`.
16-
- `noDefaults` - By default, `contexts` will permit `ArrowFunctionExpression`,
17-
`FunctionDeclaration`, and `FunctionExpression`. Set this instead to `true` to
18-
have `contexts` override these.
1917

2018
|||
2119
|---|---|
2220
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
2321
|Tags|`description`|
2422
|Aliases|`desc`|
25-
|Options|`contexts`, `exemptedBy`, `noDefaults`|
23+
|Options|`contexts`, `exemptedBy`|
2624

2725
<!-- assertions requireDescription -->

src/jsdocUtils.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -493,22 +493,16 @@ const parseClosureTemplateTag = (tag) => {
493493
* @returns {string[]}
494494
*/
495495
const enforcedContexts = (context, defaultContexts) => {
496-
/* istanbul ignore next */
497-
const defltContexts = defaultContexts === true ? [
498-
'ArrowFunctionExpression',
499-
'FunctionDeclaration',
500-
'FunctionExpression'
501-
] : defaultContexts;
502496
const {
503-
noDefaults,
504-
contexts: ctxts = []
497+
/* istanbul ignore next */
498+
contexts = defaultContexts === true ? [
499+
'ArrowFunctionExpression',
500+
'FunctionDeclaration',
501+
'FunctionExpression'
502+
] : defaultContexts
505503
} = context.options[0] || {};
506504

507-
const contexts = typeof ctxts === 'string' ? [ctxts] : ctxts;
508-
509-
return noDefaults ?
510-
contexts :
511-
[...new Set([...defltContexts, ...contexts])];
505+
return contexts;
512506
};
513507

514508
const getContextObject = (contexts, checkJsdoc) => {

src/rules/requireDescription.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,16 @@ export default iterateJsdoc(({
3737
additionalProperties: false,
3838
properties: {
3939
contexts: {
40-
oneOf: [
41-
{
42-
items: {
43-
type: 'string'
44-
},
45-
type: 'array'
46-
},
47-
{
48-
type: 'string'
49-
}
50-
]
40+
items: {
41+
type: 'string'
42+
},
43+
type: 'array'
5144
},
5245
exemptedBy: {
5346
items: {
5447
type: 'string'
5548
},
5649
type: 'array'
57-
},
58-
noDefaults: {
59-
type: 'boolean'
6050
}
6151
},
6252
type: 'object'

test/rules/assertions/requireDescription.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
],
3232
options: [
3333
{
34-
contexts: 'ClassDeclaration'
34+
contexts: ['ClassDeclaration']
3535
}
3636
]
3737
},
@@ -51,8 +51,7 @@ export default {
5151
],
5252
options: [
5353
{
54-
contexts: 'ClassDeclaration',
55-
noDefaults: true
54+
contexts: ['ClassDeclaration']
5655
}
5756
]
5857
},
@@ -109,8 +108,7 @@ export default {
109108
{
110109
contexts: [
111110
'TSInterfaceDeclaration'
112-
],
113-
noDefaults: true
111+
]
114112
}
115113
],
116114
parser: require.resolve('@typescript-eslint/parser')
@@ -218,7 +216,7 @@ export default {
218216
`,
219217
options: [
220218
{
221-
noDefaults: true
219+
contexts: ['ClassDeclaration']
222220
}
223221
]
224222
},

0 commit comments

Comments
 (0)