Skip to content

Commit 299b095

Browse files
committed
fix(match-description, require-description): allow contexts to work with any node type
1 parent 3e0775a commit 299b095

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

test/rules/assertions/matchDescription.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,80 @@ export default {
395395
noDefaults: true
396396
}
397397
]
398+
},
399+
{
400+
code: `
401+
class MyClass {
402+
/**
403+
* Abc
404+
*/
405+
myClassField = 1
406+
}
407+
`,
408+
errors: [
409+
{
410+
line: 4,
411+
message: 'JSDoc description does not satisfy the regex pattern.'
412+
}
413+
],
414+
options: [
415+
{
416+
contexts: [
417+
'ClassProperty'
418+
],
419+
noDefaults: true
420+
}
421+
],
422+
parser: require.resolve('@typescript-eslint/parser')
423+
},
424+
{
425+
code: `
426+
/**
427+
* foo.
428+
*/
429+
interface quux {
430+
431+
}
432+
`,
433+
errors: [
434+
{
435+
line: 3,
436+
message: 'JSDoc description does not satisfy the regex pattern.'
437+
}
438+
],
439+
options: [
440+
{
441+
contexts: [
442+
'TSInterfaceDeclaration'
443+
],
444+
noDefaults: true
445+
}
446+
],
447+
parser: require.resolve('@typescript-eslint/parser')
448+
},
449+
{
450+
code: `
451+
const myObject = {
452+
/**
453+
* Bad description
454+
*/
455+
myProp: true
456+
};
457+
`,
458+
errors: [
459+
{
460+
line: 4,
461+
message: 'JSDoc description does not satisfy the regex pattern.'
462+
}
463+
],
464+
options: [
465+
{
466+
contexts: [
467+
'Property'
468+
],
469+
noDefaults: true
470+
}
471+
]
398472
}
399473
],
400474
valid: [
@@ -624,6 +698,61 @@ export default {
624698
'main description': true
625699
}}
626700
]
701+
},
702+
{
703+
code: `
704+
class MyClass {
705+
/**
706+
* Abc.
707+
*/
708+
myClassField = 1
709+
}
710+
`,
711+
options: [
712+
{
713+
contexts: [
714+
'ClassProperty'
715+
],
716+
noDefaults: true
717+
}
718+
],
719+
parser: require.resolve('@typescript-eslint/parser')
720+
},
721+
{
722+
code: `
723+
/**
724+
* Foo.
725+
*/
726+
interface quux {
727+
728+
}
729+
`,
730+
options: [
731+
{
732+
contexts: [
733+
'TSInterfaceDeclaration'
734+
],
735+
noDefaults: true
736+
}
737+
],
738+
parser: require.resolve('@typescript-eslint/parser')
739+
},
740+
{
741+
code: `
742+
const myObject = {
743+
/**
744+
* Bad description
745+
*/
746+
myProp: true
747+
};
748+
`,
749+
options: [
750+
{
751+
contexts: [
752+
],
753+
noDefaults: true
754+
}
755+
]
627756
}
628757
]
629758
};

0 commit comments

Comments
 (0)