This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 887
Improve handling of paths to custom rules directories #912
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -19,7 +19,10 @@ expectOut () { | |
expect=$2 | ||
msg=$3 | ||
|
||
if [ $expect != $actual ]; then | ||
nodeV=`node -v` | ||
|
||
# if Node 0.10.*, node will sometimes exit with status 8 when an error is thrown | ||
if [[ $expect != $actual || $nodeV == v0.10.* && $expect == 1 && $actual == 8 ]] ; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this how precedence works here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you nest brackets like that? I don't know bash, but I did look up that |
||
echo "$msg: expected $expect got $actual" | ||
num_failures=$(expr $num_failures + 1) | ||
fi | ||
|
@@ -42,6 +45,21 @@ expectOut $? 0 "tslint with valid arguments did not exit correctly" | |
./bin/tslint src/configuration.ts -f src/formatterLoader.ts | ||
expectOut $? 1 "tslint with -f flag did not exit correctly" | ||
|
||
# make sure calling tslint with a CLI custom rules directory that doesn't exist fails | ||
# (redirect stderr because it's confusing to see a stack trace during the build) | ||
./bin/tslint -c ./test/config/tslint-custom-rules.json -r ./someRandomDir src/tslint.ts | ||
expectOut $? 1 "tslint with -r pointing to a nonexistent directory did not fail" | ||
|
||
# make sure calling tslint with a CLI custom rules directory that does exist finds the errors it should | ||
./bin/tslint -c ./test/config/tslint-custom-rules.json -r ./test/files/custom-rules src/tslint.ts | ||
expectOut $? 2 "tslint with with -r pointing to custom rules did not find lint failures" | ||
|
||
# make sure calling tslint with a rulesDirectory in a config file works | ||
./bin/tslint -c ./test/config/tslint-custom-rules-with-dir.json src/tslint.ts | ||
expectOut $? 2 "tslint with with JSON pointing to custom rules did not find lint failures" | ||
|
||
|
||
|
||
# make sure tslint --init generates a file | ||
cd ./bin | ||
if [ -f tslint.json ]; then | ||
|
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,6 @@ | ||
{ | ||
"rulesDirectory": "../files/custom-rules/", | ||
"rules": { | ||
"always-fail": true | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"rules": { | ||
"always-fail": true | ||
} | ||
} |
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,27 @@ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var Lint = require("tslint/lib/lint"); | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule() { | ||
_super.apply(this, arguments); | ||
} | ||
Rule.prototype.apply = function (sourceFile) { | ||
return this.applyWithWalker(new AlwaysFailWalker(sourceFile, this.getOptions())); | ||
}; | ||
return Rule; | ||
})(Lint.Rules.AbstractRule); | ||
exports.Rule = Rule; | ||
var AlwaysFailWalker = (function (_super) { | ||
__extends(AlwaysFailWalker, _super); | ||
function AlwaysFailWalker() { | ||
_super.apply(this, arguments); | ||
} | ||
AlwaysFailWalker.prototype.visitSourceFile = function (node) { | ||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "failure")); | ||
}; | ||
return AlwaysFailWalker; | ||
})(Lint.RuleWalker); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
path.resolve(directory)
in the error message?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getRelativePath
is already resolving to absolute paths, so this will show users an absolute path already