Skip to content

Commit d330391

Browse files
committedMay 12, 2020
fix(check-param-names, require-param): check ExperimentalRestProperty from babel-eslint as with RestElement; fixes #536
1 parent aaae00e commit d330391

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
 

‎src/jsdocUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const getFunctionParameterNames = (functionNode : Object) : Array<T> => {
142142
return [undefined, flattenRoots(roots)];
143143
}
144144

145-
if (param.type === 'RestElement') {
145+
if (['RestElement', 'ExperimentalRestProperty'].includes(param.type)) {
146146
return {
147147
isRestProperty: isProperty,
148148
name: param.argument.name,

‎test/rules/assertions/checkParamNames.js

+26
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,32 @@ export default {
682682
},
683683
],
684684
},
685+
{
686+
code: `
687+
module.exports = class GraphQL {
688+
/**
689+
* @param fetchOptions
690+
* @param cacheKey
691+
*/
692+
fetch = ({ url, ...options }, cacheKey) => {
693+
}
694+
};
695+
`,
696+
errors: [
697+
{
698+
message: 'Missing @param "fetchOptions.url"',
699+
},
700+
{
701+
message: 'Missing @param "fetchOptions.options"',
702+
},
703+
],
704+
options: [
705+
{
706+
checkRestProperty: true,
707+
},
708+
],
709+
parser: require.resolve('babel-eslint'),
710+
},
685711
],
686712
valid: [
687713
{

‎test/rules/assertions/requireParam.js

+38
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,44 @@ export default {
18571857
};
18581858
`,
18591859
},
1860+
{
1861+
code: `
1862+
module.exports = class GraphQL {
1863+
/**
1864+
* @param fetchOptions
1865+
* @param cacheKey
1866+
*/
1867+
fetch = ({ url, ...options }, cacheKey) => {
1868+
}
1869+
};
1870+
`,
1871+
errors: [
1872+
{
1873+
message: 'Missing JSDoc @param "fetchOptions.url" declaration.',
1874+
},
1875+
{
1876+
message: 'Missing JSDoc @param "fetchOptions.options" declaration.',
1877+
},
1878+
],
1879+
options: [
1880+
{
1881+
checkRestProperty: true,
1882+
},
1883+
],
1884+
output: `
1885+
module.exports = class GraphQL {
1886+
/**
1887+
* @param fetchOptions
1888+
* @param fetchOptions.url
1889+
* @param fetchOptions.options
1890+
* @param cacheKey
1891+
*/
1892+
fetch = ({ url, ...options }, cacheKey) => {
1893+
}
1894+
};
1895+
`,
1896+
parser: require.resolve('babel-eslint'),
1897+
},
18601898
],
18611899
valid: [
18621900
{

0 commit comments

Comments
 (0)
Please sign in to comment.