Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Fix bug where you couldn't enable the "completed-docs" rule for just …
Browse files Browse the repository at this point in the history
…private/protected methods (#2749)

+ Fix the bug
+ Fix the broken "privacies" test
+ Add tests for the individual "privacies"
  • Loading branch information
walkerburgin authored and adidahiya committed May 12, 2017
1 parent c768aa2 commit 294242e
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/rules/completedDocsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class ClassRequirement extends Requirement<IClassRequirementDescriptor> {
return this.privacies.has(PRIVACY_PROTECTED);
}

return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword);
return this.privacies.has(PRIVACY_PUBLIC);
}
}

Expand Down
30 changes: 30 additions & 0 deletions test/rules/completed-docs/privacies-private/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Class {
badDefaultMethod() { }

/**
* ...
*/
goodDefaultMethod() { }

public badPublicMethod() { }

/**
* ...
*/
public goodPublicMethod() { }

protected badProtectedMethod() { }

/**
* ...
*/
protected goodProtectedMethod() { }

private badPrivateMethod() { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for private methods.]

/**
* ...
*/
private goodPrivateMethod() { }
}
12 changes: 12 additions & 0 deletions test/rules/completed-docs/privacies-private/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"linterOptions": {
"typeCheck": true
},
"rules": {
"completed-docs": [true, {
"methods": {
"privacies": ["private"]
}
}]
}
}
30 changes: 30 additions & 0 deletions test/rules/completed-docs/privacies-protected/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Class {
badDefaultMethod() { }

/**
* ...
*/
goodDefaultMethod() { }

public badPublicMethod() { }

/**
* ...
*/
public goodPublicMethod() { }

protected badProtectedMethod() { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for protected methods.]

/**
* ...
*/
protected goodProtectedMethod() { }

private badPrivateMethod() { }

/**
* ...
*/
private goodPrivateMethod() { }
}
12 changes: 12 additions & 0 deletions test/rules/completed-docs/privacies-protected/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"linterOptions": {
"typeCheck": true
},
"rules": {
"completed-docs": [true, {
"methods": {
"privacies": ["protected"]
}
}]
}
}
31 changes: 31 additions & 0 deletions test/rules/completed-docs/privacies-public/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Class {
badDefaultMethod() { }
~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]

/**
* ...
*/
goodDefaultMethod() { }

public badPublicMethod() { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for public methods.]

/**
* ...
*/
public goodPublicMethod() { }

protected badProtectedMethod() { }

/**
* ...
*/
protected goodProtectedMethod() { }

private badPrivateMethod() { }

/**
* ...
*/
private goodPrivateMethod() { }
}
12 changes: 12 additions & 0 deletions test/rules/completed-docs/privacies-public/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"linterOptions": {
"typeCheck": true
},
"rules": {
"completed-docs": [true, {
"methods": {
"privacies": ["public"]
}
}]
}
}
5 changes: 1 addition & 4 deletions test/rules/completed-docs/privacies/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"rules": {
"completed-docs": [true, {
"methods": {
"visibilities": ["public", "protected"]
},
"properties": {
"visibilities": ["public"]
"privacies": ["all"]
}
}]
}
Expand Down

0 comments on commit 294242e

Please sign in to comment.