Skip to content

Commit 27c9b5c

Browse files
brettz9golopot
authored andcommitted
fix(getJSDocComment): Check for parents of ClassExpression and ObjectExpression
1 parent 7c47afa commit 27c9b5c

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,24 @@ have `contexts` override these.
23412341
The following patterns are considered problems:
23422342

23432343
````js
2344+
/**
2345+
* foo.
2346+
*/
2347+
const q = class {
2348+
2349+
}
2350+
// Options: [{"contexts":["ClassExpression"],"noDefaults":true}]
2351+
// Message: JSDoc description does not satisfy the regex pattern.
2352+
2353+
/**
2354+
* foo.
2355+
*/
2356+
const q = {
2357+
2358+
};
2359+
// Options: [{"contexts":["ObjectExpression"],"noDefaults":true}]
2360+
// Message: JSDoc description does not satisfy the regex pattern.
2361+
23442362
/**
23452363
* foo.
23462364
*/
@@ -2739,6 +2757,22 @@ const myObject = {
27392757
myProp: true
27402758
};
27412759
// Options: [{"contexts":[],"noDefaults":true}]
2760+
2761+
/**
2762+
* foo.
2763+
*/
2764+
const q = class {
2765+
2766+
}
2767+
// Options: [{"contexts":[],"noDefaults":true}]
2768+
2769+
/**
2770+
* foo.
2771+
*/
2772+
const q = {
2773+
2774+
};
2775+
// Options: [{"contexts":[],"noDefaults":true}]
27422776
````
27432777

27442778

test/rules/assertions/matchDescription.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
export default {
22
invalid: [
3+
{
4+
code: `
5+
/**
6+
* foo.
7+
*/
8+
const q = class {
9+
10+
}
11+
`,
12+
errors: [
13+
{
14+
line: 3,
15+
message: 'JSDoc description does not satisfy the regex pattern.'
16+
}
17+
],
18+
options: [
19+
{
20+
contexts: [
21+
'ClassExpression'
22+
],
23+
noDefaults: true
24+
}
25+
]
26+
},
27+
{
28+
code: `
29+
/**
30+
* foo.
31+
*/
32+
const q = {
33+
34+
};
35+
`,
36+
errors: [
37+
{
38+
line: 3,
39+
message: 'JSDoc description does not satisfy the regex pattern.'
40+
}
41+
],
42+
options: [
43+
{
44+
contexts: [
45+
'ObjectExpression'
46+
],
47+
noDefaults: true
48+
}
49+
]
50+
},
351
{
452
code: `
553
/**
@@ -777,6 +825,40 @@ export default {
777825
noDefaults: true
778826
}
779827
]
828+
},
829+
{
830+
code: `
831+
/**
832+
* foo.
833+
*/
834+
const q = class {
835+
836+
}
837+
`,
838+
options: [
839+
{
840+
contexts: [
841+
],
842+
noDefaults: true
843+
}
844+
]
845+
},
846+
{
847+
code: `
848+
/**
849+
* foo.
850+
*/
851+
const q = {
852+
853+
};
854+
`,
855+
options: [
856+
{
857+
contexts: [
858+
],
859+
noDefaults: true
860+
}
861+
]
780862
}
781863
]
782864
};

0 commit comments

Comments
 (0)