Skip to content

Commit 6d6e1fc

Browse files
committed
test(check-types): show further scenarios, reporting false and unifyParentAndChildTypeChecks option
1 parent cda6839 commit 6d6e1fc

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,35 @@ function quux (foo) {
15861586
// Options: [{"unifyParentAndChildTypeChecks":true}]
15871587
// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
15881588

1589+
/**
1590+
* @param {object} foo
1591+
*/
1592+
function quux (foo) {
1593+
1594+
}
1595+
// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
1596+
// Options: [{"unifyParentAndChildTypeChecks":true}]
1597+
// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
1598+
1599+
/**
1600+
* @param {object} foo
1601+
*/
1602+
function quux (foo) {
1603+
1604+
}
1605+
// Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
1606+
// Options: [{"unifyParentAndChildTypeChecks":true}]
1607+
// Message: Invalid JSDoc @param "foo" type "object".
1608+
1609+
/**
1610+
* @param {object} foo
1611+
*/
1612+
function quux (foo) {
1613+
1614+
}
1615+
// Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
1616+
// Message: Invalid JSDoc @param "foo" type "object".
1617+
15891618
/**
15901619
* @param {object.<string, number>} foo
15911620
*/
@@ -3543,6 +3572,7 @@ function quux (foo, bar) {
35433572
function quux (foo) {
35443573

35453574
}
3575+
// Settings: {"jsdoc":{"allowOverrideWithoutParam":false}}
35463576
// Message: Missing JSDoc @param "foo" declaration.
35473577

35483578
/**
@@ -3551,6 +3581,7 @@ function quux (foo) {
35513581
function quux (foo) {
35523582

35533583
}
3584+
// Settings: {"jsdoc":{"allowImplementsWithoutParam":false}}
35543585
// Message: Missing JSDoc @param "foo" declaration.
35553586

35563587
/**
@@ -3580,6 +3611,7 @@ class A {
35803611

35813612
}
35823613
}
3614+
// Settings: {"jsdoc":{"allowOverrideWithoutParam":false}}
35833615
// Message: Missing JSDoc @param "foo" declaration.
35843616

35853617
/**
@@ -3593,6 +3625,7 @@ class A {
35933625

35943626
}
35953627
}
3628+
// Settings: {"jsdoc":{"allowImplementsWithoutParam":false}}
35963629
// Message: Missing JSDoc @param "foo" declaration.
35973630

35983631
/**
@@ -3660,9 +3693,47 @@ function quux (foo) {
36603693
*/
36613694
function quux (foo) {
36623695

3696+
}
3697+
3698+
/**
3699+
* @override
3700+
*/
3701+
class A {
3702+
/**
3703+
*
3704+
*/
3705+
quux (foo) {
3706+
3707+
}
3708+
}
3709+
3710+
/**
3711+
* @override
3712+
*/
3713+
function quux (foo) {
3714+
36633715
}
36643716
// Settings: {"jsdoc":{"allowOverrideWithoutParam":true}}
36653717

3718+
/**
3719+
* @implements
3720+
*/
3721+
class A {
3722+
/**
3723+
*
3724+
*/
3725+
quux (foo) {
3726+
3727+
}
3728+
}
3729+
3730+
/**
3731+
* @implements
3732+
*/
3733+
function quux (foo) {
3734+
3735+
}
3736+
36663737
/**
36673738
* @implements
36683739
*/

test/rules/assertions/checkTypes.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,78 @@ export default {
691691
}
692692
}
693693
},
694+
{
695+
code: `
696+
/**
697+
* @param {object} foo
698+
*/
699+
function quux (foo) {
700+
701+
}
702+
`,
703+
errors: [
704+
{
705+
message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".'
706+
}
707+
],
708+
options: [{
709+
unifyParentAndChildTypeChecks: true
710+
}],
711+
settings: {
712+
jsdoc: {
713+
preferredTypes: {
714+
object: 'GenericObject'
715+
}
716+
}
717+
}
718+
},
719+
{
720+
code: `
721+
/**
722+
* @param {object} foo
723+
*/
724+
function quux (foo) {
725+
726+
}
727+
`,
728+
errors: [
729+
{
730+
message: 'Invalid JSDoc @param "foo" type "object".'
731+
}
732+
],
733+
options: [{
734+
unifyParentAndChildTypeChecks: true
735+
}],
736+
settings: {
737+
jsdoc: {
738+
preferredTypes: {
739+
object: false
740+
}
741+
}
742+
}
743+
},
744+
{
745+
code: `
746+
/**
747+
* @param {object} foo
748+
*/
749+
function quux (foo) {
750+
751+
}
752+
`,
753+
errors: [
754+
{
755+
message: 'Invalid JSDoc @param "foo" type "object".'
756+
}
757+
],
758+
settings: {
759+
jsdoc: {
760+
preferredTypes: {
761+
object: false
762+
}
763+
}
764+
}
765+
},
694766
{
695767
code: `
696768
/**

0 commit comments

Comments
 (0)