-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HAWKULAR-24: added custom rules for license checking
Adding TSLint license checker
- Loading branch information
Viliam Rockai
committed
Feb 19, 2015
1 parent
b884354
commit 697f385
Showing
9 changed files
with
114 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function Rule() { | ||
Lint.Rules.AbstractRule.apply(this, arguments); | ||
} | ||
|
||
Rule.prototype = Object.create(Lint.Rules.AbstractRule.prototype); | ||
Rule.prototype.apply = function(sourceFile) { | ||
return this.applyWithWalker(new LicenseHeaderWalker(sourceFile, this.getOptions())); | ||
}; | ||
|
||
function LicenseHeaderWalker() { | ||
Lint.RuleWalker.apply(this, arguments); | ||
} | ||
|
||
LicenseHeaderWalker.prototype = Object.create(Lint.RuleWalker.prototype); | ||
LicenseHeaderWalker.prototype.visitSourceFile = function (node) { | ||
// create a failure at the current position | ||
var sourceText = this.getSourceFile().text; | ||
|
||
var licenceHeader = this.getOptions()[0]; | ||
|
||
if ( sourceText.indexOf(licenceHeader) !== 0 ){ | ||
this.addFailure(this.createFailure(0, 0, "Missing or incorrect project license header.")); | ||
} | ||
|
||
Lint.RuleWalker.prototype.visitSourceFile.call(this, node); | ||
}; | ||
|
||
exports.Rule = Rule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters