Skip to content

Commit

Permalink
test(require-jsdoc): show exclusion of private MethodDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Apr 19, 2020
1 parent dfde551 commit 7f34ca4
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7783,6 +7783,25 @@ class MyClass {
}
// Options: [{"exemptEmptyFunctions":true,"require":{"ClassDeclaration":true}}]
// Message: Missing JSDoc comment.
export default class Test {
constructor(a) {
this.a = a;
}
}
// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":true}}]
// Message: Missing JSDoc comment.
export default class Test {
constructor(a) {
this.a = a;
}
private abc(a) {
this.a = a;
}
}
// Options: [{"contexts":["MethodDefinition:not([accessibility=\"private\"]) > FunctionExpression"],"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":false}}]
// Message: Missing JSDoc comment.
````
The following patterns are not considered problems:
Expand Down Expand Up @@ -8406,6 +8425,13 @@ export interface Foo extends Bar {
meow(): void;
}
// Options: [{"contexts":["TSMethodSignature"]}]
export default class Test {
private abc(a) {
this.a = a;
}
}
// Options: [{"contexts":["MethodDefinition:not([accessibility=\"private\"]) > FunctionExpression"],"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":false}}]
````
Expand Down
66 changes: 66 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,43 @@ export default {
sourceType: 'module',
},
},
{
code: `
export default class Test {
constructor(a) {
this.a = a;
}
private abc(a) {
this.a = a;
}
}
`,
errors: [
{
message: 'Missing JSDoc comment.',
},
],
options: [
{
contexts: [
'MethodDefinition:not([accessibility="private"]) > FunctionExpression',
],
publicOnly: true,
require: {
ArrowFunctionExpression: false,
ClassDeclaration: false,
ClassExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
MethodDefinition: false,
},
},
],
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
sourceType: 'module',
},
},
],
valid: [{
code: `
Expand Down Expand Up @@ -2503,5 +2540,34 @@ export default {
}],
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
export default class Test {
private abc(a) {
this.a = a;
}
}
`,
options: [
{
contexts: [
'MethodDefinition:not([accessibility="private"]) > FunctionExpression',
],
publicOnly: true,
require: {
ArrowFunctionExpression: false,
ClassDeclaration: false,
ClassExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
MethodDefinition: false,
},
},
],
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
sourceType: 'module',
},
},
],
};

0 comments on commit 7f34ca4

Please sign in to comment.