This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d389e6
Showing
14 changed files
with
401 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[package.json] | ||
indent_size = 2 |
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 @@ | ||
* text=auto |
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,12 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Dependency directories | ||
node_modules | ||
typings | ||
|
||
# Compiled output | ||
*.js | ||
*.d.ts |
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 @@ | ||
node_modules |
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,8 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## 0.1.0 — 2016-05-27 | ||
|
||
- Initial public release. |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Enable International Ltd. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,16 @@ | ||
# gulp-tslint-vso-formatter | ||
|
||
A [`gulp-tslint`](https://github.com/panuhorsmalahti/gulp-tslint) reporter | ||
for Visual Studio Online and Team Foundation Server. | ||
|
||
# Usage | ||
|
||
import gulp from "gulp"; | ||
import tslint from "gulp-tslint"; | ||
import vsoReporter from "gulp-tslint-vso-reporter"; | ||
|
||
gulp.task("typescript:lint", function() { | ||
return gulp.src("greeter.ts") | ||
.pipe(tslint()) | ||
.pipe(tslint.report(vsoReporter)); | ||
}); |
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,4 @@ | ||
/*tslint:disable:no-default-export */ | ||
import vsoReporter from "./lib/vsoReporter"; | ||
export default vsoReporter; | ||
/*tslint:enable:no-default-export */ |
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,17 @@ | ||
export default function vsoReporter(output: any, file?: any, options?: any): void { | ||
const logType = options && !options.emitError ? "warning" : "error"; | ||
|
||
for (let i = 0, len = output.length; i < len; i++) { | ||
const failure = output[i]; | ||
|
||
const failureString = failure.failure; | ||
const fileName = failure.name; | ||
const line = failure.startPosition.line + 1; | ||
const character = failure.startPosition.character + 1; | ||
const code = failure.ruleName; | ||
|
||
const properties = `sourcepath=${fileName};linenumber=${line};columnnumber=${character};code=${code};`; | ||
|
||
console.log(`##vso[task.logissue type=${logType};${properties}]${failureString}`); | ||
} | ||
} |
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,36 @@ | ||
{ | ||
"name": "gulp-tslint-vso-reporter", | ||
"version": "0.1.0", | ||
"description": "A gulp-tslint reporter for Visual Studio Online and Team Foundation Server", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https:github.com/EnableSoftware/gulp-tslint-vso-reporter.git" | ||
}, | ||
"bugs": { | ||
"url": "https:github.com/EnableSoftware/gulp-tslint-vso-reporter/issues" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"tslint", | ||
"gulp-tslint", | ||
"vso", | ||
"reporter" | ||
], | ||
"author": "Enable Software <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"mocha": "^2.5.1", | ||
"sinon": "^1.17.4", | ||
"typescript": "^1.8.10" | ||
}, | ||
"peerDependencies": { | ||
"gulp-tslint": "^5.0.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "typings install", | ||
"prepublish": "tsc", | ||
"test": "npm run prepublish && mocha", | ||
"lint": "tslint lib/*.ts test/*.ts index.ts --exclude **/*.d.ts" | ||
} | ||
} |
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,90 @@ | ||
import reporter from "../lib/vsoReporter"; | ||
import * as sinon from "sinon"; | ||
import * as assert from "assert"; | ||
|
||
describe("VSO Reporter", function() { | ||
let spy: sinon.SinonSpy; | ||
|
||
beforeEach(function() { | ||
spy = sinon.stub(console, 'log'); | ||
}); | ||
|
||
afterEach(function() { | ||
spy.restore(); | ||
}); | ||
|
||
it("handles no failures", function() { | ||
reporter([]); | ||
assert.equal(true, spy.notCalled); | ||
}); | ||
|
||
it("formats failure", function() { | ||
// Arrange | ||
const failure = { | ||
name: "test.ts", | ||
failure: "rule failure message", | ||
startPosition: | ||
{ | ||
line: 0, | ||
character: 0 | ||
}, | ||
ruleName: "rule-name" | ||
}; | ||
|
||
const expectedResult = | ||
"##vso[task.logissue type=error;sourcepath=test.ts;linenumber=1;columnnumber=1;code=rule-name;]rule failure message"; | ||
|
||
// Act | ||
const actualResult = reporter([failure]); | ||
|
||
// Assert | ||
assert.equal(true, spy.calledOnce); | ||
assert.equal(true, spy.calledWith(expectedResult)); | ||
}); | ||
|
||
it("formats multiple failures", function() { | ||
// Arrange | ||
const failures = [ | ||
{ name: "test.ts", failure: "first failure message", startPosition: { line: 0, character: 0 }, ruleName: "first-name" }, | ||
{ name: "test.ts", failure: "second failure message", startPosition: { line: 1, character: 16 }, ruleName: "second-name" }, | ||
{ name: "test.ts", failure: "last failure message", startPosition: { line: 9, character: 57 }, ruleName: "last-name" } | ||
]; | ||
|
||
const expectedResults = [ | ||
"##vso[task.logissue type=error;sourcepath=test.ts;linenumber=1;columnnumber=1;code=first-name;]first failure message", | ||
"##vso[task.logissue type=error;sourcepath=test.ts;linenumber=2;columnnumber=17;code=second-name;]second failure message", | ||
"##vso[task.logissue type=error;sourcepath=test.ts;linenumber=10;columnnumber=58;code=last-name;]last failure message"]; | ||
|
||
// Act | ||
const actualResult = reporter(failures); | ||
|
||
// Assert | ||
assert.equal(true, spy.calledWith(expectedResults[0])); | ||
assert.equal(true, spy.calledWith(expectedResults[1])); | ||
assert.equal(true, spy.calledWith(expectedResults[2])); | ||
}); | ||
|
||
it("emits warning if `options.emitError` is `false`", function() { | ||
// Arrange | ||
const failure = { | ||
name: "test.ts", | ||
failure: "rule failure message", | ||
startPosition: | ||
{ | ||
line: 0, | ||
character: 0 | ||
}, | ||
ruleName: "rule-name" | ||
}; | ||
|
||
const expectedResult = | ||
"##vso[task.logissue type=warning;sourcepath=test.ts;linenumber=1;columnnumber=1;code=rule-name;]rule failure message"; | ||
|
||
// Act | ||
const actualResult = reporter([failure], undefined, { emitError: false }); | ||
|
||
// Assert | ||
assert.equal(true, spy.calledOnce); | ||
assert.equal(true, spy.calledWith(expectedResult)); | ||
}); | ||
}); |
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,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"module": "commonjs", | ||
"target": "es5", | ||
"noImplicitAny": true, | ||
"sourceMap": false | ||
}, | ||
"files": [ | ||
"index.ts", | ||
"test/vsoReporter.tests.ts", | ||
"typings/index.d.ts" | ||
] | ||
} |
Oops, something went wrong.