Skip to content

Commit 7e4a106

Browse files
brettz9golopot
authored andcommitted
BREAKING CHANGE(require-description): remove noDefaults option and change contexts to always override defaults
Also reverting for `match-description`
1 parent 27c9b5c commit 7e4a106

File tree

9 files changed

+38
-94
lines changed

9 files changed

+38
-94
lines changed

.README/rules/match-description.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,13 @@ it by setting it to `false`.
7373

7474
Set this to a string or array of strings representing the AST context
7575
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
76-
77-
##### `noDefaults`
78-
79-
By default, `contexts` will permit `ArrowFunctionExpression`,
80-
`FunctionDeclaration`, and `FunctionExpression`. Set this instead to `true` to
81-
have `contexts` override these.
76+
Overrides the defaults.
8277

8378
|||
8479
|---|---|
8580
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
8681
|Tags|N/A by default but see `tags` options|
8782
|Settings||
88-
|Options|`contexts`, `noDefaults`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
83+
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
8984

9085
<!-- assertions matchDescription -->

.README/rules/require-description.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ An options object may have any of the following properties:
1111

1212
- `contexts` - Set to a string or 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 -->

.README/rules/require-jsdoc.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ be checked by the rule.
3636

3737
- `contexts` - Set this to a string or array of strings representing the additional
3838
AST context where you wish the rule to be applied (e.g., `Property` for properties).
39-
Note that unlike `require-description` and `match-description`, this rule has no
40-
`noDefaults` option because its defaults are instead set up by `require`.
4139

4240
|||
4341
|---|---|

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/matchDescription.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,10 @@ export default iterateJsdoc(({
7171
additionalProperties: false,
7272
properties: {
7373
contexts: {
74-
oneOf: [
75-
{
76-
items: {
77-
type: 'string'
78-
},
79-
type: 'array'
80-
},
81-
{
82-
type: 'string'
83-
}
84-
]
74+
items: {
75+
type: 'string'
76+
},
77+
type: 'array'
8578
},
8679
mainDescription: {
8780
oneOf: [
@@ -98,10 +91,6 @@ export default iterateJsdoc(({
9891
format: 'regex',
9992
type: 'string'
10093
},
101-
noDefaults: {
102-
default: false,
103-
type: 'boolean'
104-
},
10594
tags: {
10695
patternProperties: {
10796
'.*': {

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'

src/rules/requireJsdoc.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,10 @@ const OPTIONS_SCHEMA = {
88
additionalProperties: false,
99
properties: {
1010
contexts: {
11-
oneOf: [
12-
{
13-
items: {
14-
type: 'string'
15-
},
16-
type: 'array'
17-
},
18-
{
19-
type: 'string'
20-
}
21-
]
11+
items: {
12+
type: 'string'
13+
},
14+
type: 'array'
2215
},
2316
publicOnly: {
2417
oneOf: [

test/rules/assertions/matchDescription.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export default {
1919
{
2020
contexts: [
2121
'ClassExpression'
22-
],
23-
noDefaults: true
22+
]
2423
}
2524
]
2625
},
@@ -43,8 +42,7 @@ export default {
4342
{
4443
contexts: [
4544
'ObjectExpression'
46-
],
47-
noDefaults: true
45+
]
4846
}
4947
]
5048
},
@@ -461,8 +459,7 @@ export default {
461459
{
462460
contexts: [
463461
'ClassDeclaration'
464-
],
465-
noDefaults: true
462+
]
466463
}
467464
]
468465
},
@@ -485,8 +482,7 @@ export default {
485482
{
486483
contexts: [
487484
'ClassProperty'
488-
],
489-
noDefaults: true
485+
]
490486
}
491487
],
492488
parser: require.resolve('@typescript-eslint/parser')
@@ -510,8 +506,7 @@ export default {
510506
{
511507
contexts: [
512508
'TSInterfaceDeclaration'
513-
],
514-
noDefaults: true
509+
]
515510
}
516511
],
517512
parser: require.resolve('@typescript-eslint/parser')
@@ -535,8 +530,7 @@ export default {
535530
{
536531
contexts: [
537532
'Property'
538-
],
539-
noDefaults: true
533+
]
540534
}
541535
]
542536
}
@@ -784,8 +778,7 @@ export default {
784778
{
785779
contexts: [
786780
'ClassProperty'
787-
],
788-
noDefaults: true
781+
]
789782
}
790783
],
791784
parser: require.resolve('@typescript-eslint/parser')
@@ -803,8 +796,7 @@ export default {
803796
{
804797
contexts: [
805798
'TSInterfaceDeclaration'
806-
],
807-
noDefaults: true
799+
]
808800
}
809801
],
810802
parser: require.resolve('@typescript-eslint/parser')
@@ -821,8 +813,7 @@ export default {
821813
options: [
822814
{
823815
contexts: [
824-
],
825-
noDefaults: true
816+
]
826817
}
827818
]
828819
},
@@ -838,8 +829,7 @@ export default {
838829
options: [
839830
{
840831
contexts: [
841-
],
842-
noDefaults: true
832+
]
843833
}
844834
]
845835
},
@@ -855,8 +845,7 @@ export default {
855845
options: [
856846
{
857847
contexts: [
858-
],
859-
noDefaults: true
848+
]
860849
}
861850
]
862851
}

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)