Skip to content

Commit 1c31782

Browse files
committed
fix(check-property-names): check duplicate nested names
1 parent cf62ec5 commit 1c31782

File tree

3 files changed

+114
-1
lines changed

3 files changed

+114
-1
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,41 @@ The following patterns are considered problems:
18621862
*/
18631863
// Message: Duplicate @property "foo"
18641864

1865+
/**
1866+
* @typedef (SomeType) SomeTypedef
1867+
* @property cfg
1868+
* @property cfg.foo
1869+
* @property cfg.foo
1870+
*/
1871+
function quux ({foo, bar}) {
1872+
1873+
}
1874+
// Message: Duplicate @property "cfg.foo"
1875+
1876+
/**
1877+
* @typedef (SomeType) SomeTypedef
1878+
* @property cfg
1879+
* @property cfg.foo
1880+
* @property [cfg.foo]
1881+
* @property baz
1882+
*/
1883+
function quux ({foo, bar}, baz) {
1884+
1885+
}
1886+
// Message: Duplicate @property "cfg.foo"
1887+
1888+
/**
1889+
* @typedef (SomeType) SomeTypedef
1890+
* @property cfg
1891+
* @property cfg.foo
1892+
* @property [cfg.foo="with a default"]
1893+
* @property baz
1894+
*/
1895+
function quux ({foo, bar}, baz) {
1896+
1897+
}
1898+
// Message: Duplicate @property "cfg.foo"
1899+
18651900
/**
18661901
* @typedef (SomeType) SomeTypedef
18671902
* @prop foo
@@ -1937,6 +1972,14 @@ function quux (code = 1) {
19371972
this.error = new Error('oops');
19381973
this.code = code;
19391974
}
1975+
1976+
/**
1977+
* @typedef (SomeType) SomeTypedef
1978+
* @property foo
1979+
* @property foo.bar
1980+
* @property foo.baz
1981+
* @property bar
1982+
*/
19401983
````
19411984

19421985

src/rules/checkPropertyNames.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const validatePropertyNames = (
66
jsdoc, jsdocNode, utils,
77
) => {
88
const propertyTags = entries(jsdoc.tags).filter(([, tag]) => {
9-
return tag.tag === targetTagName && !tag.name.includes('.');
9+
return tag.tag === targetTagName;
1010
});
1111

1212
return propertyTags.some(([, tag], index) => {

test/rules/assertions/checkPropertyNames.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,65 @@ export default {
5656
*/
5757
`,
5858
},
59+
{
60+
code: `
61+
/**
62+
* @typedef (SomeType) SomeTypedef
63+
* @property cfg
64+
* @property cfg.foo
65+
* @property cfg.foo
66+
*/
67+
function quux ({foo, bar}) {
68+
69+
}
70+
`,
71+
errors: [
72+
{
73+
line: 6,
74+
message: 'Duplicate @property "cfg.foo"',
75+
},
76+
],
77+
},
78+
{
79+
code: `
80+
/**
81+
* @typedef (SomeType) SomeTypedef
82+
* @property cfg
83+
* @property cfg.foo
84+
* @property [cfg.foo]
85+
* @property baz
86+
*/
87+
function quux ({foo, bar}, baz) {
88+
89+
}
90+
`,
91+
errors: [
92+
{
93+
line: 6,
94+
message: 'Duplicate @property "cfg.foo"',
95+
},
96+
],
97+
},
98+
{
99+
code: `
100+
/**
101+
* @typedef (SomeType) SomeTypedef
102+
* @property cfg
103+
* @property cfg.foo
104+
* @property [cfg.foo="with a default"]
105+
* @property baz
106+
*/
107+
function quux ({foo, bar}, baz) {
108+
109+
}
110+
`,
111+
errors: [
112+
{
113+
line: 6,
114+
message: 'Duplicate @property "cfg.foo"',
115+
},
116+
],
117+
},
59118
{
60119
code: `
61120
/**
@@ -191,5 +250,16 @@ export default {
191250
}
192251
`,
193252
},
253+
{
254+
code: `
255+
/**
256+
* @typedef (SomeType) SomeTypedef
257+
* @property foo
258+
* @property foo.bar
259+
* @property foo.baz
260+
* @property bar
261+
*/
262+
`,
263+
},
194264
],
195265
};

0 commit comments

Comments
 (0)