initial commit
This commit is contained in:
13
node_modules/gulp-tslint/.github/ISSUE_TEMPLATE
generated
vendored
Normal file
13
node_modules/gulp-tslint/.github/ISSUE_TEMPLATE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Thanks for wanting to report an issue you've found in gulp-tslint. Please make sure it's an issue in gulp-tslint, not tslint. Otherwise please submit an issue to tslint: https://github.com/palantir/tslint/issues/new. Please delete this text and fill in the template below.
|
||||
|
||||
gulp-tslint version:
|
||||
tslint version:
|
||||
Operating system:
|
||||
|
||||
Example gulp configuration (if applicable):
|
||||
|
||||
|
||||
Error console output:
|
||||
|
||||
|
||||
TypeScript example code (if applicable):
|
||||
15
node_modules/gulp-tslint/.npmignore
generated
vendored
Normal file
15
node_modules/gulp-tslint/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/node_modules
|
||||
/test/**/*.js
|
||||
*.map
|
||||
npm-debug.log
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
|
||||
# Ignore from package:
|
||||
/test
|
||||
/types
|
||||
index.ts
|
||||
.travis.yml
|
||||
gulpfile.js
|
||||
tslint.json
|
||||
170
node_modules/gulp-tslint/CHANGELOG.md
generated
vendored
Normal file
170
node_modules/gulp-tslint/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
<a name="8.1.4"></a>
|
||||
# 8.1.4 (2019-02-21)
|
||||
|
||||
- Fix plugin return type [pull #150](https://github.com/panuhorsmalahti/gulp-tslint/pull/150).
|
||||
|
||||
<a name="8.1.3"></a>
|
||||
# 8.1.3 (2018-02-13)
|
||||
|
||||
- Drop dependency on deprecated gulp-util [pull #140](https://github.com/panuhorsmalahti/gulp-tslint/pull/140).
|
||||
|
||||
<a name="8.1.2"></a>
|
||||
# 8.1.2 (2017-08-08)
|
||||
|
||||
- Determine configuration separately for each source file [pull #134](https://github.com/panuhorsmalahti/gulp-tslint/pull/134).
|
||||
|
||||
<a name="8.1.1"></a>
|
||||
# 8.1.1 (2017-06-05)
|
||||
|
||||
- Improve gulp-tslint performance [pull #127](https://github.com/panuhorsmalahti/gulp-tslint/pull/127).
|
||||
- Types should be devDependencies [pull #129](https://github.com/panuhorsmalahti/gulp-tslint/pull/129).
|
||||
|
||||
<a name="8.1.0"></a>
|
||||
# 8.1.0 (2017-05-21)
|
||||
|
||||
- Add allowWarnings gulp-tslint option [pull #122](https://github.com/panuhorsmalahti/gulp-tslint/pull/122).
|
||||
|
||||
<a name="8.0.0"></a>
|
||||
# 8.0.0 (2017-04-10)
|
||||
|
||||
- **breaking change**: Require tslint 5.x [pull #113](https://github.com/panuhorsmalahti/gulp-tslint/pull/113).
|
||||
|
||||
<a name="7.1.0"></a>
|
||||
# 7.1.0 (2017-02-3)
|
||||
|
||||
- Add support for TSlint option 'fix' [pull #101](https://github.com/panuhorsmalahti/gulp-tslint/pull/101).
|
||||
- Skip directories while reporting errors [pull #107](https://github.com/panuhorsmalahti/gulp-tslint/pull/107).
|
||||
|
||||
<a name="7.0.0"></a>
|
||||
# 7.0.0 (2016-11-19)
|
||||
|
||||
- Update tslint to 4.0.0. See tslint changelog for a list of breaking changes.
|
||||
|
||||
<a name="6.1.3"></a>
|
||||
# 6.1.3 (2016-11-01)
|
||||
|
||||
- Drop support for Node.js 0.10
|
||||
|
||||
<a name="6.1.0"></a>
|
||||
# 6.1.0 (2016-07-29)
|
||||
|
||||
- Allow custom formatter as a function [pull #68](https://github.com/panuhorsmalahti/gulp-tslint/pull/68).
|
||||
- Allow type checked rules
|
||||
|
||||
<a name="6.0.0"></a>
|
||||
# 6.0.0 (2016-07-09)
|
||||
|
||||
## Changes
|
||||
|
||||
- **breaking change**: Add support for custom TSLint formatters, gulp-tslint reporters have been removed.
|
||||
- **breaking change**: The signature for `tslintPlugin.report` has changed to `tslintPlugin.report(options?: ReportOptions)`.
|
||||
This requires e.g. the following to be changed from
|
||||
```
|
||||
.pipe(tslint())
|
||||
.pipe(tslint.report("verbose"))
|
||||
```
|
||||
to
|
||||
```
|
||||
.pipe(tslint({
|
||||
formatter: "verbose"
|
||||
}))
|
||||
.pipe(tslint.report())
|
||||
```
|
||||
- Custom gulp-tslint reporters will no longer work; instead users will have to make use of the TSLint equivalents.
|
||||
For more information see [pull #66](https://github.com/panuhorsmalahti/gulp-tslint/pull/66).
|
||||
- **breaking change**: `tslintPlugin.ProseErrorFormat` is no longer exported.
|
||||
- **breaking change**: The options passed to tslintPlugin have changed. The PluginOptions interface is now:
|
||||
```
|
||||
interface PluginOptions {
|
||||
configuration?: any;
|
||||
formatter?: string;
|
||||
formattersDirectory?: string;
|
||||
rulesDirectory?: string;
|
||||
tslint?: any;
|
||||
}
|
||||
```
|
||||
- **breaking change**: "full" formatter was removed
|
||||
- Added "vso", "pmd" and "checkstyle" formatters
|
||||
|
||||
<a name="5.0.0"></a>
|
||||
# 5.0.0 (2016-04-24)
|
||||
|
||||
## Changes
|
||||
|
||||
- support for extends property
|
||||
|
||||
<a name="4.3.0"></a>
|
||||
# 4.3.0 (2016-01-11)
|
||||
|
||||
## Changes
|
||||
|
||||
- Updated rcloader fixing overriding configuration keys: https://github.com/spalger/rcloader/issues/10
|
||||
|
||||
<a name="4.2.0"></a>
|
||||
# 4.2.0 (2015-12-13)
|
||||
|
||||
## Changes
|
||||
|
||||
- Added "typings" support, now gulp-tslint types are automatically enabled in TypeScript
|
||||
- Converted to TypeScript
|
||||
|
||||
<a name="4.1.0"></a>
|
||||
# 4.1.0 (2015-11-29)
|
||||
|
||||
## Changes
|
||||
|
||||
- summarizeFailureOutput now works with emitError: false
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
# 4.0.0 (2015-11-27)
|
||||
|
||||
## Changes
|
||||
|
||||
- **breaking change**: Update tslint to 3.0.0
|
||||
- **breaking change**: tslint is now a peer dependency
|
||||
|
||||
<a name="3.2.0"></a>
|
||||
# 3.2.0 (2015-08-13)
|
||||
|
||||
## Changes
|
||||
|
||||
- Add the tslint option to supply a custom tslint module
|
||||
|
||||
<a name="3.0.0-beta"></a>
|
||||
# 3.0.0-beta (2015-05-11)
|
||||
|
||||
## Changes
|
||||
|
||||
- Update tslint to use the TypeScript 1.5.0-beta compiler
|
||||
- Due to changes to the typescript compiler API, old custom rules may no longer work and may need to be rewritten
|
||||
- the JSON formatter's line and character positions are now back to being 0-indexed instead of 1-indexed
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
# 2.0.0 (2015-04-12)
|
||||
|
||||
## Changes
|
||||
|
||||
- Gulp util's logging used for printing errors.
|
||||
|
||||
<a name="1.4.0"></a>
|
||||
# 1.4.1 (2014-11-13)
|
||||
|
||||
## Changes
|
||||
|
||||
- The PluginError exception now includes information about the failures
|
||||
- Update tslint to 1.0.0
|
||||
|
||||
<a name="1.3.1"></a>
|
||||
# 1.3.1 (2014-09-28)
|
||||
|
||||
## Changes
|
||||
|
||||
- Add .npmignore for reduced package size.
|
||||
|
||||
<a name="1.2.0"></a>
|
||||
# 1.2.0 (2014-06-14)
|
||||
|
||||
## Changes
|
||||
|
||||
- Fix rulesDirectory
|
||||
- Remove formattersDirectory
|
||||
21
node_modules/gulp-tslint/LICENSE
generated
vendored
Normal file
21
node_modules/gulp-tslint/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Panu Horsmalahti
|
||||
|
||||
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.
|
||||
222
node_modules/gulp-tslint/README.md
generated
vendored
Normal file
222
node_modules/gulp-tslint/README.md
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
gulp-tslint
|
||||
===========
|
||||
|
||||
[](https://travis-ci.org/panuhorsmalahti/gulp-tslint)
|
||||
[](https://david-dm.org/panuhorsmalahti/gulp-tslint)
|
||||
|
||||
TypeScript linter plugin for Gulp.
|
||||
|
||||
|
||||
First install gulp-tslint
|
||||
```shell
|
||||
npm install --save-dev gulp-tslint
|
||||
```
|
||||
|
||||
##### Peer dependencies
|
||||
|
||||
The `tslint` module is a peer dependency of `gulp-tslint`, which allows you to update tslint independently from gulp-tslint. gulp-tslint requires TypeScript version >=2 and tslint version >=4.
|
||||
|
||||
Usage:
|
||||
```javascript
|
||||
// Importing in ES6
|
||||
import tslint from "gulp-tslint";
|
||||
|
||||
// or requiring in ES5
|
||||
var tslint = require("gulp-tslint");
|
||||
|
||||
gulp.task("tslint", () =>
|
||||
gulp.src("source.ts")
|
||||
.pipe(tslint({
|
||||
formatter: "verbose"
|
||||
}))
|
||||
.pipe(tslint.report())
|
||||
);
|
||||
```
|
||||
|
||||
Types should work automatically.
|
||||
|
||||
**tslint.json** is attempted to be read from near the input file.
|
||||
It **must be available** or supplied directly through the options.
|
||||
|
||||
Failures generated by TSLint are added to `file.tslint`.
|
||||
|
||||
The format in which failures are outputted may be controlled by specifying a TSLint formatter.
|
||||
The default formatter is "prose".
|
||||
The available formatters include:
|
||||
|
||||
* "json" prints stringified JSON to console.log.
|
||||
* "prose" prints short human-readable failures to console.log.
|
||||
* "verbose" prints longer human-readable failures to console.log.
|
||||
* "msbuild" for Visual Studio
|
||||
* "vso" outputs failures in a format that can be integrated with Visual Studio Online.
|
||||
* "checkstyle" for the Checkstyle development tool
|
||||
* "pmd" for the PMD source code analyzer
|
||||
* "stylish" human-readable formatter which creates stylish messages.
|
||||
|
||||
Custom [TSLint formatters](https://palantir.github.io/tslint/develop/custom-formatters/) may also be
|
||||
used by specifying the `formatter` and `formattersDirectory` properties on the options passed to
|
||||
`gulp-tslint`.
|
||||
|
||||
If upgrading to gulp-tslint v6.0.0 or greater, it should be noted that reporters have been removed
|
||||
in favour of using TSLint formatters directly. If you were previously specifying a reporter in calls
|
||||
to `.report()`, these should be removed and instead `formatter` should be specified in calls to
|
||||
`gulp-tslint`.
|
||||
|
||||
If there is at least one failure a PluginError is emitted after execution of the reporters:
|
||||
```javascript
|
||||
[gulp] Error in plugin 'gulp-tslint': Failed to lint: input.ts
|
||||
```
|
||||
|
||||
You can prevent emiting the error by setting emitError in report options to false.
|
||||
|
||||
```javascript
|
||||
gulp.task("invalid-noemit", () =>
|
||||
gulp.src("input.ts")
|
||||
.pipe(tslint({
|
||||
formatter: "prose"
|
||||
}))
|
||||
.pipe(tslint.report({
|
||||
emitError: false
|
||||
}))
|
||||
);
|
||||
```
|
||||
|
||||
You can summarize the gulp error message to the number of errors by setting summarizeFailureOutput in report options.
|
||||
|
||||
```javascript
|
||||
gulp.task("invalid-noemit", () =>
|
||||
gulp.src("input.ts")
|
||||
.pipe(tslint({
|
||||
formatter: "prose"
|
||||
}))
|
||||
.pipe(tslint.report({
|
||||
summarizeFailureOutput: true
|
||||
}))
|
||||
);
|
||||
```
|
||||
|
||||
tslint.json can be supplied as a parameter by setting the configuration property.
|
||||
```javascript
|
||||
gulp.task("tslint-json", () =>
|
||||
gulp.src("input.ts")
|
||||
.pipe(tslint({
|
||||
configuration: {
|
||||
rules: {
|
||||
"class-name": true,
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}))
|
||||
.pipe(tslint.report())
|
||||
);
|
||||
```
|
||||
|
||||
You can also supply a file path to the configuration option, and the file name
|
||||
doesn't need to be tslint.json.
|
||||
|
||||
```javascript
|
||||
.pipe(tslint({
|
||||
// contains rules in the tslint.json format
|
||||
configuration: "source/settings.json"
|
||||
}))
|
||||
```
|
||||
|
||||
Report limits
|
||||
-------------
|
||||
|
||||
You can optionally specify a report limit in the .report options that will turn off reporting for files after the limit has been reached. If the limit is 0 or less, the limit is ignored, which is the default setting.
|
||||
|
||||
```javascript
|
||||
gulp.task("tslint", () =>
|
||||
gulp.src(["input.ts",])
|
||||
.pipe(tslint({
|
||||
formatter: "prose"
|
||||
}))
|
||||
.pipe(tslint.report({
|
||||
reportLimit: 2
|
||||
}))
|
||||
);
|
||||
```
|
||||
|
||||
Allowing Warnings
|
||||
-----------------
|
||||
|
||||
TSLint 5.0 introduced support for a "warning" severity for linting errors. By default, warnings cause `gulp-tslint` to emit an error to maintain backwards-compatibility with previous versions. To let the build succeed in the presence of warnings, use the `allowWarnings` report option.
|
||||
|
||||
```javascript
|
||||
gulp.task("tslint", () =>
|
||||
gulp.src("input.ts")
|
||||
.pipe(tslint({
|
||||
formatter: "prose"
|
||||
}))
|
||||
.pipe(tslint.report({
|
||||
allowWarnings: true
|
||||
}))
|
||||
);
|
||||
```
|
||||
|
||||
Specifying the tslint module
|
||||
----------------------------
|
||||
|
||||
If you want to use a different version of tslint, you can supply it with the `tslint` option.
|
||||
|
||||
```bash
|
||||
npm install tslint@next
|
||||
```
|
||||
|
||||
```javascript
|
||||
.pipe(tslint({
|
||||
tslint: require("tslint")
|
||||
}));
|
||||
```
|
||||
|
||||
Type checked rules
|
||||
------------------
|
||||
|
||||
Type checked rules require a TypeScript program object to be provided to the linter in the options. For more information see tslint documentation.
|
||||
|
||||
```javascript
|
||||
var gulpTslint = require("gulp-tslint");
|
||||
var tslint = require("tslint");
|
||||
|
||||
// NOTE: Ensure 'Linter.createProgram' is called inside the gulp task else the contents of the files will be cached
|
||||
// if this tasks is called again (eg. as part of a 'watch' task).
|
||||
gulp.task('lint', function() {
|
||||
var program = tslint.Linter.createProgram("./tsconfig.json");
|
||||
|
||||
return gulp.src('src/**/*.ts', { base: '.' })
|
||||
.pipe(gulpTslint({ program }));
|
||||
}
|
||||
```
|
||||
|
||||
All default tslint options
|
||||
--------------------------
|
||||
|
||||
```javascript
|
||||
const tslintOptions = {
|
||||
configuration: {},
|
||||
fix: false,
|
||||
formatter: "prose",
|
||||
formattersDirectory: null,
|
||||
rulesDirectory: null,
|
||||
tslint: null,
|
||||
program: null
|
||||
};
|
||||
```
|
||||
|
||||
All default report options
|
||||
--------------------------
|
||||
|
||||
```javascript
|
||||
const reportOptions = {
|
||||
emitError: true,
|
||||
reportLimit: 0,
|
||||
summarizeFailureOutput: false,
|
||||
allowWarnings: false
|
||||
};
|
||||
```
|
||||
|
||||
Development
|
||||
===========
|
||||
|
||||
Fork this repository, run npm install and send pull requests. The project can be build with ``gulp`` command.
|
||||
37
node_modules/gulp-tslint/index.d.ts
generated
vendored
Normal file
37
node_modules/gulp-tslint/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/// <reference types="node" />
|
||||
export interface PluginOptions {
|
||||
configuration?: any;
|
||||
fix?: boolean;
|
||||
formatter?: string | Function;
|
||||
formattersDirectory?: string;
|
||||
rulesDirectory?: string;
|
||||
tslint?: any;
|
||||
program?: any;
|
||||
}
|
||||
export interface ReportOptions {
|
||||
emitError?: boolean;
|
||||
reportLimit?: number;
|
||||
summarizeFailureOutput?: boolean;
|
||||
allowWarnings?: boolean;
|
||||
}
|
||||
export interface TslintFile {
|
||||
tslint: any;
|
||||
path: string;
|
||||
relative: string;
|
||||
contents: Buffer | any;
|
||||
isStream(): boolean;
|
||||
isNull(): boolean;
|
||||
}
|
||||
export interface TslintPlugin {
|
||||
(pluginOptions?: PluginOptions): NodeJS.ReadWriteStream;
|
||||
report: (options?: ReportOptions) => NodeJS.ReadWriteStream;
|
||||
pluginOptions: PluginOptions;
|
||||
}
|
||||
/**
|
||||
* Main plugin function
|
||||
* @param {PluginOptions} [pluginOptions] contains the options for gulp-tslint.
|
||||
* Optional.
|
||||
* @returns {any}
|
||||
*/
|
||||
declare const tslintPlugin: TslintPlugin;
|
||||
export default tslintPlugin;
|
||||
219
node_modules/gulp-tslint/index.js
generated
vendored
Normal file
219
node_modules/gulp-tslint/index.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/*jshint node:true */
|
||||
/*jshint nomen: true */
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Requires
|
||||
var colors = require("ansi-colors");
|
||||
var fancyLog = require("fancy-log");
|
||||
var TSLint = require("tslint");
|
||||
var through = require("through");
|
||||
var PluginError = require("plugin-error");
|
||||
var map = require("map-stream");
|
||||
/**
|
||||
* Helper function to check if a value is a function
|
||||
* @param {any} value to check whether or not it is a function
|
||||
* @returns {boolean} Returns true if the value is a function
|
||||
*/
|
||||
function isFunction(value) {
|
||||
return Object.prototype.toString.call(value) === "[object Function]";
|
||||
}
|
||||
/**
|
||||
* Helper function to check if a value is a string
|
||||
* @param {any} value to check whether or not it is a string
|
||||
* @returns {boolean} Returns true if the value is a string
|
||||
*/
|
||||
function isString(value) {
|
||||
return Object.prototype.toString.call(value) === "[object String]";
|
||||
}
|
||||
/**
|
||||
* Returns the TSLint from the options, or if not set, the default TSLint.
|
||||
* @param {PluginOptions} options
|
||||
* @returns {any} TSLint module
|
||||
*/
|
||||
function getTslint(options) {
|
||||
if (options && options.tslint) {
|
||||
return options.tslint;
|
||||
}
|
||||
return TSLint;
|
||||
}
|
||||
/**
|
||||
* Log an event or error using gutil.log.
|
||||
* @param {string} message the log message.
|
||||
* @param {string} level can be "error". Optional.
|
||||
* Leave empty for the default logging type.
|
||||
*/
|
||||
function log(message, level) {
|
||||
var prefix = "[" + colors.cyan("gulp-tslint") + "]";
|
||||
if (level === "error") {
|
||||
fancyLog(prefix, colors.red("error"), message);
|
||||
}
|
||||
else {
|
||||
fancyLog(prefix, message);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Convert a failure to the prose error format.
|
||||
* @param {RuleFailure} failure
|
||||
* @returns {string} The failure in the prose error formar.
|
||||
*/
|
||||
var proseErrorFormat = function (failure) {
|
||||
var fileName = failure.getFileName();
|
||||
var failureString = failure.getFailure();
|
||||
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
|
||||
var line = lineAndCharacter.line + 1;
|
||||
var character = lineAndCharacter.character + 1;
|
||||
return fileName + " [" + line + ", " + character + "]: " + failureString;
|
||||
};
|
||||
/**
|
||||
* Main plugin function
|
||||
* @param {PluginOptions} [pluginOptions] contains the options for gulp-tslint.
|
||||
* Optional.
|
||||
* @returns {any}
|
||||
*/
|
||||
var tslintPlugin = function (pluginOptions) {
|
||||
// If user options are undefined, set an empty options object
|
||||
if (!pluginOptions) {
|
||||
pluginOptions = {};
|
||||
}
|
||||
// Save off pluginOptions so we can get it in `report()`
|
||||
tslintPlugin.pluginOptions = pluginOptions;
|
||||
// TSLint default options
|
||||
var options = {
|
||||
fix: pluginOptions.fix || false,
|
||||
formatter: pluginOptions.formatter || "prose",
|
||||
formattersDirectory: pluginOptions.formattersDirectory || null,
|
||||
rulesDirectory: pluginOptions.rulesDirectory || null
|
||||
};
|
||||
var linter = getTslint(pluginOptions);
|
||||
var tslint = new linter.Linter(options, pluginOptions.program);
|
||||
return map(function (file, cb) {
|
||||
// Skip
|
||||
if (file.isNull()) {
|
||||
return cb(null, file);
|
||||
}
|
||||
// Stream is not supported
|
||||
if (file.isStream()) {
|
||||
return cb(new PluginError("gulp-tslint", "Streaming not supported"));
|
||||
}
|
||||
var configuration = (pluginOptions.configuration === null ||
|
||||
pluginOptions.configuration === undefined ||
|
||||
isString(pluginOptions.configuration))
|
||||
// Configuration can be a file path or null, if it's unknown
|
||||
? linter.Configuration.findConfiguration(pluginOptions.configuration || null, file.path).results
|
||||
: pluginOptions.configuration;
|
||||
tslint.lint(file.path, file.contents.toString("utf8"), configuration);
|
||||
file.tslint = tslint.getResult();
|
||||
// Clear all results for current file from tslint
|
||||
tslint.failures = [];
|
||||
tslint.fixes = [];
|
||||
// Pass file
|
||||
cb(null, file);
|
||||
});
|
||||
};
|
||||
tslintPlugin.report = function (options) {
|
||||
// Default options
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
if (options.emitError === undefined) {
|
||||
options.emitError = true;
|
||||
}
|
||||
if (options.reportLimit === undefined) {
|
||||
// 0 or less is unlimited
|
||||
options.reportLimit = 0;
|
||||
}
|
||||
if (options.summarizeFailureOutput === undefined) {
|
||||
options.summarizeFailureOutput = false;
|
||||
}
|
||||
if (options.allowWarnings === undefined) {
|
||||
options.allowWarnings = false;
|
||||
}
|
||||
// Collect all files with errors
|
||||
var errorFiles = [];
|
||||
// Collect all failures
|
||||
var allFailures = [];
|
||||
// Track how many errors have been reported
|
||||
var totalReported = 0;
|
||||
// Log formatted output for each file individually
|
||||
var reportFailures = function (file) {
|
||||
if (file.tslint) {
|
||||
// Version 5.0.0 of tslint no longer has a failureCount member
|
||||
// It was renamed to errorCount. See tslint issue #2439
|
||||
var failureCount = file.tslint.errorCount;
|
||||
if (!options.allowWarnings) {
|
||||
failureCount += file.tslint.warningCount;
|
||||
}
|
||||
if (failureCount > 0) {
|
||||
errorFiles.push(file);
|
||||
Array.prototype.push.apply(allFailures, file.tslint.failures);
|
||||
if (options.reportLimit <= 0 || (options.reportLimit && options.reportLimit > totalReported)) {
|
||||
if (file.tslint.output !== undefined) {
|
||||
// If any errors were found, print all warnings and errors
|
||||
console.log(file.tslint.output);
|
||||
}
|
||||
totalReported += failureCount;
|
||||
if (options.reportLimit > 0 &&
|
||||
options.reportLimit <= totalReported) {
|
||||
log("More than " + options.reportLimit
|
||||
+ " failures reported. Turning off reporter.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (options.allowWarnings && file.tslint.warningCount > 0) {
|
||||
// Íf only warnings were emitted, format and print them
|
||||
// Figure out which formatter the user requested in `tslintPlugin()` and construct one
|
||||
var formatterConstructor = TSLint.findFormatter(tslintPlugin.pluginOptions.formatter);
|
||||
var formatter = new formatterConstructor();
|
||||
// Get just the warnings
|
||||
var warnings = file.tslint.failures.filter(function (failure) { return failure.getRuleSeverity() === "warning"; });
|
||||
// Print the output of those
|
||||
console.log(formatter.format(warnings));
|
||||
}
|
||||
}
|
||||
// Pass file
|
||||
this.emit("data", file);
|
||||
};
|
||||
/**
|
||||
* After reporting on all files, throw the error.
|
||||
*/
|
||||
var throwErrors = function () {
|
||||
// Throw error
|
||||
if (options && errorFiles.length > 0) {
|
||||
var failuresToOutput = allFailures;
|
||||
var ignoreFailureCount = 0;
|
||||
// If error count is limited, calculate number of errors not shown and slice reportLimit
|
||||
// number of errors to be included in the error.
|
||||
if (options.reportLimit > 0) {
|
||||
ignoreFailureCount = allFailures.length - options.reportLimit;
|
||||
failuresToOutput = allFailures.slice(0, options.reportLimit);
|
||||
}
|
||||
// Always use the proseErrorFormat for the error.
|
||||
var failureOutput = failuresToOutput.map(function (failure) {
|
||||
return proseErrorFormat(failure);
|
||||
}).join(", ");
|
||||
var errorOutput = "Failed to lint: ";
|
||||
if (options.summarizeFailureOutput) {
|
||||
errorOutput += failuresToOutput.length + " errors.";
|
||||
}
|
||||
else {
|
||||
errorOutput += failureOutput + ".";
|
||||
}
|
||||
if (ignoreFailureCount > 0) {
|
||||
errorOutput += " (" + ignoreFailureCount + " other errors not shown.)";
|
||||
}
|
||||
if (options.emitError === true) {
|
||||
return this.emit("error", new PluginError("gulp-tslint", errorOutput));
|
||||
}
|
||||
else if (options.summarizeFailureOutput) {
|
||||
log(errorOutput);
|
||||
}
|
||||
}
|
||||
// Notify through that we're done
|
||||
this.emit("end");
|
||||
};
|
||||
return through(reportFailures, throwErrors);
|
||||
};
|
||||
exports.default = tslintPlugin;
|
||||
// ES5/ES6 fallbacks
|
||||
module.exports = tslintPlugin;
|
||||
module.exports.default = tslintPlugin;
|
||||
60
node_modules/gulp-tslint/package.json
generated
vendored
Normal file
60
node_modules/gulp-tslint/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "gulp-tslint",
|
||||
"preferGlobal": false,
|
||||
"version": "8.1.4",
|
||||
"author": "Panu Horsmalahti <panu.horsmalahti@iki.fi>",
|
||||
"description": "TypeScript linter Gulp plugin",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Panu Horsmalahti",
|
||||
"email": "panu.horsmalahti@iki.fi"
|
||||
}
|
||||
],
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/panuhorsmalahti/gulp-tslint.git"
|
||||
},
|
||||
"keywords": [
|
||||
"gulp",
|
||||
"typescript",
|
||||
"plugin",
|
||||
"ts",
|
||||
"gulpplugin",
|
||||
"gulpfriendly",
|
||||
"tslint",
|
||||
"linter",
|
||||
"lint"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/fancy-log": "1.3.0",
|
||||
"ansi-colors": "^1.0.1",
|
||||
"fancy-log": "1.3.3",
|
||||
"map-stream": "~0.0.7",
|
||||
"plugin-error": "1.0.1",
|
||||
"through": "~2.3.8"
|
||||
},
|
||||
"analyze": true,
|
||||
"devDependencies": {
|
||||
"@types/ansi-colors": "^1.0.0",
|
||||
"@types/node": "^11.9.4",
|
||||
"@types/through": "0.0.29",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-typescript": "^3.2.1",
|
||||
"tslint": "^5",
|
||||
"typescript": "^3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tslint": ">=5.0.0-dev"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/panuhorsmalahti/gulp-tslint/issues"
|
||||
},
|
||||
"homepage": "https://github.com/panuhorsmalahti/gulp-tslint",
|
||||
"typings": "index"
|
||||
}
|
||||
25
node_modules/gulp-tslint/tsconfig.json
generated
vendored
Normal file
25
node_modules/gulp-tslint/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"filesGlob": [
|
||||
"./index.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": false,
|
||||
"outDir": ".",
|
||||
"rootDir": ".",
|
||||
"sourceMap": false,
|
||||
"declaration": true,
|
||||
"lib" : ["es2015"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"files": [
|
||||
"./index.ts"
|
||||
],
|
||||
"atom": {
|
||||
"rewriteTsconfig": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user