Add protected keyword to underscore lint rule
This commit is contained in:
		@@ -1,5 +1,10 @@
 | 
				
			|||||||
# CHANGELOG
 | 
					# CHANGELOG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## v0.5.0 - _TBD, 2018_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    * Modified custom 'underscore-privates' rule, changing it to 'underscore-private-protected' requiring underscores to be prepended to private variable names
 | 
				
			||||||
 | 
					    * Because our tools can be used in both a TS and JS environment, we want to make the private methods of any public facing interface show up at the bottom of auto-complete lists. Additionally, we wanted to remain consistent with respect to our usage of underscores in order to enforce this rule with a linter rule, rather then manual code reviews.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## v0.4.0 - _December 28, 2017_
 | 
					## v0.4.0 - _December 28, 2017_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    * Added custom 'underscore-privates' rule, requiring underscores to be prepended to private variable names
 | 
					    * Added custom 'underscore-privates' rule, requiring underscores to be prepended to private variable names
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ type RelevantClassMember =
 | 
				
			|||||||
// Copied from: https://github.com/DanielRosenwasser/underscore-privates-tslint-rule
 | 
					// Copied from: https://github.com/DanielRosenwasser/underscore-privates-tslint-rule
 | 
				
			||||||
// The version on github is not published on npm
 | 
					// The version on github is not published on npm
 | 
				
			||||||
export class Rule extends Lint.Rules.AbstractRule {
 | 
					export class Rule extends Lint.Rules.AbstractRule {
 | 
				
			||||||
    public static FAILURE_STRING = 'private members must be prefixed with an underscore';
 | 
					    public static FAILURE_STRING = 'private and protected members must be prefixed with an underscore';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
 | 
					    public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
 | 
				
			||||||
        return this.applyWithFunction(sourceFile, walk);
 | 
					        return this.applyWithFunction(sourceFile, walk);
 | 
				
			||||||
@@ -54,7 +54,7 @@ function nameStartsWithUnderscore(text: string) {
 | 
				
			|||||||
    return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
 | 
					    return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
function memberIsPrivate(node: ts.Declaration) {
 | 
					function memberIsPrivate(node: ts.Declaration) {
 | 
				
			||||||
    return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword);
 | 
					    return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ProtectedKeyword);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
function nameIsIdentifier(node: ts.Node): node is ts.Identifier {
 | 
					function nameIsIdentifier(node: ts.Node): node is ts.Identifier {
 | 
				
			||||||
    return node.kind === ts.SyntaxKind.Identifier;
 | 
					    return node.kind === ts.SyntaxKind.Identifier;
 | 
				
			||||||
@@ -73,7 +73,7 @@
 | 
				
			|||||||
        ],
 | 
					        ],
 | 
				
			||||||
        "space-within-parens": false,
 | 
					        "space-within-parens": false,
 | 
				
			||||||
        "type-literal-delimiter": true,
 | 
					        "type-literal-delimiter": true,
 | 
				
			||||||
        "underscore-privates": true,
 | 
					        "underscore-private-and-protected": true,
 | 
				
			||||||
        "variable-name": [true, "ban-keywords", "allow-pascal-case"],
 | 
					        "variable-name": [true, "ban-keywords", "allow-pascal-case"],
 | 
				
			||||||
        "whitespace": [
 | 
					        "whitespace": [
 | 
				
			||||||
            true,
 | 
					            true,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user