Skip to content

Commit

Permalink
completed-docs: methods and properties on interfaces are checked. (pa…
Browse files Browse the repository at this point in the history
  • Loading branch information
reduckted authored and suchanlee committed Aug 21, 2018
1 parent 360bdd0 commit d178206
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rules/completedDocsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ function walk(context: Lint.WalkContext<ExclusionsMap>, typeChecker: ts.TypeChec
checkNode(node as ts.InterfaceDeclaration, ARGUMENT_INTERFACES);
break;

case ts.SyntaxKind.MethodSignature:
checkNode(node as ts.MethodSignature, ARGUMENT_METHODS);
break;

case ts.SyntaxKind.MethodDeclaration:
if (node.parent!.kind !== ts.SyntaxKind.ObjectLiteralExpression) {
checkNode(node as ts.MethodDeclaration, ARGUMENT_METHODS);
Expand All @@ -350,6 +354,10 @@ function walk(context: Lint.WalkContext<ExclusionsMap>, typeChecker: ts.TypeChec
checkNode(node as ts.ModuleDeclaration, ARGUMENT_NAMESPACES);
break;

case ts.SyntaxKind.PropertySignature:
checkNode(node as ts.PropertySignature, ARGUMENT_PROPERTIES);
break;

case ts.SyntaxKind.PropertyDeclaration:
checkNode(node as ts.PropertyDeclaration, ARGUMENT_PROPERTIES);
break;
Expand Down
39 changes: 39 additions & 0 deletions test/rules/completed-docs/interface-members/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* ...
*/
interface BadInterfaceMembers {
prop: number;
~~~~~~~~~~~~~ [Documentation must exist for properties.]
method(): number;
~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
}

/**
* ...
*/
interface EmptyInterfaceMembers {
/**
*
*/
prop: number;
~~~~~~~~~~~~~ [Documentation must exist for properties.]
/**
*
*/
method(): number;
~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
}

/**
* ...
*/
interface GoodInterfaceMembers {
/**
* ...
*/
prop: number;
/**
* ...
*/
method(): number;
}
5 changes: 5 additions & 0 deletions test/rules/completed-docs/interface-members/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"module": "commonjs"
}
}
10 changes: 10 additions & 0 deletions test/rules/completed-docs/interface-members/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rules": {
"completed-docs": [
true,
"interfaces",
"methods",
"properties"
]
}
}
40 changes: 40 additions & 0 deletions test/rules/completed-docs/types/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,46 @@ interface EmptyInterface { }
*/
interface GoodInterface { }

/**
* ...
*/
interface BadInterfaceMembers {
prop: number;
~~~~~~~~~~~~~ [Documentation must exist for properties.]
method(): number;
~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
}

/**
* ...
*/
interface EmptyInterfaceMembers {
/**
*
*/
prop: number;
~~~~~~~~~~~~~ [Documentation must exist for properties.]
/**
*
*/
method(): number;
~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
}

/**
* ...
*/
interface GoodInterfaceMembers {
/**
* ...
*/
prop: number;
/**
* ...
*/
method(): number;
}

namespace BadNamespace { }
~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for namespaces.]

Expand Down

0 comments on commit d178206

Please sign in to comment.